Changeset 155347 in webkit
- Timestamp:
- Sep 9, 2013, 6:49:33 AM (13 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 7 edited
-
ChangeLog (modified) (1 diff)
-
UIProcess/API/gtk/WebKitAuthenticationDialog.cpp (modified) (5 diffs)
-
UIProcess/API/gtk/WebKitAuthenticationDialog.h (modified) (1 diff)
-
UIProcess/API/gtk/WebKitAuthenticationRequest.cpp (modified) (4 diffs)
-
UIProcess/API/gtk/WebKitWebView.cpp (modified) (7 diffs)
-
UIProcess/API/gtk/WebKitWebViewBase.cpp (modified) (1 diff)
-
UIProcess/API/gtk/tests/TestWebKitWebView.cpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r155345 r155347 1 2013-09-09 Anton Obzhirov <a.obzhirov@samsung.com> 2 3 [GTK] Cancel the current active WebKitAuthenticationRequest on load failed 4 https://bugs.webkit.org/show_bug.cgi?id=120350 5 6 Reviewed by Carlos Garcia Campos. 7 8 The default dialog does not get closed and the authentication is not cancelled 9 if loading fails or is stopped on a page which requires HTTP authentication. 10 11 This patch cancels the authentication request on load failed 12 and adds new authentication cancelled signal in WebKitAuthenticationRequest 13 to allow the application handling of authentication UI. 14 15 * UIProcess/API/gtk/WebKitAuthenticationDialog.cpp: 16 (authenticationCancelled): 17 (webkitAuthenticationDialogInitialize): 18 (webkitAuthenticationDialogDispose): 19 (webkitAuthenticationDialogNew): 20 * UIProcess/API/gtk/WebKitAuthenticationDialog.h: 21 * UIProcess/API/gtk/WebKitAuthenticationRequest.cpp: 22 (webkit_authentication_request_class_init): 23 (webkit_authentication_request_cancel): 24 * UIProcess/API/gtk/WebKitWebView.cpp: 25 (webkitWebViewAuthenticate): 26 (webkitWebViewLoadFailed): 27 (webkitWebViewHandleAuthenticationChallenge): 28 (webkitWebViewCancelAuthenticationRequest): 29 * UIProcess/API/gtk/tests/TestWebKitWebView.cpp: 30 (testWebViewAuthenticationLoadCancelled): 31 (beforeAll): 32 1 33 2013-09-09 Brian Holt <brian.holt@samsung.com> 2 34 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitAuthenticationDialog.cpp
r154329 r155347 33 33 GtkWidget* authWidget; 34 34 GtkWidget* defaultButton; 35 unsigned long loadFailedEventID;35 unsigned long authenticationCancelledID; 36 36 GRefPtr<GtkStyleContext> styleContext; 37 WebKitWebView* webView;38 37 }; 39 38 … … 55 54 } 56 55 57 static void pageLoadFailed(WebKitWebView*, WebKitLoadEvent, const char*, GError*, WebKitAuthenticationDialog* authDialog)56 static void authenticationCancelled(WebKitAuthenticationRequest*, WebKitAuthenticationDialog* authDialog) 58 57 { 59 webkit_authentication_request_cancel(authDialog->priv->request.get());60 58 gtk_widget_destroy(GTK_WIDGET(authDialog)); 61 59 } 62 60 63 static void webkitAuthenticationDialogInitialize(WebKitAuthenticationDialog* authDialog, CredentialStorageMode credentialStorageMode , WebKitWebView* webView)61 static void webkitAuthenticationDialogInitialize(WebKitAuthenticationDialog* authDialog, CredentialStorageMode credentialStorageMode) 64 62 { 65 63 GtkWidget* frame = gtk_frame_new(0); … … 99 97 gtk_widget_show(frame); 100 98 101 authDialog->priv->webView = webView; 102 authDialog->priv->loadFailedEventID = g_signal_connect(webView, "load-failed", G_CALLBACK(pageLoadFailed), authDialog); 99 authDialog->priv->authenticationCancelledID = g_signal_connect(authDialog->priv->request.get(), "cancelled", G_CALLBACK(authenticationCancelled), authDialog); 103 100 } 104 101 … … 140 137 { 141 138 WebKitAuthenticationDialogPrivate* priv = WEBKIT_AUTHENTICATION_DIALOG(object)->priv; 142 if (priv-> loadFailedEventID) {143 g_signal_handler_disconnect(priv-> webView, priv->loadFailedEventID);144 priv-> loadFailedEventID = 0;139 if (priv->authenticationCancelledID) { 140 g_signal_handler_disconnect(priv->request.get(), priv->authenticationCancelledID); 141 priv->authenticationCancelledID = 0; 145 142 } 146 143 … … 159 156 } 160 157 161 GtkWidget* webkitAuthenticationDialogNew(WebKitAuthenticationRequest* request, CredentialStorageMode mode , WebKitWebView* webView)158 GtkWidget* webkitAuthenticationDialogNew(WebKitAuthenticationRequest* request, CredentialStorageMode mode) 162 159 { 163 160 WebKitAuthenticationDialog* authDialog = WEBKIT_AUTHENTICATION_DIALOG(g_object_new(WEBKIT_TYPE_AUTHENTICATION_DIALOG, NULL)); 164 161 authDialog->priv->request = request; 165 webkitAuthenticationDialogInitialize(authDialog, mode , webView);162 webkitAuthenticationDialogInitialize(authDialog, mode); 166 163 return GTK_WIDGET(authDialog); 167 164 } -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitAuthenticationDialog.h
r154329 r155347 50 50 51 51 GType webkit_authentication_dialog_get_type(); 52 GtkWidget* webkitAuthenticationDialogNew(WebKitAuthenticationRequest*, CredentialStorageMode , WebKitWebView*);52 GtkWidget* webkitAuthenticationDialogNew(WebKitAuthenticationRequest*, CredentialStorageMode); 53 53 54 54 G_END_DECLS -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitAuthenticationRequest.cpp
r153882 r155347 52 52 */ 53 53 54 enum { 55 CANCELLED, 56 57 LAST_SIGNAL 58 }; 59 54 60 struct _WebKitAuthenticationRequestPrivate { 55 61 RefPtr<AuthenticationChallengeProxy> authenticationChallenge; … … 59 65 CString realm; 60 66 }; 67 68 static guint signals[LAST_SIGNAL] = { 0, }; 61 69 62 70 COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_AUTHENTICATION_SCHEME_DEFAULT, ProtectionSpaceAuthenticationSchemeDefault); … … 87 95 GObjectClass* objectClass = G_OBJECT_CLASS(requestClass); 88 96 objectClass->dispose = webkitAuthenticationRequestDispose; 97 98 /** 99 * WebKitAuthenticationRequest::cancelled: 100 * @request: the #WebKitAuthenticationRequest 101 * 102 * This signal is emitted when the user authentication request is 103 * cancelled. It allows the application to dismiss its authentication 104 * dialog in case of page load failure for example. 105 * 106 * Since: 2.2 107 */ 108 signals[CANCELLED] = 109 g_signal_new("cancelled", 110 G_TYPE_FROM_CLASS(objectClass), 111 G_SIGNAL_RUN_LAST, 112 0, 0, 0, 113 g_cclosure_marshal_VOID__VOID, 114 G_TYPE_NONE, 0); 89 115 } 90 116 … … 289 315 290 316 request->priv->authenticationChallenge->listener()->cancel(); 291 } 317 318 g_signal_emit(request, signals[CANCELLED], 0); 319 } -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
r155066 r155347 191 191 192 192 SnapshotResultsMap snapshotResultsMap; 193 GRefPtr<WebKitAuthenticationRequest> authenticationRequest; 193 194 }; 194 195 … … 438 439 { 439 440 CredentialStorageMode credentialStorageMode = webkit_authentication_request_can_save_credentials(request) ? AllowPersistentStorage : DisallowPersistentStorage; 440 webkitWebViewBaseAddAuthenticationDialog(WEBKIT_WEB_VIEW_BASE(webView), webkitAuthenticationDialogNew(request, credentialStorageMode , webView));441 webkitWebViewBaseAddAuthenticationDialog(WEBKIT_WEB_VIEW_BASE(webView), webkitAuthenticationDialogNew(request, credentialStorageMode)); 441 442 442 443 return TRUE; … … 1431 1432 } 1432 1433 1434 static void webkitWebViewCancelAuthenticationRequest(WebKitWebView* webView) 1435 { 1436 if (!webView->priv->authenticationRequest) 1437 return; 1438 1439 webkit_authentication_request_cancel(webView->priv->authenticationRequest.get()); 1440 webView->priv->authenticationRequest.clear(); 1441 } 1442 1433 1443 static void webkitWebViewEmitLoadChanged(WebKitWebView* webView, WebKitLoadEvent loadEvent) 1434 1444 { … … 1436 1446 webkitWebViewSetIsLoading(webView, true); 1437 1447 webkitWebViewWatchForChangesInFavicon(webView); 1438 webkitWebView BaseCancelAuthenticationDialog(WEBKIT_WEB_VIEW_BASE(webView));1448 webkitWebViewCancelAuthenticationRequest(webView); 1439 1449 } else if (loadEvent == WEBKIT_LOAD_FINISHED) { 1440 1450 webkitWebViewSetIsLoading(webView, false); 1441 web View->priv->waitingForMainResource = false;1451 webkitWebViewCancelAuthenticationRequest(webView); 1442 1452 webkitWebViewDisconnectMainResourceResponseChangedSignalHandler(webView); 1443 1453 } else … … 1493 1503 { 1494 1504 webkitWebViewSetIsLoading(webView, false); 1505 webkitWebViewCancelAuthenticationRequest(webView); 1506 1495 1507 gboolean returnValue; 1496 1508 g_signal_emit(webView, signals[LOAD_FAILED], 0, loadEvent, failingURI, error, &returnValue); … … 1501 1513 { 1502 1514 webkitWebViewSetIsLoading(webView, false); 1515 webkitWebViewCancelAuthenticationRequest(webView); 1503 1516 1504 1517 WebKitTLSErrorsPolicy tlsErrorsPolicy = webkit_web_context_get_tls_errors_policy(webView->priv->context); … … 1787 1800 { 1788 1801 gboolean privateBrowsingEnabled = webkit_settings_get_enable_private_browsing(webkit_web_view_get_settings(webView)); 1789 GRefPtr<WebKitAuthenticationRequest> request = adoptGRef(webkitAuthenticationRequestCreate(authenticationChallenge, privateBrowsingEnabled));1802 webView->priv->authenticationRequest = adoptGRef(webkitAuthenticationRequestCreate(authenticationChallenge, privateBrowsingEnabled)); 1790 1803 gboolean returnValue; 1791 g_signal_emit(webView, signals[AUTHENTICATE], 0, request.get(), &returnValue);1804 g_signal_emit(webView, signals[AUTHENTICATE], 0, webView->priv->authenticationRequest.get(), &returnValue); 1792 1805 } 1793 1806 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp
r155125 r155347 299 299 } 300 300 301 void webkitWebViewBaseCancelAuthenticationDialog(WebKitWebViewBase* webViewBase)302 {303 WebKitWebViewBasePrivate* priv = webViewBase->priv;304 if (priv->authenticationDialog)305 gtk_widget_destroy(priv->authenticationDialog);306 }307 308 301 void webkitWebViewBaseAddWebInspector(WebKitWebViewBase* webViewBase, GtkWidget* inspector) 309 302 { -
trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp
r154818 r155347 1249 1249 1250 1250 static int authenticationRetries; 1251 static bool authenticationCancelledReceived; 1251 1252 1252 1253 void loadURI(const char* uri) … … 1254 1255 // Reset the retry count of the fake server when a page is loaded. 1255 1256 authenticationRetries = 0; 1257 authenticationCancelledReceived = false; 1256 1258 LoadTrackingTest::loadURI(uri); 1257 1259 } … … 1259 1261 static gboolean runAuthenticationCallback(WebKitWebView*, WebKitAuthenticationRequest* request, AuthenticationTest* test) 1260 1262 { 1263 g_signal_connect(request, "cancelled", G_CALLBACK(authenticationCancelledCallback), test); 1261 1264 test->runAuthentication(request); 1262 1265 return TRUE; 1266 } 1267 1268 static void authenticationCancelledCallback(WebKitAuthenticationRequest*, AuthenticationTest*) 1269 { 1270 authenticationCancelledReceived = true; 1263 1271 } 1264 1272 … … 1281 1289 1282 1290 int AuthenticationTest::authenticationRetries = 0; 1291 bool AuthenticationTest::authenticationCancelledReceived = false; 1283 1292 1284 1293 static const char authTestUsername[] = "username"; … … 1317 1326 // Server doesn't ask for new credentials. 1318 1327 test->waitUntilLoadFinished(); 1328 1329 g_assert_cmpint(test->m_loadEvents.size(), ==, 3); 1330 g_assert_cmpint(test->m_loadEvents[0], ==, LoadTrackingTest::ProvisionalLoadStarted); 1331 g_assert_cmpint(test->m_loadEvents[1], ==, LoadTrackingTest::ProvisionalLoadFailed); 1332 g_assert_cmpint(test->m_loadEvents[2], ==, LoadTrackingTest::LoadFinished); 1333 1334 g_assert_error(test->m_error.get(), WEBKIT_NETWORK_ERROR, WEBKIT_NETWORK_ERROR_CANCELLED); 1335 } 1336 1337 static void testWebViewAuthenticationLoadCancelled(AuthenticationTest* test, gconstpointer) 1338 { 1339 test->loadURI(kServer->getURIForPath("/auth-test.html").data()); 1340 test->waitForAuthenticationRequest(); 1341 webkit_web_view_stop_loading(test->m_webView); 1342 // Expect empty page. 1343 test->waitUntilLoadFinished(); 1344 g_assert(test->authenticationCancelledReceived); 1319 1345 1320 1346 g_assert_cmpint(test->m_loadEvents.size(), ==, 3); … … 1475 1501 AuthenticationTest::add("WebKitWebView", "authentication-request", testWebViewAuthenticationRequest); 1476 1502 AuthenticationTest::add("WebKitWebView", "authentication-cancel", testWebViewAuthenticationCancel); 1503 AuthenticationTest::add("WebKitWebView", "authentication-load-cancelled", testWebViewAuthenticationLoadCancelled); 1477 1504 AuthenticationTest::add("WebKitWebView", "authentication-failure", testWebViewAuthenticationFailure); 1478 1505 AuthenticationTest::add("WebKitWebView", "authentication-no-credential", testWebViewAuthenticationNoCredential);
Note:
See TracChangeset
for help on using the changeset viewer.