Title: [154329] trunk/Source/WebKit2
Revision
154329
Author
[email protected]
Date
2013-08-20 08:57:38 -0700 (Tue, 20 Aug 2013)

Log Message

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

Patch by Anton Obzhirov <[email protected]> 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):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (154328 => 154329)


--- trunk/Source/WebKit2/ChangeLog	2013-08-20 15:52:27 UTC (rev 154328)
+++ trunk/Source/WebKit2/ChangeLog	2013-08-20 15:57:38 UTC (rev 154329)
@@ -1,3 +1,22 @@
+2013-08-20  Anton Obzhirov  <[email protected]>
+
+        <https://webkit.org/b/119487> [Gtk] Cancel authentication on load failed
+
+        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):
+
 2013-08-20  Allan Sandfeld Jensen  <[email protected]>
 
         [Qt][WK2] Doesn't build without Plugin-process

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitAuthenticationDialog.cpp (154328 => 154329)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitAuthenticationDialog.cpp	2013-08-20 15:52:27 UTC (rev 154328)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitAuthenticationDialog.cpp	2013-08-20 15:57:38 UTC (rev 154329)
@@ -24,6 +24,7 @@
 #include "WebKitAuthenticationRequestPrivate.h"
 #include "WebKitCredentialPrivate.h"
 #include "WebKitPrivate.h"
+#include "WebKitWebView.h"
 
 using namespace WebKit;
 
@@ -31,7 +32,9 @@
     GRefPtr<WebKitAuthenticationRequest> request;
     GtkWidget* authWidget;
     GtkWidget* defaultButton;
+    unsigned long loadFailedEventID;
     GRefPtr<GtkStyleContext> styleContext;
+    WebKitWebView* webView;
 };
 
 WEBKIT_DEFINE_TYPE(WebKitAuthenticationDialog, webkit_authentication_dialog, GTK_TYPE_EVENT_BOX)
@@ -51,8 +54,14 @@
     gtk_widget_destroy(GTK_WIDGET(authDialog));
 }
 
-static void webkitAuthenticationDialogInitialize(WebKitAuthenticationDialog* authDialog, CredentialStorageMode credentialStorageMode)
+static void pageLoadFailed(WebKitWebView*, WebKitLoadEvent, const char*, GError*, WebKitAuthenticationDialog* authDialog)
 {
+    webkit_authentication_request_cancel(authDialog->priv->request.get());
+    gtk_widget_destroy(GTK_WIDGET(authDialog));
+}
+
+static void webkitAuthenticationDialogInitialize(WebKitAuthenticationDialog* authDialog, CredentialStorageMode credentialStorageMode, WebKitWebView* webView)
+{
     GtkWidget* frame = gtk_frame_new(0);
     gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
 
@@ -88,6 +97,9 @@
 
     gtk_container_add(GTK_CONTAINER(authDialog), frame);
     gtk_widget_show(frame);
+
+    authDialog->priv->webView = webView;
+    authDialog->priv->loadFailedEventID = g_signal_connect(webView, "load-failed", G_CALLBACK(pageLoadFailed), authDialog);
 }
 
 static gboolean webkitAuthenticationDialogDraw(GtkWidget* widget, cairo_t* cr)
@@ -124,20 +136,32 @@
     gtk_widget_path_free(path);
 }
 
+static void webkitAuthenticationDialogDispose(GObject* object)
+{
+    WebKitAuthenticationDialogPrivate* priv = WEBKIT_AUTHENTICATION_DIALOG(object)->priv;
+    if (priv->loadFailedEventID) {
+        g_signal_handler_disconnect(priv->webView, priv->loadFailedEventID);
+        priv->loadFailedEventID = 0;
+    }
+
+    G_OBJECT_CLASS(webkit_authentication_dialog_parent_class)->dispose(object);
+}
+
 static void webkit_authentication_dialog_class_init(WebKitAuthenticationDialogClass* klass)
 {
     GObjectClass* objectClass = G_OBJECT_CLASS(klass);
     objectClass->constructed = webkitAuthenticationDialogConstructed;
+    objectClass->dispose = webkitAuthenticationDialogDispose;
 
     GtkWidgetClass* widgetClass = GTK_WIDGET_CLASS(klass);
     widgetClass->draw = webkitAuthenticationDialogDraw;
     widgetClass->map = webkitAuthenticationDialogMap;
 }
 
-GtkWidget* webkitAuthenticationDialogNew(WebKitAuthenticationRequest* request, CredentialStorageMode mode)
+GtkWidget* webkitAuthenticationDialogNew(WebKitAuthenticationRequest* request, CredentialStorageMode mode, WebKitWebView* webView)
 {
     WebKitAuthenticationDialog* authDialog = WEBKIT_AUTHENTICATION_DIALOG(g_object_new(WEBKIT_TYPE_AUTHENTICATION_DIALOG, NULL));
     authDialog->priv->request = request;
-    webkitAuthenticationDialogInitialize(authDialog, mode);
+    webkitAuthenticationDialogInitialize(authDialog, mode, webView);
     return GTK_WIDGET(authDialog);
 }

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitAuthenticationDialog.h (154328 => 154329)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitAuthenticationDialog.h	2013-08-20 15:52:27 UTC (rev 154328)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitAuthenticationDialog.h	2013-08-20 15:57:38 UTC (rev 154329)
@@ -22,6 +22,7 @@
 
 #include "WebKitAuthenticationRequest.h"
 #include "WebKitAuthenticationWidget.h"
+#include "WebKitWebView.h"
 #include <gtk/gtk.h>
 
 G_BEGIN_DECLS
@@ -48,7 +49,7 @@
 };
 
 GType webkit_authentication_dialog_get_type();
-GtkWidget* webkitAuthenticationDialogNew(WebKitAuthenticationRequest*, CredentialStorageMode);
+GtkWidget* webkitAuthenticationDialogNew(WebKitAuthenticationRequest*, CredentialStorageMode, WebKitWebView*);
 
 G_END_DECLS
 

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp (154328 => 154329)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp	2013-08-20 15:52:27 UTC (rev 154328)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp	2013-08-20 15:57:38 UTC (rev 154329)
@@ -435,7 +435,7 @@
 static gboolean webkitWebViewAuthenticate(WebKitWebView* webView, WebKitAuthenticationRequest* request)
 {
     CredentialStorageMode credentialStorageMode = webkit_authentication_request_can_save_credentials(request) ? AllowPersistentStorage : DisallowPersistentStorage;
-    webkitWebViewBaseAddAuthenticationDialog(WEBKIT_WEB_VIEW_BASE(webView), webkitAuthenticationDialogNew(request, credentialStorageMode));
+    webkitWebViewBaseAddAuthenticationDialog(WEBKIT_WEB_VIEW_BASE(webView), webkitAuthenticationDialogNew(request, credentialStorageMode, webView));
 
     return TRUE;
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to