Changeset 173510 in webkit


Ignore:
Timestamp:
Sep 11, 2014 1:59:45 AM (10 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK] Merge WebKitAuthenticationWidget into WebKitAuthenticationDialog
https://bugs.webkit.org/show_bug.cgi?id=136700

Reviewed by Sergio Villar Senin.

Source/WebCore:

Remove WebKitAuthenticationWidget. The only reason why we had this
widget separated in WebCore was to share it between WebKit1 and
WebKit2, but now it's only used by WebKitAuthenticationDialog in WebKit2.

  • PlatformGTK.cmake: Remove files from compilation.
  • platform/gtk/WebKitAuthenticationWidget.cpp: Removed.
  • platform/gtk/WebKitAuthenticationWidget.h: Removed.

Source/WebCore/platform/gtk/po:

  • POTFILES.in: Remove WebKitAuthenticationWidget.cpp and add WebKitAuthenticationDialog.cpp.

Source/WebKit2:

Copy WebKitAuthenticationWidget implementation inside
WebKitAuthenticationDialog using a normal GtkBox instead.

  • UIProcess/API/gtk/WebKitAuthenticationDialog.cpp:

(okButtonClicked):
(cancelButtonClicked):
(packTwoColumnLayoutInBox):
(createLabel):
(createEntry):
(webkitAuthenticationDialogInitialize): Remove the
CredentialStorageMode parameter since it's now a member.
(webkitAuthenticationDialogNew): Initialize the
CredentialStorageMode member too.

  • UIProcess/API/gtk/WebKitAuthenticationDialog.h:
Location:
trunk/Source
Files:
2 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r173507 r173510  
     12014-09-11  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Merge WebKitAuthenticationWidget into WebKitAuthenticationDialog
     4        https://bugs.webkit.org/show_bug.cgi?id=136700
     5
     6        Reviewed by Sergio Villar Senin.
     7
     8        Remove WebKitAuthenticationWidget. The only reason why we had this
     9        widget separated in WebCore was to share it between WebKit1 and
     10        WebKit2, but now it's only used by WebKitAuthenticationDialog in WebKit2.
     11
     12        * PlatformGTK.cmake: Remove files from compilation.
     13        * platform/gtk/WebKitAuthenticationWidget.cpp: Removed.
     14        * platform/gtk/WebKitAuthenticationWidget.h: Removed.
     15
    1162014-09-10  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
    217
  • trunk/Source/WebCore/PlatformGTK.cmake

    r173401 r173510  
    245245    platform/gtk/TemporaryLinkStubs.cpp
    246246    platform/gtk/UserAgentGtk.cpp
    247     platform/gtk/WebKitAuthenticationWidget.cpp
    248247    platform/gtk/WidgetBackingStoreGtkX11.cpp
    249248    platform/gtk/WidgetGtk.cpp
  • trunk/Source/WebCore/platform/gtk/po/ChangeLog

    r173193 r173510  
     12014-09-11  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Merge WebKitAuthenticationWidget into WebKitAuthenticationDialog
     4        https://bugs.webkit.org/show_bug.cgi?id=136700
     5
     6        Reviewed by Sergio Villar Senin.
     7
     8        * POTFILES.in: Remove WebKitAuthenticationWidget.cpp and add WebKitAuthenticationDialog.cpp.
     9
    1102014-09-02  Christian Stadelmann  <gnome-de@genodeftest.de>
    211
  • trunk/Source/WebCore/platform/gtk/po/POTFILES.in

    r166979 r173510  
    22ErrorsGtk.cpp
    33LocalizedStringsGtk.cpp
    4 WebKitAuthenticationWidget.cpp
    54../../../WebKit2/Shared/Downloads/soup/DownloadSoup.cpp
     5../../../WebKit2/UIProcess/API/gtk/WebKitAuthenticationDialog.cpp
    66../../../WebKit2/UIProcess/API/gtk/WebKitDownload.cpp
    77../../../WebKit2/UIProcess/API/gtk/WebKitFaviconDatabase.cpp
  • trunk/Source/WebKit2/ChangeLog

    r173468 r173510  
     12014-09-11  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Merge WebKitAuthenticationWidget into WebKitAuthenticationDialog
     4        https://bugs.webkit.org/show_bug.cgi?id=136700
     5
     6        Reviewed by Sergio Villar Senin.
     7
     8        Copy WebKitAuthenticationWidget implementation inside
     9        WebKitAuthenticationDialog using a normal GtkBox instead.
     10
     11        * UIProcess/API/gtk/WebKitAuthenticationDialog.cpp:
     12        (okButtonClicked):
     13        (cancelButtonClicked):
     14        (packTwoColumnLayoutInBox):
     15        (createLabel):
     16        (createEntry):
     17        (webkitAuthenticationDialogInitialize): Remove the
     18        CredentialStorageMode parameter since it's now a member.
     19        (webkitAuthenticationDialogNew): Initialize the
     20        CredentialStorageMode member too.
     21        * UIProcess/API/gtk/WebKitAuthenticationDialog.h:
     22
    1232014-09-10  Antti Koivisto  <antti@apple.com>
    224
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitAuthenticationDialog.cpp

    r155347 r173510  
    2626#include "WebKitPrivate.h"
    2727#include "WebKitWebView.h"
     28#include <glib/gi18n-lib.h>
     29#include <wtf/text/CString.h>
    2830
    2931using namespace WebKit;
     
    3133struct _WebKitAuthenticationDialogPrivate {
    3234    GRefPtr<WebKitAuthenticationRequest> request;
    33     GtkWidget* authWidget;
     35    CredentialStorageMode credentialStorageMode;
     36    GtkWidget* loginEntry;
     37    GtkWidget* passwordEntry;
     38    GtkWidget* rememberCheckButton;
    3439    GtkWidget* defaultButton;
    3540    unsigned long authenticationCancelledID;
     
    4247{
    4348    WebKitAuthenticationDialogPrivate* priv = authDialog->priv;
    44     WebKitCredential* credential = webkitCredentialCreate(webkitAuthenticationWidgetCreateCredential(WEBKIT_AUTHENTICATION_WIDGET(priv->authWidget)));
     49    const char* username = gtk_entry_get_text(GTK_ENTRY(priv->loginEntry));
     50    const char* password = gtk_entry_get_text(GTK_ENTRY(priv->passwordEntry));
     51    bool rememberPassword = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->rememberCheckButton));
     52
     53    WebCore::CredentialPersistence persistence = rememberPassword && priv->credentialStorageMode == AllowPersistentStorage ?
     54        WebCore::CredentialPersistencePermanent : WebCore::CredentialPersistenceForSession;
     55
     56    // FIXME: Use a stack allocated WebKitCredential.
     57    WebKitCredential* credential = webkitCredentialCreate(WebCore::Credential(String::fromUTF8(username), String::fromUTF8(password), persistence));
    4558    webkit_authentication_request_authenticate(priv->request.get(), credential);
    4659    webkit_credential_free(credential);
     
    5063static void cancelButtonClicked(GtkButton*, WebKitAuthenticationDialog* authDialog)
    5164{
    52     webkit_authentication_request_authenticate(authDialog->priv->request.get(), 0);
     65    webkit_authentication_request_authenticate(authDialog->priv->request.get(), nullptr);
    5366    gtk_widget_destroy(GTK_WIDGET(authDialog));
    5467}
     
    5972}
    6073
    61 static void webkitAuthenticationDialogInitialize(WebKitAuthenticationDialog* authDialog, CredentialStorageMode credentialStorageMode)
     74static void packTwoColumnLayoutInBox(GtkWidget* box, ...)
     75{
     76    va_list argumentList;
     77    va_start(argumentList, box);
     78
     79    GtkWidget* grid = gtk_grid_new();
     80    gtk_grid_set_column_spacing(GTK_GRID(grid), 6);
     81    gtk_grid_set_row_spacing(GTK_GRID(grid), 6);
     82    gtk_grid_set_column_homogeneous(GTK_GRID(grid), TRUE);
     83
     84    GtkWidget* firstColumnWidget = va_arg(argumentList, GtkWidget*);
     85    int rowNumber = 0;
     86    while (firstColumnWidget) {
     87        GtkWidget* secondColumnWidget = va_arg(argumentList, GtkWidget*);
     88        int firstWidgetWidth = secondColumnWidget ? 1 : 2;
     89
     90        gtk_grid_attach(GTK_GRID(grid), firstColumnWidget, 0, rowNumber, firstWidgetWidth, 1);
     91        gtk_widget_set_hexpand(firstColumnWidget, TRUE);
     92        gtk_widget_set_vexpand(firstColumnWidget, TRUE);
     93        gtk_widget_show(firstColumnWidget);
     94
     95        if (secondColumnWidget) {
     96            gtk_grid_attach(GTK_GRID(grid), secondColumnWidget, 1, rowNumber, 1, 1);
     97            gtk_widget_set_hexpand(secondColumnWidget, TRUE);
     98            gtk_widget_set_vexpand(secondColumnWidget, TRUE);
     99            gtk_widget_show(secondColumnWidget);
     100        }
     101
     102        firstColumnWidget = va_arg(argumentList, GtkWidget*);
     103        rowNumber++;
     104    }
     105
     106    va_end(argumentList);
     107
     108    gtk_box_pack_start(GTK_BOX(box), grid, FALSE, FALSE, 0);
     109    gtk_widget_show(grid);
     110}
     111
     112static GtkWidget* createLabel(const char* labelString, int horizontalPadding = 0)
     113{
     114    GtkWidget* label = gtk_label_new(labelString);
     115    gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
     116    if (horizontalPadding)
     117        gtk_misc_set_padding(GTK_MISC(label), 0, horizontalPadding);
     118    return label;
     119}
     120
     121static GtkWidget* createEntry(GtkWidget** member)
     122{
     123    *member = gtk_entry_new();
     124    gtk_entry_set_activates_default(GTK_ENTRY(*member), TRUE);
     125    return *member;
     126}
     127
     128static void webkitAuthenticationDialogInitialize(WebKitAuthenticationDialog* authDialog)
    62129{
    63130    GtkWidget* frame = gtk_frame_new(0);
     
    77144    gtk_widget_show(button);
    78145
     146    WebKitAuthenticationDialogPrivate* priv = authDialog->priv;
    79147    button = gtk_button_new_from_stock(GTK_STOCK_OK);
    80     authDialog->priv->defaultButton = button;
     148    priv->defaultButton = button;
    81149    g_signal_connect(button, "clicked", G_CALLBACK(okButtonClicked), authDialog);
    82150    gtk_widget_set_can_default(button, TRUE);
     
    84152    gtk_widget_show(button);
    85153
    86     authDialog->priv->authWidget = webkitAuthenticationWidgetNew(webkitAuthenticationRequestGetAuthenticationChallenge(authDialog->priv->request.get())->core(), credentialStorageMode);
    87     gtk_box_pack_start(GTK_BOX(vBox), authDialog->priv->authWidget, TRUE, TRUE, 0);
    88     gtk_widget_show(authDialog->priv->authWidget);
     154    GtkWidget* authBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
     155    gtk_container_set_border_width(GTK_CONTAINER(authBox), 5);
     156
     157    GtkWidget* icon = gtk_image_new_from_stock(GTK_STOCK_DIALOG_AUTHENTICATION, GTK_ICON_SIZE_DIALOG);
     158    gtk_misc_set_alignment(GTK_MISC(icon), 0.5, 0.0);
     159    gtk_box_pack_start(GTK_BOX(authBox), icon, FALSE, FALSE, 0);
     160    gtk_widget_show(icon);
     161
     162    const WebCore::AuthenticationChallenge& challenge = webkitAuthenticationRequestGetAuthenticationChallenge(priv->request.get())->core();
     163    GUniquePtr<char> prompt(g_strdup_printf(_("The site %s:%i requests a username and password"),
     164        challenge.protectionSpace().host().utf8().data(), challenge.protectionSpace().port()));
     165    priv->rememberCheckButton = gtk_check_button_new_with_mnemonic(_("_Remember password"));
     166    gtk_label_set_line_wrap(GTK_LABEL(gtk_bin_get_child(GTK_BIN(priv->rememberCheckButton))), TRUE);
     167
     168    String realm = challenge.protectionSpace().realm();
     169    if (!realm.isEmpty()) {
     170        packTwoColumnLayoutInBox(
     171            authBox,
     172            createLabel(prompt.get(), 6), nullptr,
     173            createLabel(_("Server message:")), createLabel(realm.utf8().data()),
     174            createLabel(_("Username:")), createEntry(&priv->loginEntry),
     175            createLabel(_("Password:")), createEntry(&priv->passwordEntry),
     176            priv->rememberCheckButton, nullptr,
     177            nullptr);
     178
     179    } else {
     180        packTwoColumnLayoutInBox(
     181            authBox,
     182            createLabel(prompt.get(), 6), nullptr,
     183            createLabel(_("Username:")), createEntry(&priv->loginEntry),
     184            createLabel(_("Password:")), createEntry(&priv->passwordEntry),
     185            priv->rememberCheckButton, nullptr, nullptr,
     186            nullptr);
     187    }
     188    gtk_entry_set_visibility(GTK_ENTRY(priv->passwordEntry), FALSE);
     189    gtk_widget_set_visible(priv->rememberCheckButton, priv->credentialStorageMode != DisallowPersistentStorage);
     190
     191    const WebCore::Credential& credentialFromPersistentStorage = challenge.proposedCredential();
     192    if (!credentialFromPersistentStorage.isEmpty()) {
     193        gtk_entry_set_text(GTK_ENTRY(priv->loginEntry), credentialFromPersistentStorage.user().utf8().data());
     194        gtk_entry_set_text(GTK_ENTRY(priv->passwordEntry), credentialFromPersistentStorage.password().utf8().data());
     195        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->rememberCheckButton), TRUE);
     196    }
     197
     198    gtk_widget_grab_focus(priv->loginEntry);
     199
     200    gtk_box_pack_start(GTK_BOX(vBox), authBox, TRUE, TRUE, 0);
     201    gtk_widget_show(authBox);
    89202
    90203    gtk_box_pack_end(GTK_BOX(vBox), buttonBox, FALSE, TRUE, 0);
     
    160273    WebKitAuthenticationDialog* authDialog = WEBKIT_AUTHENTICATION_DIALOG(g_object_new(WEBKIT_TYPE_AUTHENTICATION_DIALOG, NULL));
    161274    authDialog->priv->request = request;
    162     webkitAuthenticationDialogInitialize(authDialog, mode);
     275    authDialog->priv->credentialStorageMode = mode;
     276    webkitAuthenticationDialogInitialize(authDialog);
    163277    return GTK_WIDGET(authDialog);
    164278}
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitAuthenticationDialog.h

    r155347 r173510  
    2222
    2323#include "WebKitAuthenticationRequest.h"
    24 #include "WebKitAuthenticationWidget.h"
    25 #include "WebKitWebView.h"
    2624#include <gtk/gtk.h>
     25
     26enum CredentialStorageMode {
     27    AllowPersistentStorage, // The user is asked whether to store credential information.
     28    DisallowPersistentStorage // Credential information is only kept in the session.
     29};
    2730
    2831G_BEGIN_DECLS
Note: See TracChangeset for help on using the changeset viewer.