Changeset 177073 in webkit
- Timestamp:
- Dec 10, 2014, 9:36:40 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 9 added
- 18 edited
-
ChangeLog (modified) (1 diff)
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/platform/gtk/TestExpectations (modified) (1 diff)
-
Source/WebKit2/ChangeLog (modified) (1 diff)
-
Source/WebKit2/PlatformGTK.cmake (modified) (4 diffs)
-
Source/WebKit2/UIProcess/API/gtk/WebKitForwardDeclarations.h (modified) (1 diff)
-
Source/WebKit2/UIProcess/API/gtk/WebKitNotification.cpp (added)
-
Source/WebKit2/UIProcess/API/gtk/WebKitNotification.h (added)
-
Source/WebKit2/UIProcess/API/gtk/WebKitNotificationPermissionRequest.cpp (added)
-
Source/WebKit2/UIProcess/API/gtk/WebKitNotificationPermissionRequest.h (added)
-
Source/WebKit2/UIProcess/API/gtk/WebKitNotificationPermissionRequestPrivate.h (added)
-
Source/WebKit2/UIProcess/API/gtk/WebKitNotificationPrivate.h (added)
-
Source/WebKit2/UIProcess/API/gtk/WebKitNotificationProvider.cpp (added)
-
Source/WebKit2/UIProcess/API/gtk/WebKitNotificationProvider.h (added)
-
Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp (modified) (2 diffs)
-
Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp (modified) (4 diffs)
-
Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp (modified) (10 diffs)
-
Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h (modified) (1 diff)
-
Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h (modified) (1 diff)
-
Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt (modified) (1 diff)
-
Source/WebKit2/UIProcess/API/gtk/webkit2.h (modified) (1 diff)
-
Source/cmake/FindLibNotify.cmake (added)
-
Source/cmake/OptionsGTK.cmake (modified) (3 diffs)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/MiniBrowser/gtk/BrowserWindow.c (modified) (1 diff)
-
Tools/Scripts/webkitperl/FeatureList.pm (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r177049 r177073 1 2014-12-09 Gustavo Noronha Silva <gustavo.noronha@collabora.com> 2 3 [GTK][WK2] Add HTML5 Notifications support 4 https://bugs.webkit.org/show_bug.cgi?id=61140 5 6 Reviewed by Carlos Garcia Campos. 7 8 * Source/cmake/FindLibNotify.cmake: Added. 9 * Source/cmake/OptionsGTK.cmake: add option to enable notifications, look for 10 libnotify and use it for a default implementation when found. 11 1 12 2014-12-09 Bem Jones-Bey <bjonesbe@adobe.com> 2 13 -
trunk/LayoutTests/ChangeLog
r177054 r177073 1 2014-12-09 Gustavo Noronha Silva <gustavo.noronha@collabora.com> 2 3 [GTK][WK2] Add HTML5 Notifications support 4 https://bugs.webkit.org/show_bug.cgi?id=61140 5 6 Reviewed by Carlos Garcia Campos. 7 8 * platform/gtk/TestExpectations: unskip the HTTP tests for new-style notifications. 9 1 10 2014-12-09 Alexey Proskuryakov <ap@apple.com> 2 11 -
trunk/LayoutTests/platform/gtk/TestExpectations
r176922 r177073 147 147 webkit.org/b/98927 fast/dom/DeviceOrientation [ Skip ] 148 148 149 # Desktop notifications are not yet supported. 150 webkit.org/b/61140 fast/notifications [ Skip ] 151 webkit.org/b/61140 http/tests/notifications [ Skip ] 149 # https://bugs.webkit.org/show_bug.cgi?id=81697 Skip file:// based notifications tests 150 fast/notifications 151 152 # we do not enable legacy notifications 153 http/tests/notifications/legacy/window-show-on-click.html 154 http/tests/notifications/legacy/request.html 155 http/tests/notifications/legacy/request-no-callback.html 156 http/tests/notifications/legacy/events.html 157 http/tests/notifications/legacy/show.html 158 http/tests/notifications/legacy/double-show.html 152 159 153 160 # StorageTracker is not enabled. -
trunk/Source/WebKit2/ChangeLog
r177057 r177073 1 2014-12-09 Claudio Saavedra <csaavedra@igalia.com> and Gustavo Noronha Silva <gustavo.noronha@collabora.com> 2 3 [GTK][WK2] Add HTML5 Notifications support 4 https://bugs.webkit.org/show_bug.cgi?id=61140 5 6 Reviewed by Carlos Garcia Campos. 7 8 * PlatformGTK.cmake: add new files to the build. 9 * UIProcess/API/gtk/WebKitForwardDeclarations.h: 10 * UIProcess/API/gtk/WebKitNotification.cpp: Added. New GObject used to expose information about 11 the notification to the API. 12 (webkitNotificationGetProperty): 13 (webkit_notification_class_init): 14 (webkitNotificationCreate): 15 (webkit_notification_get_id): 16 (webkit_notification_get_title): 17 (webkit_notification_get_body): 18 * UIProcess/API/gtk/WebKitNotification.h: Added. 19 * UIProcess/API/gtk/WebKitNotificationPermissionRequest.cpp: Added. Permission request object 20 for notifications. 21 (webkitNotificationPermissionRequestAllow): 22 (webkitNotificationPermissionRequestDeny): 23 (webkit_permission_request_interface_init): 24 (webkitNotificationPermissionRequestDispose): 25 (webkit_notification_permission_request_class_init): 26 (webkitNotificationPermissionRequestCreate): 27 * UIProcess/API/gtk/WebKitNotificationPermissionRequest.h: Added. 28 * UIProcess/API/gtk/WebKitNotificationPermissionRequestPrivate.h: Added. 29 * UIProcess/API/gtk/WebKitNotificationPrivate.h: Added. 30 * UIProcess/API/gtk/WebKitNotificationProvider.cpp: Added. Notification provider that emits signals. 31 The C API allows overriding the notification providers and managers for customizing the handling of 32 notifications. We decided to go for a single manager and a single provider which provide more idiomatic 33 GObject API - signals. 34 (toNotificationProvider): 35 (showCallback): 36 (cancelCallback): 37 (WebKitNotificationProvider::~WebKitNotificationProvider): 38 (WebKitNotificationProvider::create): 39 (WebKitNotificationProvider::WebKitNotificationProvider): 40 (WebKitNotificationProvider::show): 41 (WebKitNotificationProvider::cancel): 42 * UIProcess/API/gtk/WebKitNotificationProvider.h: Added. 43 * UIProcess/API/gtk/WebKitUIClient.cpp: implemented decidePolicyForNotificationPermissionRequest. 44 * UIProcess/API/gtk/WebKitWebContext.cpp: 45 (webkitWebContextConstructed): initialize the notification provider. 46 * UIProcess/API/gtk/WebKitWebView.cpp: 47 (webkitWebViewShowNotification): default implementation for showing the notification, currently 48 using GNotification, about to be ported to libnotify. 49 (webkit_web_view_class_init): set the default implementation for the show-notification signal. 50 (webkitWebViewEmitCloseNotification): emit the close-notification signal. 51 (webkitWebViewEmitShowNotification): emit the show-notification signal. 52 * UIProcess/API/gtk/WebKitWebView.h: 53 * UIProcess/API/gtk/WebKitWebViewPrivate.h: 54 * UIProcess/API/gtk/docs/webkit2gtk-sections.txt: list new objects and methods. 55 * UIProcess/API/gtk/webkit2.h: include new headers. 56 1 57 2014-12-10 Grzegorz Czajkowski <g.czajkowski@samsung.com> 2 58 -
trunk/Source/WebKit2/PlatformGTK.cmake
r177016 r177073 159 159 UIProcess/API/gtk/WebKitNavigationPolicyDecision.h 160 160 UIProcess/API/gtk/WebKitNavigationPolicyDecisionPrivate.h 161 UIProcess/API/gtk/WebKitNotificationPermissionRequest.cpp 162 UIProcess/API/gtk/WebKitNotificationPermissionRequest.h 163 UIProcess/API/gtk/WebKitNotificationPermissionRequestPrivate.h 164 UIProcess/API/gtk/WebKitNotificationProvider.cpp 165 UIProcess/API/gtk/WebKitNotificationProvider.h 166 UIProcess/API/gtk/WebKitNotification.cpp 167 UIProcess/API/gtk/WebKitNotification.h 168 UIProcess/API/gtk/WebKitNotificationPrivate.h 161 169 UIProcess/API/gtk/WebKitPermissionRequest.cpp 162 170 UIProcess/API/gtk/WebKitPermissionRequest.h … … 352 360 ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitNavigationAction.h 353 361 ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitNavigationPolicyDecision.h 362 ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitNotificationPermissionRequest.h 363 ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitNotification.h 354 364 ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitPermissionRequest.h 355 365 ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitPlugin.h … … 456 466 ) 457 467 468 if (LIBNOTIFY_FOUND) 469 list(APPEND WebKit2_INCLUDE_DIRECTORIES 470 ${LIBNOTIFY_INCLUDE_DIRS} 471 ) 472 endif () 473 458 474 set(WebKit2CommonIncludeDirectories ${WebKit2_INCLUDE_DIRECTORIES}) 459 475 … … 490 506 ${GTK_UNIX_PRINT_LIBRARIES} 491 507 ) 508 509 if (LIBNOTIFY_FOUND) 510 list(APPEND WebKit2_LIBRARIES 511 ${LIBNOTIFY_LIBRARIES} 512 ) 513 endif () 514 492 515 ADD_WHOLE_ARCHIVE_TO_LIBRARIES(WebKit2_LIBRARIES) 493 516 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitForwardDeclarations.h
r175694 r177073 36 36 typedef struct _WebKitContextMenu WebKitContextMenu; 37 37 typedef struct _WebKitContextMenuItem WebKitContextMenuItem; 38 typedef struct _WebKitNotification WebKitNotification; 38 39 39 40 #endif // WebKitForward_h -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp
r176952 r177073 25 25 #include "WebKitGeolocationPermissionRequestPrivate.h" 26 26 #include "WebKitNavigationActionPrivate.h" 27 #include "WebKitNotificationPermissionRequestPrivate.h" 27 28 #include "WebKitPrivate.h" 28 29 #include "WebKitURIRequestPrivate.h" … … 167 168 } 168 169 170 virtual bool decidePolicyForNotificationPermissionRequest(WebPageProxy*, WebSecurityOrigin*, NotificationPermissionRequest* permissionRequest) override 171 { 172 GRefPtr<WebKitNotificationPermissionRequest> notificationPermissionRequest = adoptGRef(webkitNotificationPermissionRequestCreate(permissionRequest)); 173 webkitWebViewMakePermissionRequest(m_webView, WEBKIT_PERMISSION_REQUEST(notificationPermissionRequest.get())); 174 return true; 175 } 176 169 177 virtual void printFrame(WebPageProxy*, WebFrameProxy* frame) override 170 178 { -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp
r176512 r177073 34 34 #include "WebKitGeolocationProvider.h" 35 35 #include "WebKitInjectedBundleClient.h" 36 #include "WebKitNotificationProvider.h" 36 37 #include "WebKitPluginPrivate.h" 37 38 #include "WebKitPrivate.h" … … 45 46 #include "WebKitWebViewBasePrivate.h" 46 47 #include "WebKitWebViewPrivate.h" 48 #include "WebNotificationManagerProxy.h" 47 49 #include "WebResourceCacheManagerProxy.h" 48 50 #include <WebCore/FileSystem.h> … … 167 169 RefPtr<WebKitBatteryProvider> batteryProvider; 168 170 #endif 171 #if ENABLE(NOTIFICATIONS) 172 RefPtr<WebKitNotificationProvider> notificationProvider; 173 #endif 169 174 #if ENABLE(SPELLCHECK) 170 175 std::unique_ptr<WebKitTextChecker> textChecker; … … 278 283 #if ENABLE(BATTERY_STATUS) 279 284 priv->batteryProvider = WebKitBatteryProvider::create(priv->context->supplement<WebBatteryManagerProxy>()); 285 #endif 286 #if ENABLE(NOTIFICATIONS) 287 priv->notificationProvider = WebKitNotificationProvider::create(priv->context->supplement<WebNotificationManagerProxy>()); 280 288 #endif 281 289 #if ENABLE(SPELLCHECK) -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
r176513 r177073 2 2 * Copyright (C) 2011 Igalia S.L. 3 3 * Portions Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved. 4 * Copyright (C) 2014 Collabora Ltd. 4 5 * 5 6 * This library is free software; you can redistribute it and/or … … 43 44 #include "WebKitLoaderClient.h" 44 45 #include "WebKitMarshal.h" 46 #include "WebKitNotificationPrivate.h" 45 47 #include "WebKitPolicyClient.h" 46 48 #include "WebKitPrintOperationPrivate.h" … … 70 72 #include <wtf/text/CString.h> 71 73 74 #if USE(LIBNOTIFY) 75 #include <libnotify/notify.h> 76 #endif 77 72 78 using namespace WebKit; 73 79 using namespace WebCore; … … 124 130 125 131 AUTHENTICATE, 132 133 SHOW_NOTIFICATION, 134 CLOSE_NOTIFICATION, 126 135 127 136 LAST_SIGNAL … … 145 154 typedef HashMap<uint64_t, GRefPtr<WebKitWebResource> > LoadingResourcesMap; 146 155 typedef HashMap<uint64_t, GRefPtr<GTask> > SnapshotResultsMap; 156 #if USE(LIBNOTIFY) 157 typedef HashMap<uint64_t, GRefPtr<NotifyNotification>> NotifyNotificationsMap; 158 #endif 147 159 class PageLoadStateObserver; 148 160 … … 195 207 SnapshotResultsMap snapshotResultsMap; 196 208 GRefPtr<WebKitAuthenticationRequest> authenticationRequest; 209 210 #if USE(LIBNOTIFY) 211 NotifyNotificationsMap notifyNotificationsMap; 212 #endif 197 213 }; 198 214 … … 561 577 GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(downloadProxy); 562 578 webkitDownloadSetWebView(download.get(), WEBKIT_WEB_VIEW(webViewBase)); 579 } 580 581 static gboolean webkitWebViewShowNotification(WebKitWebView* webView, WebKitNotification* webNotification) 582 { 583 #if USE(LIBNOTIFY) 584 if (!notify_is_initted()) 585 notify_init(g_get_prgname()); 586 587 GRefPtr<NotifyNotification> notification = webView->priv->notifyNotificationsMap.get(webkit_notification_get_id(webNotification)); 588 if (!notification) { 589 notification = adoptGRef(notify_notification_new(webkit_notification_get_title(webNotification), 590 webkit_notification_get_body(webNotification), nullptr)); 591 592 webView->priv->notifyNotificationsMap.set(webkit_notification_get_id(webNotification), notification); 593 } else 594 notify_notification_update(notification.get(), webkit_notification_get_title(webNotification), 595 webkit_notification_get_body(webNotification), nullptr); 596 597 notify_notification_show(notification.get(), nullptr); 598 return TRUE; 599 #else 600 UNUSED_PARAM(webNotification); 601 return FALSE; 602 #endif 603 } 604 605 static gboolean webkitWebViewCloseNotification(WebKitWebView* webView, WebKitNotification* webNotification) 606 { 607 #if USE(LIBNOTIFY) 608 if (GRefPtr<NotifyNotification> notification = webView->priv->notifyNotificationsMap.get(webkit_notification_get_id(webNotification))) { 609 notify_notification_close(notification.get(), nullptr); 610 webView->priv->notifyNotificationsMap.remove(webkit_notification_get_id(webNotification)); 611 } 612 return TRUE; 613 #else 614 UNUSED_PARAM(webNotification); 615 return FALSE; 616 #endif 563 617 } 564 618 … … 714 768 webViewClass->run_file_chooser = webkitWebViewRunFileChooser; 715 769 webViewClass->authenticate = webkitWebViewAuthenticate; 770 webViewClass->show_notification = webkitWebViewShowNotification; 771 webViewClass->close_notification = webkitWebViewCloseNotification; 716 772 717 773 /** … … 1575 1631 G_TYPE_BOOLEAN, 1, /* number of parameters */ 1576 1632 WEBKIT_TYPE_AUTHENTICATION_REQUEST); 1633 1634 /** 1635 * WebKitWebView::show-notification: 1636 * @web_view: the #WebKitWebView 1637 * @notification: a #WebKitNofication 1638 * 1639 * This signal is emitted when a notification should be presented to the 1640 * user. The @notification is kept alive until either: 1) the web page cancels it 1641 * or 2) a navigation happens. 1642 * 1643 * The default handler will emit a notification using libnotify, if built with 1644 * support for it. 1645 * 1646 * Returns: %TRUE to stop other handlers from being invoked. %FALSE otherwise. 1647 * 1648 * Since: 2.8 1649 */ 1650 signals[SHOW_NOTIFICATION] = 1651 g_signal_new("show-notification", 1652 G_TYPE_FROM_CLASS(gObjectClass), 1653 G_SIGNAL_RUN_LAST, 1654 G_STRUCT_OFFSET(WebKitWebViewClass, show_notification), 1655 g_signal_accumulator_true_handled, nullptr /* accumulator data */, 1656 webkit_marshal_BOOLEAN__OBJECT, 1657 G_TYPE_BOOLEAN, 1, 1658 WEBKIT_TYPE_NOTIFICATION); 1659 1660 /** 1661 * WebKitNotification::close-notification: 1662 * @web_view: the #WebKitWebView 1663 * @notification: a #WebKitNofication 1664 * 1665 * This signal is emitted when a notification should be withdrawn. 1666 * 1667 * The default handler will close the notification using libnotify, if built with 1668 * support for it. 1669 * 1670 * Returns: %TRUE to stop other handlers from being invoked. %FALSE otherwise. 1671 * 1672 * Since: 2.8 1673 */ 1674 signals[CLOSE_NOTIFICATION] = 1675 g_signal_new("close-notification", 1676 G_TYPE_FROM_CLASS(gObjectClass), 1677 G_SIGNAL_RUN_LAST, 1678 G_STRUCT_OFFSET(WebKitWebViewClass, close_notification), 1679 g_signal_accumulator_true_handled, nullptr /* accumulator data */, 1680 webkit_marshal_BOOLEAN__OBJECT, 1681 G_TYPE_BOOLEAN, 1, 1682 WEBKIT_TYPE_NOTIFICATION); 1577 1683 } 1578 1684 … … 1956 2062 { 1957 2063 g_signal_emit(webView, signals[INSECURE_CONTENT_DETECTED], 0, type); 2064 } 2065 2066 bool webkitWebViewEmitShowNotification(WebKitWebView* webView, WebKitNotification* webNotification) 2067 { 2068 gboolean handled; 2069 g_signal_emit(webView, signals[SHOW_NOTIFICATION], 0, webNotification, &handled); 2070 return handled; 2071 } 2072 2073 void webkitWebViewEmitCloseNotification(WebKitWebView* webView, WebKitNotification* webNotification) 2074 { 2075 gboolean handled; 2076 g_signal_emit(webView, signals[CLOSE_NOTIFICATION], 0, webNotification, &handled); 1958 2077 } 1959 2078 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h
r173691 r177073 239 239 GTlsCertificate *certificate, 240 240 GTlsCertificateFlags errors); 241 gboolean (* show_notification) (WebKitWebView *web_view, 242 WebKitNotification *notification); 243 gboolean (* close_notification) (WebKitWebView *web_view, 244 WebKitNotification *notification); 245 241 246 void (*_webkit_reserved0) (void); 242 247 void (*_webkit_reserved1) (void); 243 248 void (*_webkit_reserved2) (void); 244 249 void (*_webkit_reserved3) (void); 245 void (*_webkit_reserved4) (void);246 void (*_webkit_reserved5) (void);247 250 }; 248 251 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h
r175694 r177073 58 58 void webkitWebViewHandleAuthenticationChallenge(WebKitWebView*, WebKit::AuthenticationChallengeProxy*); 59 59 void webkitWebViewInsecureContentDetected(WebKitWebView*, WebKitInsecureContentEvent); 60 bool webkitWebViewEmitShowNotification(WebKitWebView*, WebKitNotification*); 61 void webkitWebViewEmitCloseNotification(WebKitWebView*, WebKitNotification*); 60 62 void webkitWebViewWebProcessCrashed(WebKitWebView*); 61 63 -
trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
r176952 r177073 617 617 618 618 <SECTION> 619 <FILE>WebKitNotification</FILE> 620 WebKitNotification 621 webkit_notification_get_id 622 webkit_notification_get_title 623 webkit_notification_get_body 624 625 <SUBSECTION Standard> 626 WebKitNotificationClass 627 WEBKIT_TYPE_NOTIFICATION 628 WEBKIT_IS_NOTIFICATION 629 WEBKIT_NOTIFICATION 630 WEBKIT_NOTIFICATION_CLASS 631 WEBKIT_IS_NOTIFICATION_CLASS 632 WEBKIT_NOTIFICATION_GET_CLASS 633 634 <SUBSECTION Private> 635 WebKitNotificationPrivate 636 webkit_notification_get_type 637 </SECTION> 638 639 <SECTION> 640 <FILE>WebKitNotificationPermissionRequest</FILE> 641 WebKitNotificationPermissionRequest 642 643 <SUBSECTION Standard> 644 WebKitNotificationPermissionRequestClass 645 WEBKIT_TYPE_NOTIFICATION_PERMISSION_REQUEST 646 WEBKIT_NOTIFICATION_PERMISSION_REQUEST 647 WEBKIT_IS_NOTIFICATION_PERMISSION_REQUEST 648 WEBKIT_NOTIFICATION_PERMISSION_REQUEST_CLASS 649 WEBKIT_IS_NOTIFICATION_PERMISSION_REQUEST_CLASS 650 WEBKIT_NOTIFICATION_PERMISSION_REQUEST_GET_CLASS 651 652 <SUBSECTION Private> 653 WebKitNotificationPermissionRequestPrivate 654 webkit_notification_permission_request_get_type 655 </SECTION> 656 657 <SECTION> 619 658 <FILE>WebKitPolicyDecision</FILE> 620 659 WebKitPolicyDecision -
trunk/Source/WebKit2/UIProcess/API/gtk/webkit2.h
r176952 r177073 51 51 #include <webkit2/WebKitNavigationAction.h> 52 52 #include <webkit2/WebKitNavigationPolicyDecision.h> 53 #include <webkit2/WebKitNotification.h> 54 #include <webkit2/WebKitNotificationPermissionRequest.h> 53 55 #include <webkit2/WebKitPermissionRequest.h> 54 56 #include <webkit2/WebKitPlugin.h> -
trunk/Source/cmake/OptionsGTK.cmake
r176928 r177073 51 51 find_package(GeoClue2 2.1.5) 52 52 find_package(GnuTLS 3.0.0) 53 find_package(LibNotify) 53 54 54 55 if (NOT GEOCLUE2_FOUND) … … 152 153 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NAVIGATOR_HWCONCURRENCY ON) 153 154 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NETSCAPE_PLUGIN_API ON) 155 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NOTIFICATIONS ON) 154 156 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_PICTURE_SIZES ON) 155 157 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_QUOTA OFF) … … 174 176 WEBKIT_OPTION_END() 175 177 178 if (LIBNOTIFY_FOUND) 179 add_definitions(-DWTF_USE_LIBNOTIFY=1) 180 else () 181 add_definitions(-DWTF_USE_LIBNOTIFY=0) 182 endif () 183 176 184 if (ENABLE_PLUGIN_PROCESS_GTK2) 177 185 find_package(GTK2 2.24.10 REQUIRED) -
trunk/Tools/ChangeLog
r177036 r177073 1 2014-12-09 Gustavo Noronha Silva <gustavo.noronha@collabora.com> 2 3 [GTK][WK2] Add HTML5 Notifications support 4 https://bugs.webkit.org/show_bug.cgi?id=61140 5 6 Reviewed by Carlos Garcia Campos. 7 8 * Scripts/webkitperl/FeatureList.pm: enable notifications for GTK+. 9 * TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp: 10 (testWebViewNotification): 11 (beforeAll): 12 * MiniBrowser/gtk/BrowserWindow.c: also handle notification permission requests. 13 (permissionRequestDialogCallback): 14 (webViewDecidePermissionRequest): 15 (geolocationRequestDialogCallback): Deleted. 16 1 17 2014-12-09 Benjamin Poulain <bpoulain@apple.com> 2 18 -
trunk/Tools/MiniBrowser/gtk/BrowserWindow.c
r176952 r177073 417 417 dialog_message_format = "%s"; 418 418 dialog_message = "Allow geolocation request?"; 419 } else if (WEBKIT_IS_NOTIFICATION_PERMISSION_REQUEST(request)) { 420 dialog_title = "Notification request"; 421 dialog_message_format = "%s"; 422 dialog_message = "Allow notifications request?"; 419 423 } else if (WEBKIT_IS_USER_MEDIA_PERMISSION_REQUEST(request)) { 420 424 dialog_message_format = "Allow access to %s device?"; -
trunk/Tools/Scripts/webkitperl/FeatureList.pm
r176712 r177073 328 328 329 329 { option => "notifications", desc => "Toggle Notifications support", 330 define => "ENABLE_NOTIFICATIONS", default => 0, value => \$notificationsSupport },330 define => "ENABLE_NOTIFICATIONS", default => isGtk(), value => \$notificationsSupport }, 331 331 332 332 { option => "orientation-events", desc => "Toggle Orientation Events support", -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp
r176513 r177073 1 1 /* 2 2 * Copyright (C) 2011 Igalia S.L. 3 * Copyright (C) 2014 Collabora Ltd. 3 4 * 4 5 * This library is free software; you can redistribute it and/or … … 19 20 20 21 #include "config.h" 22 #include "WebKitTestServer.h" 21 23 #include "WebViewTest.h" 22 24 #include <JavaScriptCore/JSStringRef.h> … … 24 26 #include <glib/gstdio.h> 25 27 #include <wtf/gobject/GRefPtr.h> 28 29 static WebKitTestServer* gServer; 26 30 27 31 static void testWebViewWebContext(WebViewTest* test, gconstpointer) … … 582 586 } 583 587 588 class NotificationWebViewTest: public WebViewTest { 589 public: 590 MAKE_GLIB_TEST_FIXTURE(NotificationWebViewTest); 591 592 enum NotificationEvent { 593 None, 594 Permission, 595 Shown, 596 Cancelled 597 }; 598 599 static gboolean permissionRequestCallback(WebKitWebView*, WebKitPermissionRequest *request, NotificationWebViewTest* test) 600 { 601 g_assert(WEBKIT_IS_NOTIFICATION_PERMISSION_REQUEST(request)); 602 test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(request)); 603 604 test->m_event = Permission; 605 606 webkit_permission_request_allow(request); 607 608 g_main_loop_quit(test->m_mainLoop); 609 610 return TRUE; 611 } 612 613 static gboolean showNotificationCallback(WebKitWebView*, WebKitNotification* notification, NotificationWebViewTest* test) 614 { 615 test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(notification)); 616 test->m_notification = notification; 617 test->m_event = Shown; 618 g_main_loop_quit(test->m_mainLoop); 619 return TRUE; 620 } 621 622 static gboolean closeNotificationCallback(WebKitWebView*, WebKitNotification*, NotificationWebViewTest* test) 623 { 624 test->m_notification = nullptr; 625 test->m_event = Cancelled; 626 g_main_loop_quit(test->m_mainLoop); 627 return TRUE; 628 } 629 630 NotificationWebViewTest() 631 : m_event(None) 632 { 633 g_signal_connect(m_webView, "permission-request", G_CALLBACK(permissionRequestCallback), this); 634 g_signal_connect(m_webView, "show-notification", G_CALLBACK(showNotificationCallback), this); 635 g_signal_connect(m_webView, "close-notification", G_CALLBACK(closeNotificationCallback), this); 636 637 } 638 639 ~NotificationWebViewTest() 640 { 641 g_signal_handlers_disconnect_matched(m_webView, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this); 642 } 643 644 void requestPermissionAndWaitUntilGiven() 645 { 646 m_event = None; 647 webkit_web_view_run_javascript(m_webView, "Notification.requestPermission();", nullptr, nullptr, nullptr); 648 g_main_loop_run(m_mainLoop); 649 } 650 651 void requestNotificationAndWaitUntilShown(const char* title, const char* body) 652 { 653 m_event = None; 654 655 GUniquePtr<char> jscode(g_strdup_printf("n = new Notification('%s', { body: '%s'});", title, body)); 656 webkit_web_view_run_javascript(m_webView, jscode.get(), nullptr, nullptr, nullptr); 657 658 g_main_loop_run(m_mainLoop); 659 } 660 661 void closeNotificationAndWaitUntilCancelled() 662 { 663 m_event = None; 664 webkit_web_view_run_javascript(m_webView, "n.close()", nullptr, nullptr, nullptr); 665 g_main_loop_run(m_mainLoop); 666 } 667 668 NotificationEvent m_event; 669 WebKitNotification* m_notification; 670 }; 671 672 static void testWebViewNotification(NotificationWebViewTest* test, gconstpointer) 673 { 674 // Notifications don't work with local or special schemes. 675 test->loadURI(gServer->getURIForPath("/").data()); 676 test->waitUntilLoadFinished(); 677 678 test->requestPermissionAndWaitUntilGiven(); 679 680 g_assert(test->m_event == NotificationWebViewTest::Permission); 681 682 static const char* title = "This is a notification"; 683 static const char* body = "This is the body."; 684 test->requestNotificationAndWaitUntilShown(title, body); 685 686 g_assert(test->m_event == NotificationWebViewTest::Shown); 687 g_assert(test->m_notification); 688 g_assert_cmpstr(webkit_notification_get_title(test->m_notification), ==, title); 689 g_assert_cmpstr(webkit_notification_get_body(test->m_notification), ==, body); 690 691 test->closeNotificationAndWaitUntilCancelled(); 692 693 g_assert(test->m_event == NotificationWebViewTest::Cancelled); 694 695 test->requestNotificationAndWaitUntilShown(title, body); 696 697 g_assert(test->m_event == NotificationWebViewTest::Shown); 698 699 test->loadURI(gServer->getURIForPath("/").data()); 700 test->waitUntilLoadFinished(); 701 702 g_assert(test->m_event == NotificationWebViewTest::Cancelled); 703 } 704 705 static void serverCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer) 706 { 707 if (message->method != SOUP_METHOD_GET) { 708 soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED); 709 return; 710 } 711 712 if (g_str_equal(path, "/")) { 713 soup_message_set_status(message, SOUP_STATUS_OK); 714 soup_message_body_complete(message->response_body); 715 } else 716 soup_message_set_status(message, SOUP_STATUS_NOT_FOUND); 717 } 718 584 719 void beforeAll() 585 720 { 721 gServer = new WebKitTestServer(); 722 gServer->run(serverCallback); 723 586 724 WebViewTest::add("WebKitWebView", "web-context", testWebViewWebContext); 587 725 WebViewTest::add("WebKitWebView", "custom-charset", testWebViewCustomCharset); … … 595 733 SnapshotWebViewTest::add("WebKitWebView", "snapshot", testWebViewSnapshot); 596 734 WebViewTest::add("WebKitWebView", "page-visibility", testWebViewPageVisibility); 735 NotificationWebViewTest::add("WebKitWebView", "notification", testWebViewNotification); 597 736 } 598 737
Note:
See TracChangeset
for help on using the changeset viewer.