Changeset 119475 in webkit
- Timestamp:
- Jun 5, 2012 2:46:21 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r119423 r119475 1 2012-06-05 Mario Sanchez Prada <msanchez@igalia.com> 2 3 [GTK][WK2] Implement API for Geolocation permission requests in the GTK port 4 https://bugs.webkit.org/show_bug.cgi?id=83879 5 6 Reviewed by Carlos Garcia Campos. 7 8 Added a new kind of permission request for supporting the 9 Geolocation API in WebKit2GTK+. 10 11 New WebKitGeolocationPermissionRequest class, implementing the 12 WebKitPermissionRequest interface, to enabling client applications 13 to allow or deny geolocation permission requests. 14 15 * GNUmakefile.list.am: Added new files. 16 * UIProcess/API/gtk/WebKitGeolocationPermissionRequest.cpp: Added. 17 (_WebKitGeolocationPermissionRequestPrivate): 18 (webkitGeolocationPermissionRequestAllow): 19 (webkitGeolocationPermissionRequestDeny): 20 (webkit_permission_request_interface_init): 21 (webkit_geolocation_permission_request_init): 22 (webkitGeolocationPermissionRequestFinalize): 23 (webkit_geolocation_permission_request_class_init): 24 (webkitGeolocationPermissionRequestCreate): 25 * UIProcess/API/gtk/WebKitGeolocationPermissionRequest.h: Added. 26 (_WebKitGeolocationPermissionRequest): 27 (_WebKitGeolocationPermissionRequestClass): 28 * UIProcess/API/gtk/WebKitGeolocationPermissionRequestPrivate.h: Added. 29 30 Include WKGeolocationPermissionRequest.h in WebKitPrivate.h, so we 31 can use it from the new WebKitGeolocationPermissionRequest class. 32 33 * UIProcess/API/gtk/WebKitPrivate.h: Added new include. 34 35 Implement geolocation permission requests in the UI client. 36 37 * UIProcess/API/gtk/WebKitUIClient.cpp: 38 (decidePolicyForGeolocationPermissionRequest): Create a new 39 instance of the WebKitGeolocationPermissionRequest class and call 40 to webkitWebViewMakePermissionRequest(). 41 (attachUIClientToView): Provide an implementation function for 42 decidePolicyForGeolocationPermissionRequest. 43 * UIProcess/API/gtk/WebKitWebView.h: Add new element to 44 WebKitPermissionRequestType enumeration for geolocation requests. 45 * UIProcess/API/gtk/webkit2.h: Added header file for 46 WebKitGeolocationPermissionRequest 47 48 New unit tests to test allowing and denying permission requests. 49 50 * UIProcess/API/gtk/tests/TestWebKitWebView.cpp: 51 (testWebViewPermissionRequests): New test that loads a simple HTML 52 with JavaScript code requesting the current location. 53 (beforeAll): Added new test. 54 55 Updated documentation files. 56 57 * UIProcess/API/gtk/docs/webkit2gtk-docs.sgml: 58 * UIProcess/API/gtk/docs/webkit2gtk-sections.txt: 59 1 60 2012-06-04 Sadrul Habib Chowdhury <sadrul@chromium.org> 2 61 -
trunk/Source/WebKit2/GNUmakefile.list.am
r119404 r119475 96 96 $(WebKit2)/UIProcess/API/gtk/WebKitFileChooserRequest.h \ 97 97 $(WebKit2)/UIProcess/API/gtk/WebKitFindController.h \ 98 $(WebKit2)/UIProcess/API/gtk/WebKitGeolocationPermissionRequest.h \ 98 99 $(WebKit2)/UIProcess/API/gtk/WebKitHitTestResult.h \ 99 100 $(WebKit2)/UIProcess/API/gtk/WebKitJavascriptResult.h \ … … 514 515 Source/WebKit2/UIProcess/API/C/WKGeolocationManager.cpp \ 515 516 Source/WebKit2/UIProcess/API/C/WKGeolocationManager.h \ 517 Source/WebKit2/UIProcess/API/C/WKGeolocationPermissionRequest.cpp \ 516 518 Source/WebKit2/UIProcess/API/C/WKGeolocationPermissionRequest.h \ 517 519 Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.cpp \ … … 585 587 Source/WebKit2/UIProcess/API/gtk/WebKitFullscreenClient.cpp \ 586 588 Source/WebKit2/UIProcess/API/gtk/WebKitFullscreenClient.h \ 589 Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationPermissionRequest.cpp \ 590 Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationPermissionRequest.h \ 591 Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationPermissionRequestPrivate.h \ 587 592 Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationProvider.cpp \ 588 593 Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationProvider.h \ -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h
r119404 r119475 32 32 #include <WebKit2/WKFullScreenClientGtk.h> 33 33 #include <WebKit2/WKGeolocationManager.h> 34 #include <WebKit2/WKGeolocationPermissionRequest.h> 34 35 #include <WebKit2/WKGeolocationPosition.h> 35 36 #include <WebKit2/WKInspector.h> -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp
r118795 r119475 22 22 23 23 #include "WebKitFileChooserRequestPrivate.h" 24 #include "WebKitGeolocationPermissionRequestPrivate.h" 24 25 #include "WebKitPrivate.h" 25 26 #include "WebKitWebViewBasePrivate.h" … … 143 144 GRefPtr<WebKitFileChooserRequest> request = adoptGRef(webkitFileChooserRequestCreate(parameters, listener)); 144 145 webkitWebViewRunFileChooserRequest(WEBKIT_WEB_VIEW(clientInfo), request.get()); 146 } 147 148 static void decidePolicyForGeolocationPermissionRequest(WKPageRef, WKFrameRef, WKSecurityOriginRef, WKGeolocationPermissionRequestRef request, const void* clientInfo) 149 { 150 GRefPtr<WebKitGeolocationPermissionRequest> geolocationPermissionRequest = adoptGRef(webkitGeolocationPermissionRequestCreate(request)); 151 webkitWebViewMakePermissionRequest(WEBKIT_WEB_VIEW(clientInfo), WEBKIT_PERMISSION_REQUEST(geolocationPermissionRequest.get())); 145 152 } 146 153 … … 179 186 0, // exceededDatabaseQuota 180 187 runOpenPanel, 181 0, // decidePolicyForGeolocationPermissionRequest188 decidePolicyForGeolocationPermissionRequest, 182 189 0, // headerHeight 183 190 0, // footerHeight -
trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml
r118522 r119475 23 23 <xi:include href="xml/WebKitDownload.xml"/> 24 24 <xi:include href="xml/WebKitPermissionRequest.xml"/> 25 <xi:include href="xml/WebKitGeolocationPermissionRequest.xml"/> 25 26 <xi:include href="xml/WebKitPolicyDecision.xml"/> 26 27 <xi:include href="xml/WebKitNavigationPolicyDecision.xml"/> -
trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
r119108 r119475 389 389 390 390 <SECTION> 391 <FILE>WebKitGeolocationPermissionRequest</FILE> 392 WebKitGeolocationPermissionRequest 393 394 <SUBSECTION Standard> 395 WebKitGeolocationPermissionRequestClass 396 WEBKIT_TYPE_GEOLOCATION_PERMISSION_REQUEST 397 WEBKIT_GEOLOCATION_PERMISSION_REQUEST 398 WEBKIT_IS_GEOLOCATION_PERMISSION_REQUEST 399 WEBKIT_GEOLOCATION_PERMISSION_REQUEST_CLASS 400 WEBKIT_IS_GEOLOCATION_PERMISSION_REQUEST_CLASS 401 WEBKIT_GEOLOCATION_PERMISSION_REQUEST_GET_CLASS 402 403 <SUBSECTION Private> 404 WebKitGeolocationPermissionRequestPrivate 405 webkit_geolocation_permission_request_get_type 406 </SECTION> 407 408 <SECTION> 391 409 <FILE>WebKitPolicyDecision</FILE> 392 410 WebKitPolicyDecision -
trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp
r118904 r119475 20 20 #include "config.h" 21 21 #include "WebViewTest.h" 22 #include <JavaScriptCore/JSStringRef.h> 23 #include <JavaScriptCore/JSValueRef.h> 22 24 #include <wtf/HashSet.h> 23 25 #include <wtf/gobject/GRefPtr.h> … … 279 281 } 280 282 283 static gboolean permissionRequested(WebKitWebView*, WebKitPermissionRequest* request, UIClientTest* test) 284 { 285 g_assert(WEBKIT_IS_PERMISSION_REQUEST(request)); 286 test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(request)); 287 288 if (test->m_allowPermissionRequests) 289 webkit_permission_request_allow(request); 290 else 291 webkit_permission_request_deny(request); 292 293 return TRUE; 294 } 295 281 296 UIClientTest() 282 297 : m_scriptDialogType(WEBKIT_SCRIPT_DIALOG_ALERT) 283 298 , m_scriptDialogConfirmed(true) 299 , m_allowPermissionRequests(false) 284 300 , m_mouseTargetModifiers(0) 285 301 { … … 288 304 g_signal_connect(m_webView, "script-dialog", G_CALLBACK(scriptDialog), this); 289 305 g_signal_connect(m_webView, "mouse-target-changed", G_CALLBACK(mouseTargetChanged), this); 306 g_signal_connect(m_webView, "permission-request", G_CALLBACK(permissionRequested), this); 290 307 } 291 308 … … 315 332 WebKitScriptDialogType m_scriptDialogType; 316 333 bool m_scriptDialogConfirmed; 334 bool m_allowPermissionRequests; 317 335 WindowProperties m_windowProperties; 318 336 HashSet<WTF::String> m_windowPropertiesChanged; … … 450 468 } 451 469 470 static void testWebViewPermissionRequests(UIClientTest* test, gconstpointer) 471 { 472 test->showInWindowAndWaitUntilMapped(); 473 static const char* geolocationRequestHTML = 474 "<html>" 475 " <script>" 476 " function runTest()" 477 " {" 478 " navigator.geolocation.getCurrentPosition(function(p) { document.title = \"OK\" }," 479 " function(e) { document.title = e.code });" 480 " }" 481 " </script>" 482 " <body onload='runTest();'></body>" 483 "</html>"; 484 485 // Test denying a permission request. 486 test->m_allowPermissionRequests = false; 487 test->loadHtml(geolocationRequestHTML, 0); 488 test->waitUntilTitleChanged(); 489 490 // According to the Geolocation API specification, '1' is the 491 // error code returned for the PERMISSION_DENIED error. 492 // http://dev.w3.org/geo/api/spec-source.html#position_error_interface 493 const gchar* result = webkit_web_view_get_title(test->m_webView); 494 g_assert_cmpstr(result, ==, "1"); 495 496 // Test allowing a permission request. 497 test->m_allowPermissionRequests = true; 498 test->loadHtml(geolocationRequestHTML, 0); 499 test->waitUntilTitleChanged(); 500 501 // Check that we did not get the PERMISSION_DENIED error now. 502 result = webkit_web_view_get_title(test->m_webView); 503 g_assert_cmpstr(result, !=, "1"); 504 } 505 452 506 static void testWebViewZoomLevel(WebViewTest* test, gconstpointer) 453 507 { … … 731 785 UIClientTest::add("WebKitWebView", "window-properties", testWebViewWindowProperties); 732 786 UIClientTest::add("WebKitWebView", "mouse-target", testWebViewMouseTarget); 787 UIClientTest::add("WebKitWebView", "permission-requests", testWebViewPermissionRequests); 733 788 WebViewTest::add("WebKitWebView", "zoom-level", testWebViewZoomLevel); 734 789 WebViewTest::add("WebKitWebView", "run-javascript", testWebViewRunJavaScript); -
trunk/Source/WebKit2/UIProcess/API/gtk/webkit2.h
r118794 r119475 34 34 #include <webkit2/WebKitFileChooserRequest.h> 35 35 #include <webkit2/WebKitFindController.h> 36 #include <webkit2/WebKitGeolocationPermissionRequest.h> 36 37 #include <webkit2/WebKitHitTestResult.h> 37 38 #include <webkit2/WebKitJavascriptResult.h> -
trunk/Tools/ChangeLog
r119463 r119475 1 2012-06-05 Mario Sanchez Prada <msanchez@igalia.com> 2 3 [GTK][WK2] Implement API for Geolocation permission requests in the GTK port 4 https://bugs.webkit.org/show_bug.cgi?id=83879 5 6 Reviewed by Carlos Garcia Campos. 7 8 Make minibrowser connect to the new 'permission requests' signal 9 to allow users handle the Geolocation permission requests. 10 11 * MiniBrowser/gtk/BrowserWindow.c: 12 (geolocationRequestDialogCallback): Callback for the dialog asking 13 the user for allowing or not geolocation permission requests. 14 (webViewDecidePermissionRequest): Launch a dialog to ask the user 15 whether to allow or deny geolocation permission requests. 16 (browserWindowConstructed): Connect to 'permission-request' signal. 17 1 18 2012-06-04 Chase Phillips <cmp@google.com> 2 19 -
trunk/Tools/MiniBrowser/gtk/BrowserWindow.c
r117735 r119475 214 214 } 215 215 216 static void geolocationRequestDialogCallback(GtkDialog *dialog, gint response, WebKitPermissionRequest *request) 217 { 218 switch (response) { 219 case GTK_RESPONSE_YES: 220 webkit_permission_request_allow(request); 221 break; 222 default: 223 webkit_permission_request_deny(request); 224 break; 225 } 226 227 gtk_widget_destroy(GTK_WIDGET(dialog)); 228 g_object_unref(request); 229 } 230 216 231 static void webViewClose(WebKitWebView *webView, BrowserWindow *window) 217 232 { … … 278 293 } 279 294 295 static gboolean webViewDecidePermissionRequest(WebKitWebView *webView, WebKitPermissionRequest *request, BrowserWindow *window) 296 { 297 if (!WEBKIT_IS_GEOLOCATION_PERMISSION_REQUEST(request)) 298 return FALSE; 299 300 GtkWidget *dialog = gtk_message_dialog_new(GTK_WINDOW(window), 301 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, 302 GTK_MESSAGE_QUESTION, 303 GTK_BUTTONS_YES_NO, 304 "Geolocation request"); 305 306 gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), "Allow geolocation request?"); 307 g_signal_connect(dialog, "response", G_CALLBACK(geolocationRequestDialogCallback), g_object_ref(request)); 308 gtk_widget_show(dialog); 309 310 return TRUE; 311 } 312 280 313 static void webViewMouseTargetChanged(WebKitWebView *webView, WebKitHitTestResult *hitTestResult, guint mouseModifiers, BrowserWindow *window) 281 314 { … … 435 468 g_signal_connect(window->webView, "load-failed", G_CALLBACK(webViewLoadFailed), window); 436 469 g_signal_connect(window->webView, "decide-policy", G_CALLBACK(webViewDecidePolicy), window); 470 g_signal_connect(window->webView, "permission-request", G_CALLBACK(webViewDecidePermissionRequest), window); 437 471 g_signal_connect(window->webView, "mouse-target-changed", G_CALLBACK(webViewMouseTargetChanged), window); 438 472 g_signal_connect(window->webView, "notify::zoom-level", G_CALLBACK(webViewZoomLevelChanged), window);
Note: See TracChangeset
for help on using the changeset viewer.