Changeset 154329 in webkit


Ignore:
Timestamp:
Aug 20, 2013 8:57:38 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

<https://webkit.org/b/119487> [Gtk] Cancel authentication on load failed

Patch by Anton Obzhirov <Anton Obzhirov> on 2013-08-20
Reviewed by Martin Robinson.

Added callback to handle load-failed event in default authentication dialog.
Authentication request gets cancelled and the dialog widget gets destroyed.

  • UIProcess/API/gtk/WebKitAuthenticationDialog.cpp:

(pageLoadFailed):
(webkitAuthenticationDialogInitialize):
(webkitAuthenticationDialogDispose):
(webkit_authentication_dialog_class_init):
(webkitAuthenticationDialogNew):

  • UIProcess/API/gtk/WebKitAuthenticationDialog.h:
  • UIProcess/API/gtk/WebKitWebView.cpp:

(webkitWebViewAuthenticate):

Location:
trunk/Source/WebKit2
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r154321 r154329  
     12013-08-20  Anton Obzhirov  <a.obzhirov@samsung.com>
     2
     3        <https://webkit.org/b/119487> [Gtk] Cancel authentication on load failed
     4
     5        Reviewed by Martin Robinson.
     6
     7        Added callback to handle load-failed event in default authentication dialog.
     8        Authentication request gets cancelled and the dialog widget gets destroyed.
     9
     10        * UIProcess/API/gtk/WebKitAuthenticationDialog.cpp:
     11        (pageLoadFailed):
     12        (webkitAuthenticationDialogInitialize):
     13        (webkitAuthenticationDialogDispose):
     14        (webkit_authentication_dialog_class_init):
     15        (webkitAuthenticationDialogNew):
     16        * UIProcess/API/gtk/WebKitAuthenticationDialog.h:
     17        * UIProcess/API/gtk/WebKitWebView.cpp:
     18        (webkitWebViewAuthenticate):
     19
    1202013-08-20  Allan Sandfeld Jensen  <allan.jensen@digia.com>
    221
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitAuthenticationDialog.cpp

    r153882 r154329  
    2525#include "WebKitCredentialPrivate.h"
    2626#include "WebKitPrivate.h"
     27#include "WebKitWebView.h"
    2728
    2829using namespace WebKit;
     
    3233    GtkWidget* authWidget;
    3334    GtkWidget* defaultButton;
     35    unsigned long loadFailedEventID;
    3436    GRefPtr<GtkStyleContext> styleContext;
     37    WebKitWebView* webView;
    3538};
    3639
     
    5255}
    5356
    54 static void webkitAuthenticationDialogInitialize(WebKitAuthenticationDialog* authDialog, CredentialStorageMode credentialStorageMode)
     57static void pageLoadFailed(WebKitWebView*, WebKitLoadEvent, const char*, GError*, WebKitAuthenticationDialog* authDialog)
     58{
     59    webkit_authentication_request_cancel(authDialog->priv->request.get());
     60    gtk_widget_destroy(GTK_WIDGET(authDialog));
     61}
     62
     63static void webkitAuthenticationDialogInitialize(WebKitAuthenticationDialog* authDialog, CredentialStorageMode credentialStorageMode, WebKitWebView* webView)
    5564{
    5665    GtkWidget* frame = gtk_frame_new(0);
     
    8998    gtk_container_add(GTK_CONTAINER(authDialog), frame);
    9099    gtk_widget_show(frame);
     100
     101    authDialog->priv->webView = webView;
     102    authDialog->priv->loadFailedEventID = g_signal_connect(webView, "load-failed", G_CALLBACK(pageLoadFailed), authDialog);
    91103}
    92104
     
    125137}
    126138
     139static void webkitAuthenticationDialogDispose(GObject* object)
     140{
     141    WebKitAuthenticationDialogPrivate* priv = WEBKIT_AUTHENTICATION_DIALOG(object)->priv;
     142    if (priv->loadFailedEventID) {
     143        g_signal_handler_disconnect(priv->webView, priv->loadFailedEventID);
     144        priv->loadFailedEventID = 0;
     145    }
     146
     147    G_OBJECT_CLASS(webkit_authentication_dialog_parent_class)->dispose(object);
     148}
     149
    127150static void webkit_authentication_dialog_class_init(WebKitAuthenticationDialogClass* klass)
    128151{
    129152    GObjectClass* objectClass = G_OBJECT_CLASS(klass);
    130153    objectClass->constructed = webkitAuthenticationDialogConstructed;
     154    objectClass->dispose = webkitAuthenticationDialogDispose;
    131155
    132156    GtkWidgetClass* widgetClass = GTK_WIDGET_CLASS(klass);
     
    135159}
    136160
    137 GtkWidget* webkitAuthenticationDialogNew(WebKitAuthenticationRequest* request, CredentialStorageMode mode)
     161GtkWidget* webkitAuthenticationDialogNew(WebKitAuthenticationRequest* request, CredentialStorageMode mode, WebKitWebView* webView)
    138162{
    139163    WebKitAuthenticationDialog* authDialog = WEBKIT_AUTHENTICATION_DIALOG(g_object_new(WEBKIT_TYPE_AUTHENTICATION_DIALOG, NULL));
    140164    authDialog->priv->request = request;
    141     webkitAuthenticationDialogInitialize(authDialog, mode);
     165    webkitAuthenticationDialogInitialize(authDialog, mode, webView);
    142166    return GTK_WIDGET(authDialog);
    143167}
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitAuthenticationDialog.h

    r153882 r154329  
    2323#include "WebKitAuthenticationRequest.h"
    2424#include "WebKitAuthenticationWidget.h"
     25#include "WebKitWebView.h"
    2526#include <gtk/gtk.h>
    2627
     
    4950
    5051GType webkit_authentication_dialog_get_type();
    51 GtkWidget* webkitAuthenticationDialogNew(WebKitAuthenticationRequest*, CredentialStorageMode);
     52GtkWidget* webkitAuthenticationDialogNew(WebKitAuthenticationRequest*, CredentialStorageMode, WebKitWebView*);
    5253
    5354G_END_DECLS
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp

    r153882 r154329  
    436436{
    437437    CredentialStorageMode credentialStorageMode = webkit_authentication_request_can_save_credentials(request) ? AllowPersistentStorage : DisallowPersistentStorage;
    438     webkitWebViewBaseAddAuthenticationDialog(WEBKIT_WEB_VIEW_BASE(webView), webkitAuthenticationDialogNew(request, credentialStorageMode));
     438    webkitWebViewBaseAddAuthenticationDialog(WEBKIT_WEB_VIEW_BASE(webView), webkitAuthenticationDialogNew(request, credentialStorageMode, webView));
    439439
    440440    return TRUE;
Note: See TracChangeset for help on using the changeset viewer.