Diff
Modified: trunk/ChangeLog (177072 => 177073)
--- trunk/ChangeLog 2014-12-10 17:12:28 UTC (rev 177072)
+++ trunk/ChangeLog 2014-12-10 17:36:40 UTC (rev 177073)
@@ -1,3 +1,14 @@
+2014-12-09 Gustavo Noronha Silva <gustavo.noro...@collabora.com>
+
+ [GTK][WK2] Add HTML5 Notifications support
+ https://bugs.webkit.org/show_bug.cgi?id=61140
+
+ Reviewed by Carlos Garcia Campos.
+
+ * Source/cmake/FindLibNotify.cmake: Added.
+ * Source/cmake/OptionsGTK.cmake: add option to enable notifications, look for
+ libnotify and use it for a default implementation when found.
+
2014-12-09 Bem Jones-Bey <bjone...@adobe.com>
REGRESSION(r155906): Page content disappears on Tuaw article after loading
Modified: trunk/LayoutTests/ChangeLog (177072 => 177073)
--- trunk/LayoutTests/ChangeLog 2014-12-10 17:12:28 UTC (rev 177072)
+++ trunk/LayoutTests/ChangeLog 2014-12-10 17:36:40 UTC (rev 177073)
@@ -1,3 +1,12 @@
+2014-12-09 Gustavo Noronha Silva <gustavo.noro...@collabora.com>
+
+ [GTK][WK2] Add HTML5 Notifications support
+ https://bugs.webkit.org/show_bug.cgi?id=61140
+
+ Reviewed by Carlos Garcia Campos.
+
+ * platform/gtk/TestExpectations: unskip the HTTP tests for new-style notifications.
+
2014-12-09 Alexey Proskuryakov <a...@apple.com>
Unskip more multipart tests
Modified: trunk/LayoutTests/platform/gtk/TestExpectations (177072 => 177073)
--- trunk/LayoutTests/platform/gtk/TestExpectations 2014-12-10 17:12:28 UTC (rev 177072)
+++ trunk/LayoutTests/platform/gtk/TestExpectations 2014-12-10 17:36:40 UTC (rev 177073)
@@ -146,10 +146,17 @@
webkit.org/b/98927 fast/dom/DeviceMotion [ Skip ]
webkit.org/b/98927 fast/dom/DeviceOrientation [ Skip ]
-# Desktop notifications are not yet supported.
-webkit.org/b/61140 fast/notifications [ Skip ]
-webkit.org/b/61140 http/tests/notifications [ Skip ]
+# https://bugs.webkit.org/show_bug.cgi?id=81697 Skip file:// based notifications tests
+fast/notifications
+# we do not enable legacy notifications
+http/tests/notifications/legacy/window-show-on-click.html
+http/tests/notifications/legacy/request.html
+http/tests/notifications/legacy/request-no-callback.html
+http/tests/notifications/legacy/events.html
+http/tests/notifications/legacy/show.html
+http/tests/notifications/legacy/double-show.html
+
# StorageTracker is not enabled.
webkit.org/b/98933 storage/domstorage/localstorage/storagetracker [ Skip ]
Modified: trunk/Source/WebKit2/ChangeLog (177072 => 177073)
--- trunk/Source/WebKit2/ChangeLog 2014-12-10 17:12:28 UTC (rev 177072)
+++ trunk/Source/WebKit2/ChangeLog 2014-12-10 17:36:40 UTC (rev 177073)
@@ -1,3 +1,59 @@
+2014-12-09 Claudio Saavedra <csaave...@igalia.com> and Gustavo Noronha Silva <gustavo.noro...@collabora.com>
+
+ [GTK][WK2] Add HTML5 Notifications support
+ https://bugs.webkit.org/show_bug.cgi?id=61140
+
+ Reviewed by Carlos Garcia Campos.
+
+ * PlatformGTK.cmake: add new files to the build.
+ * UIProcess/API/gtk/WebKitForwardDeclarations.h:
+ * UIProcess/API/gtk/WebKitNotification.cpp: Added. New GObject used to expose information about
+ the notification to the API.
+ (webkitNotificationGetProperty):
+ (webkit_notification_class_init):
+ (webkitNotificationCreate):
+ (webkit_notification_get_id):
+ (webkit_notification_get_title):
+ (webkit_notification_get_body):
+ * UIProcess/API/gtk/WebKitNotification.h: Added.
+ * UIProcess/API/gtk/WebKitNotificationPermissionRequest.cpp: Added. Permission request object
+ for notifications.
+ (webkitNotificationPermissionRequestAllow):
+ (webkitNotificationPermissionRequestDeny):
+ (webkit_permission_request_interface_init):
+ (webkitNotificationPermissionRequestDispose):
+ (webkit_notification_permission_request_class_init):
+ (webkitNotificationPermissionRequestCreate):
+ * UIProcess/API/gtk/WebKitNotificationPermissionRequest.h: Added.
+ * UIProcess/API/gtk/WebKitNotificationPermissionRequestPrivate.h: Added.
+ * UIProcess/API/gtk/WebKitNotificationPrivate.h: Added.
+ * UIProcess/API/gtk/WebKitNotificationProvider.cpp: Added. Notification provider that emits signals.
+ The C API allows overriding the notification providers and managers for customizing the handling of
+ notifications. We decided to go for a single manager and a single provider which provide more idiomatic
+ GObject API - signals.
+ (toNotificationProvider):
+ (showCallback):
+ (cancelCallback):
+ (WebKitNotificationProvider::~WebKitNotificationProvider):
+ (WebKitNotificationProvider::create):
+ (WebKitNotificationProvider::WebKitNotificationProvider):
+ (WebKitNotificationProvider::show):
+ (WebKitNotificationProvider::cancel):
+ * UIProcess/API/gtk/WebKitNotificationProvider.h: Added.
+ * UIProcess/API/gtk/WebKitUIClient.cpp: implemented decidePolicyForNotificationPermissionRequest.
+ * UIProcess/API/gtk/WebKitWebContext.cpp:
+ (webkitWebContextConstructed): initialize the notification provider.
+ * UIProcess/API/gtk/WebKitWebView.cpp:
+ (webkitWebViewShowNotification): default implementation for showing the notification, currently
+ using GNotification, about to be ported to libnotify.
+ (webkit_web_view_class_init): set the default implementation for the show-notification signal.
+ (webkitWebViewEmitCloseNotification): emit the close-notification signal.
+ (webkitWebViewEmitShowNotification): emit the show-notification signal.
+ * UIProcess/API/gtk/WebKitWebView.h:
+ * UIProcess/API/gtk/WebKitWebViewPrivate.h:
+ * UIProcess/API/gtk/docs/webkit2gtk-sections.txt: list new objects and methods.
+ * UIProcess/API/gtk/webkit2.h: include new headers.
+
2014-12-10 Grzegorz Czajkowski <g.czajkow...@samsung.com>
[EFL][[WK2] test_ewk2_text_checker is failed
Modified: trunk/Source/WebKit2/PlatformGTK.cmake (177072 => 177073)
--- trunk/Source/WebKit2/PlatformGTK.cmake 2014-12-10 17:12:28 UTC (rev 177072)
+++ trunk/Source/WebKit2/PlatformGTK.cmake 2014-12-10 17:36:40 UTC (rev 177073)
@@ -158,6 +158,14 @@
UIProcess/API/gtk/WebKitNavigationPolicyDecision.cpp
UIProcess/API/gtk/WebKitNavigationPolicyDecision.h
UIProcess/API/gtk/WebKitNavigationPolicyDecisionPrivate.h
+ UIProcess/API/gtk/WebKitNotificationPermissionRequest.cpp
+ UIProcess/API/gtk/WebKitNotificationPermissionRequest.h
+ UIProcess/API/gtk/WebKitNotificationPermissionRequestPrivate.h
+ UIProcess/API/gtk/WebKitNotificationProvider.cpp
+ UIProcess/API/gtk/WebKitNotificationProvider.h
+ UIProcess/API/gtk/WebKitNotification.cpp
+ UIProcess/API/gtk/WebKitNotification.h
+ UIProcess/API/gtk/WebKitNotificationPrivate.h
UIProcess/API/gtk/WebKitPermissionRequest.cpp
UIProcess/API/gtk/WebKitPermissionRequest.h
UIProcess/API/gtk/WebKitPlugin.cpp
@@ -351,6 +359,8 @@
${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitMimeInfo.h
${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitNavigationAction.h
${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitNavigationPolicyDecision.h
+ ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitNotificationPermissionRequest.h
+ ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitNotification.h
${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitPermissionRequest.h
${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitPlugin.h
${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitPolicyDecision.h
@@ -455,6 +465,12 @@
${LIBSOUP_INCLUDE_DIRS}
)
+if (LIBNOTIFY_FOUND)
+list(APPEND WebKit2_INCLUDE_DIRECTORIES
+ ${LIBNOTIFY_INCLUDE_DIRS}
+)
+endif ()
+
set(WebKit2CommonIncludeDirectories ${WebKit2_INCLUDE_DIRECTORIES})
list(APPEND WebKit2_INCLUDE_DIRECTORIES
@@ -489,6 +505,13 @@
WebCorePlatformGTK
${GTK_UNIX_PRINT_LIBRARIES}
)
+
+if (LIBNOTIFY_FOUND)
+list(APPEND WebKit2_LIBRARIES
+ ${LIBNOTIFY_LIBRARIES}
+)
+endif ()
+
ADD_WHOLE_ARCHIVE_TO_LIBRARIES(WebKit2_LIBRARIES)
set(WebKit2_MARSHAL_LIST ${WEBKIT2_DIR}/UIProcess/API/gtk/webkit2marshal.list)
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitForwardDeclarations.h (177072 => 177073)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitForwardDeclarations.h 2014-12-10 17:12:28 UTC (rev 177072)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitForwardDeclarations.h 2014-12-10 17:36:40 UTC (rev 177073)
@@ -35,5 +35,6 @@
typedef struct _WebKitWebView WebKitWebView;
typedef struct _WebKitContextMenu WebKitContextMenu;
typedef struct _WebKitContextMenuItem WebKitContextMenuItem;
+typedef struct _WebKitNotification WebKitNotification;
#endif // WebKitForward_h
Added: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotification.cpp (0 => 177073)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotification.cpp (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotification.cpp 2014-12-10 17:36:40 UTC (rev 177073)
@@ -0,0 +1,189 @@
+/*
+ * Copyright (C) 2014 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "WebKitNotification.h"
+
+#include "WebKitNotificationPrivate.h"
+#include "WebKitPrivate.h"
+#include "WebNotification.h"
+#include <glib/gi18n-lib.h>
+#include <wtf/text/CString.h>
+
+/**
+ * SECTION: WebKitNotification
+ * @Short_description: Object used to hold information about a notification that should be shown to the user.
+ * @Title: WebKitNotification
+ *
+ * Since: 2.8
+ */
+
+enum {
+ PROP_0,
+
+ PROP_ID,
+ PROP_TITLE,
+ PROP_BODY
+};
+
+struct _WebKitNotificationPrivate {
+ CString title;
+ CString body;
+ guint64 id;
+
+ WebKitWebView* webView;
+};
+
+WEBKIT_DEFINE_TYPE(WebKitNotification, webkit_notification, G_TYPE_OBJECT)
+
+static void webkitNotificationGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec)
+{
+ WebKitNotification* notification = WEBKIT_NOTIFICATION(object);
+
+ switch (propId) {
+ case PROP_ID:
+ g_value_set_uint64(value, webkit_notification_get_id(notification));
+ break;
+ case PROP_TITLE:
+ g_value_set_string(value, webkit_notification_get_title(notification));
+ break;
+ case PROP_BODY:
+ g_value_set_string(value, webkit_notification_get_body(notification));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
+ }
+}
+
+static void webkit_notification_class_init(WebKitNotificationClass* notificationClass)
+{
+ GObjectClass* objectClass = G_OBJECT_CLASS(notificationClass);
+ objectClass->get_property = webkitNotificationGetProperty;
+
+ /**
+ * WebKitNotification:id:
+ *
+ * The unique id for the notification.
+ *
+ * Since: 2.8
+ */
+ g_object_class_install_property(objectClass,
+ PROP_ID,
+ g_param_spec_uint64("id",
+ _("ID"),
+ _("The unique id for the notification"),
+ 0, G_MAXUINT64, 0,
+ WEBKIT_PARAM_READABLE));
+
+ /**
+ * WebKitNotification:title:
+ *
+ * The title for the notification.
+ *
+ * Since: 2.8
+ */
+ g_object_class_install_property(objectClass,
+ PROP_TITLE,
+ g_param_spec_string("title",
+ _("Title"),
+ _("The title for the notification"),
+ nullptr,
+ WEBKIT_PARAM_READABLE));
+
+ /**
+ * WebKitNotification:body:
+ *
+ * The body for the notification.
+ *
+ * Since: 2.8
+ */
+ g_object_class_install_property(objectClass,
+ PROP_BODY,
+ g_param_spec_string("body",
+ _("Body"),
+ _("The body for the notification"),
+ nullptr,
+ WEBKIT_PARAM_READABLE));
+}
+
+WebKitNotification* webkitNotificationCreate(WebKitWebView* webView, const WebKit::WebNotification& webNotification)
+{
+ WebKitNotification* notification = WEBKIT_NOTIFICATION(g_object_new(WEBKIT_TYPE_NOTIFICATION, nullptr));
+ notification->priv->id = webNotification.notificationID();
+ notification->priv->title = webNotification.title().utf8();
+ notification->priv->body = webNotification.body().utf8();
+ notification->priv->webView = webView;
+ return notification;
+}
+
+WebKitWebView* webkitNotificationGetWebView(WebKitNotification* notification)
+{
+ return notification->priv->webView;
+}
+
+/**
+ * webkit_notification_get_id:
+ * @notification: a #WebKitNotification
+ *
+ * Obtains the unique id for the notification.
+ *
+ * Returns: the unique id for the notification
+ *
+ * Since: 2.8
+ */
+guint64 webkit_notification_get_id(WebKitNotification* notification)
+{
+ g_return_val_if_fail(WEBKIT_IS_NOTIFICATION(notification), 0);
+
+ return notification->priv->id;
+}
+
+/**
+ * webkit_notification_get_title:
+ * @notification: a #WebKitNotification
+ *
+ * Obtains the title for the notification.
+ *
+ * Returns: the title for the notification
+ *
+ * Since: 2.8
+ */
+const gchar* webkit_notification_get_title(WebKitNotification* notification)
+{
+ g_return_val_if_fail(WEBKIT_IS_NOTIFICATION(notification), nullptr);
+
+ return notification->priv->title.data();
+}
+
+/**
+ * webkit_notification_get_body:
+ * @notification: a #WebKitNotification
+ *
+ * Obtains the body for the notification.
+ *
+ * Returns: the body for the notification
+ *
+ * Since: 2.8
+ */
+const gchar* webkit_notification_get_body(WebKitNotification* notification)
+{
+ g_return_val_if_fail(WEBKIT_IS_NOTIFICATION(notification), nullptr);
+
+ return notification->priv->body.data();
+}
Added: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotification.h (0 => 177073)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotification.h (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotification.h 2014-12-10 17:36:40 UTC (rev 177073)
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2014 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
+#error "Only <webkit2/webkit2.h> can be included directly."
+#endif
+
+#ifndef WebKitNotification_h
+#define WebKitNotification_h
+
+#include <glib-object.h>
+#include <webkit2/WebKitDefines.h>
+#include <webkit2/WebKitForwardDeclarations.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_NOTIFICATION (webkit_notification_get_type())
+#define WEBKIT_NOTIFICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_NOTIFICATION, WebKitNotification))
+#define WEBKIT_IS_NOTIFICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_NOTIFICATION))
+#define WEBKIT_NOTIFICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_NOTIFICATION, WebKitNotificationClass))
+#define WEBKIT_IS_NOTIFICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_NOTIFICATION))
+#define WEBKIT_NOTIFICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_NOTIFICATION, WebKitNotificationClass))
+
+typedef struct _WebKitNotification WebKitNotification;
+typedef struct _WebKitNotificationClass WebKitNotificationClass;
+typedef struct _WebKitNotificationPrivate WebKitNotificationPrivate;
+
+struct _WebKitNotification {
+ GObject parent;
+
+ WebKitNotificationPrivate *priv;
+};
+
+struct _WebKitNotificationClass {
+ GObjectClass parent_class;
+
+ void (*_webkit_reserved0) (void);
+ void (*_webkit_reserved1) (void);
+ void (*_webkit_reserved2) (void);
+ void (*_webkit_reserved3) (void);
+ void (*_webkit_reserved4) (void);
+ void (*_webkit_reserved5) (void);
+};
+
+WEBKIT_API GType
+webkit_notification_get_type (void);
+
+WEBKIT_API guint64
+webkit_notification_get_id (WebKitNotification *notification);
+
+WEBKIT_API const gchar *
+webkit_notification_get_title (WebKitNotification *notification);
+
+WEBKIT_API const gchar *
+webkit_notification_get_body (WebKitNotification *notification);
+
+G_END_DECLS
+
+#endif
Added: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotificationPermissionRequest.cpp (0 => 177073)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotificationPermissionRequest.cpp (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotificationPermissionRequest.cpp 2014-12-10 17:36:40 UTC (rev 177073)
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2013 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "WebKitNotificationPermissionRequest.h"
+
+#include "NotificationPermissionRequest.h"
+#include "WebKitNotificationPermissionRequestPrivate.h"
+#include "WebKitPermissionRequest.h"
+
+using namespace WebKit;
+
+/**
+ * SECTION: WebKitNotificationPermissionRequest
+ * @Short_description: A permission request for displaying web notifications
+ * @Title: WebKitNotificationPermissionRequest
+ * @See_also: #WebKitPermissionRequest, #WebKitWebView
+ *
+ * WebKitNotificationPermissionRequest represents a request for
+ * permission to decide whether WebKit should provide the user with
+ * notifications through the Web Notification API.
+ */
+
+static void webkit_permission_request_interface_init(WebKitPermissionRequestIface*);
+
+struct _WebKitNotificationPermissionRequestPrivate {
+ RefPtr<NotificationPermissionRequest> request;
+ bool madeDecision;
+};
+
+WEBKIT_DEFINE_TYPE_WITH_CODE(
+ WebKitNotificationPermissionRequest, webkit_notification_permission_request, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE(WEBKIT_TYPE_PERMISSION_REQUEST, webkit_permission_request_interface_init))
+
+static void webkitNotificationPermissionRequestAllow(WebKitPermissionRequest* request)
+{
+ ASSERT(WEBKIT_IS_NOTIFICATION_PERMISSION_REQUEST(request));
+
+ WebKitNotificationPermissionRequestPrivate* priv = WEBKIT_NOTIFICATION_PERMISSION_REQUEST(request)->priv;
+
+ // Only one decision at a time.
+ if (priv->madeDecision)
+ return;
+
+ priv->request->allow();
+ priv->madeDecision = true;
+}
+
+static void webkitNotificationPermissionRequestDeny(WebKitPermissionRequest* request)
+{
+ ASSERT(WEBKIT_IS_NOTIFICATION_PERMISSION_REQUEST(request));
+
+ WebKitNotificationPermissionRequestPrivate* priv = WEBKIT_NOTIFICATION_PERMISSION_REQUEST(request)->priv;
+
+ // Only one decision at a time.
+ if (priv->madeDecision)
+ return;
+
+ priv->request->deny();
+ priv->madeDecision = true;
+}
+
+static void webkit_permission_request_interface_init(WebKitPermissionRequestIface* iface)
+{
+ iface->allow = webkitNotificationPermissionRequestAllow;
+ iface->deny = webkitNotificationPermissionRequestDeny;
+}
+
+static void webkitNotificationPermissionRequestDispose(GObject* object)
+{
+ // Default behaviour when no decision has been made is denying the request.
+ webkitNotificationPermissionRequestDeny(WEBKIT_PERMISSION_REQUEST(object));
+ G_OBJECT_CLASS(webkit_notification_permission_request_parent_class)->dispose(object);
+}
+
+static void webkit_notification_permission_request_class_init(WebKitNotificationPermissionRequestClass* klass)
+{
+ GObjectClass* objectClass = G_OBJECT_CLASS(klass);
+ objectClass->dispose = webkitNotificationPermissionRequestDispose;
+}
+
+WebKitNotificationPermissionRequest* webkitNotificationPermissionRequestCreate(NotificationPermissionRequest* request)
+{
+ WebKitNotificationPermissionRequest* notificationPermissionRequest = WEBKIT_NOTIFICATION_PERMISSION_REQUEST(g_object_new(WEBKIT_TYPE_NOTIFICATION_PERMISSION_REQUEST, nullptr));
+ notificationPermissionRequest->priv->request = request;
+ return notificationPermissionRequest;
+}
Added: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotificationPermissionRequest.h (0 => 177073)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotificationPermissionRequest.h (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotificationPermissionRequest.h 2014-12-10 17:36:40 UTC (rev 177073)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2013 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
+#error "Only <webkit2/webkit2.h> can be included directly."
+#endif
+
+#ifndef WebKitNotificationPermissionRequest_h
+#define WebKitNotificationPermissionRequest_h
+
+#include <glib-object.h>
+#include <webkit2/WebKitDefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_NOTIFICATION_PERMISSION_REQUEST (webkit_notification_permission_request_get_type())
+#define WEBKIT_NOTIFICATION_PERMISSION_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_NOTIFICATION_PERMISSION_REQUEST, WebKitNotificationPermissionRequest))
+#define WEBKIT_NOTIFICATION_PERMISSION_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_NOTIFICATION_PERMISSION_REQUEST, WebKitNotificationPermissionRequestClass))
+#define WEBKIT_IS_NOTIFICATION_PERMISSION_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_NOTIFICATION_PERMISSION_REQUEST))
+#define WEBKIT_IS_NOTIFICATION_PERMISSION_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_NOTIFICATION_PERMISSION_REQUEST))
+#define WEBKIT_NOTIFICATION_PERMISSION_REQUEST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_NOTIFICATION_PERMISSION_REQUEST, WebKitNotificationPermissionRequestClass))
+
+typedef struct _WebKitNotificationPermissionRequest WebKitNotificationPermissionRequest;
+typedef struct _WebKitNotificationPermissionRequestClass WebKitNotificationPermissionRequestClass;
+typedef struct _WebKitNotificationPermissionRequestPrivate WebKitNotificationPermissionRequestPrivate;
+
+struct _WebKitNotificationPermissionRequest {
+ GObject parent;
+
+ /*< private >*/
+ WebKitNotificationPermissionRequestPrivate *priv;
+};
+
+struct _WebKitNotificationPermissionRequestClass {
+ GObjectClass parent_class;
+};
+
+WEBKIT_API GType
+webkit_notification_permission_request_get_type (void);
+
+G_END_DECLS
+
+#endif
Added: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotificationPermissionRequestPrivate.h (0 => 177073)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotificationPermissionRequestPrivate.h (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotificationPermissionRequestPrivate.h 2014-12-10 17:36:40 UTC (rev 177073)
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2013 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef WebKitNotificationPermissionRequestPrivate_h
+#define WebKitNotificationPermissionRequestPrivate_h
+
+#include "WebKitNotificationPermissionRequest.h"
+#include "WebKitPrivate.h"
+
+WebKitNotificationPermissionRequest* webkitNotificationPermissionRequestCreate(WebKit::NotificationPermissionRequest*);
+
+#endif // WebKitNotificationPermissionRequestPrivate_h
Added: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotificationPrivate.h (0 => 177073)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotificationPrivate.h (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotificationPrivate.h 2014-12-10 17:36:40 UTC (rev 177073)
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2014 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef WebKitNotificationPrivate_h
+#define WebKitNotificationPrivate_h
+
+#include "WebKitNotification.h"
+#include "WebKitPrivate.h"
+#include "WebNotification.h"
+#include <wtf/text/CString.h>
+
+WebKitNotification* webkitNotificationCreate(WebKitWebView*, const WebKit::WebNotification&);
+WebKitWebView* webkitNotificationGetWebView(WebKitNotification*);
+
+#endif // WebKitNotificationPrivate_h
Added: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotificationProvider.cpp (0 => 177073)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotificationProvider.cpp (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotificationProvider.cpp 2014-12-10 17:36:40 UTC (rev 177073)
@@ -0,0 +1,119 @@
+/*
+ * Copyright (C) 2013 Igalia S.L.
+ * Copyright (C) 2014 Collabora Ltd.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebKitNotificationProvider.h"
+
+#include "APIArray.h"
+#include "WKNotificationManager.h"
+#include "WebKitNotificationPrivate.h"
+#include "WebKitWebViewPrivate.h"
+#include "WebNotificationManagerProxy.h"
+#include "WebPageProxy.h"
+#include <wtf/text/CString.h>
+
+using namespace WebKit;
+
+static inline WebKitNotificationProvider* toNotificationProvider(const void* clientInfo)
+{
+ return static_cast<WebKitNotificationProvider*>(const_cast<void*>(clientInfo));
+}
+
+static void showCallback(WKPageRef page, WKNotificationRef notification, const void* clientInfo)
+{
+ toNotificationProvider(clientInfo)->show(toImpl(page), *toImpl(notification));
+}
+
+static void cancelCallback(WKNotificationRef notification, const void* clientInfo)
+{
+ toNotificationProvider(clientInfo)->cancel(*toImpl(notification));
+}
+
+static void clearNotificationsCallback(WKArrayRef notificationIDs, const void* clientInfo)
+{
+ toNotificationProvider(clientInfo)->clearNotifications(toImpl(notificationIDs));
+}
+
+WebKitNotificationProvider::~WebKitNotificationProvider()
+{
+}
+
+PassRefPtr<WebKitNotificationProvider> WebKitNotificationProvider::create(WebNotificationManagerProxy* notificationManager)
+{
+ return adoptRef(new WebKitNotificationProvider(notificationManager));
+}
+
+WebKitNotificationProvider::WebKitNotificationProvider(WebNotificationManagerProxy* notificationManager)
+ : m_notificationManager(notificationManager)
+{
+ ASSERT(notificationManager);
+
+ WKNotificationProviderV0 wkNotificationProvider = {
+ kWKNotificationProviderCurrentVersion,
+ this, // clientInfo,
+ showCallback,
+ cancelCallback,
+ 0, // didDestroyNotificationCallback,
+ 0, // addNotificationManagerCallback,
+ 0, // removeNotificationManagerCallback,
+ 0, // notificationPermissionsCallback,
+ clearNotificationsCallback,
+ };
+
+ WKNotificationManagerSetProvider(toAPI(notificationManager), reinterpret_cast<WKNotificationProviderBase*>(&wkNotificationProvider));
+}
+
+void WebKitNotificationProvider::show(WebPageProxy* page, const WebNotification& webNotification)
+{
+ GRefPtr<WebKitNotification> notification = m_notifications.get(webNotification.notificationID());
+
+ if (!notification) {
+ notification = adoptGRef(webkitNotificationCreate(WEBKIT_WEB_VIEW(page->viewWidget()), webNotification));
+ m_notifications.set(webNotification.notificationID(), notification);
+ }
+
+ if (webkitWebViewEmitShowNotification(WEBKIT_WEB_VIEW(page->viewWidget()), notification.get()))
+ m_notificationManager->providerDidShowNotification(webNotification.notificationID());
+}
+
+void WebKitNotificationProvider::cancelNotificationByID(uint64_t notificationID)
+{
+ if (GRefPtr<WebKitNotification> notification = m_notifications.get(notificationID))
+ webkitWebViewEmitCloseNotification(webkitNotificationGetWebView(notification.get()), notification.get());
+
+ m_notifications.remove(notificationID);
+}
+
+void WebKitNotificationProvider::cancel(const WebNotification& webNotification)
+{
+ cancelNotificationByID(webNotification.notificationID());
+}
+
+void WebKitNotificationProvider::clearNotifications(const API::Array* notificationIDs)
+{
+ for (const auto& item : notificationIDs->elementsOfType<API::UInt64>())
+ cancelNotificationByID(item->value());
+}
Added: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotificationProvider.h (0 => 177073)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotificationProvider.h (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotificationProvider.h 2014-12-10 17:36:40 UTC (rev 177073)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2013 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef WebKitNotificationProvider_h
+#define WebKitNotificationProvider_h
+
+#include "WebKitPrivate.h"
+#include "WebKitNotification.h"
+#include <wtf/HashMap.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace API {
+class Array;
+};
+
+namespace WebKit {
+
+class WebKitNotificationProvider : public RefCounted<WebKitNotificationProvider> {
+public:
+ virtual ~WebKitNotificationProvider();
+ static PassRefPtr<WebKitNotificationProvider> create(WebNotificationManagerProxy*);
+
+ void show(WebPageProxy*, const WebNotification&);
+ void cancel(const WebNotification&);
+ void clearNotifications(const API::Array*);
+
+private:
+ WebKitNotificationProvider(WebNotificationManagerProxy*);
+
+ void cancelNotificationByID(uint64_t);
+
+ RefPtr<WebNotificationManagerProxy> m_notificationManager;
+ HashMap<uint64_t, GRefPtr<WebKitNotification>> m_notifications;
+};
+
+} // namespace WebKit
+
+#endif
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp (177072 => 177073)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp 2014-12-10 17:12:28 UTC (rev 177072)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp 2014-12-10 17:36:40 UTC (rev 177073)
@@ -24,6 +24,7 @@
#include "WebKitFileChooserRequestPrivate.h"
#include "WebKitGeolocationPermissionRequestPrivate.h"
#include "WebKitNavigationActionPrivate.h"
+#include "WebKitNotificationPermissionRequestPrivate.h"
#include "WebKitPrivate.h"
#include "WebKitURIRequestPrivate.h"
#include "WebKitUserMediaPermissionRequestPrivate.h"
@@ -166,6 +167,13 @@
return true;
}
+ virtual bool decidePolicyForNotificationPermissionRequest(WebPageProxy*, WebSecurityOrigin*, NotificationPermissionRequest* permissionRequest) override
+ {
+ GRefPtr<WebKitNotificationPermissionRequest> notificationPermissionRequest = adoptGRef(webkitNotificationPermissionRequestCreate(permissionRequest));
+ webkitWebViewMakePermissionRequest(m_webView, WEBKIT_PERMISSION_REQUEST(notificationPermissionRequest.get()));
+ return true;
+ }
+
virtual void printFrame(WebPageProxy*, WebFrameProxy* frame) override
{
webkitWebViewPrintFrame(m_webView, frame);
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp (177072 => 177073)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp 2014-12-10 17:12:28 UTC (rev 177072)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp 2014-12-10 17:36:40 UTC (rev 177073)
@@ -33,6 +33,7 @@
#include "WebKitFaviconDatabasePrivate.h"
#include "WebKitGeolocationProvider.h"
#include "WebKitInjectedBundleClient.h"
+#include "WebKitNotificationProvider.h"
#include "WebKitPluginPrivate.h"
#include "WebKitPrivate.h"
#include "WebKitRequestManagerClient.h"
@@ -44,6 +45,7 @@
#include "WebKitWebContextPrivate.h"
#include "WebKitWebViewBasePrivate.h"
#include "WebKitWebViewPrivate.h"
+#include "WebNotificationManagerProxy.h"
#include "WebResourceCacheManagerProxy.h"
#include <WebCore/FileSystem.h>
#include <WebCore/IconDatabase.h>
@@ -166,6 +168,9 @@
#if ENABLE(BATTERY_STATUS)
RefPtr<WebKitBatteryProvider> batteryProvider;
#endif
+#if ENABLE(NOTIFICATIONS)
+ RefPtr<WebKitNotificationProvider> notificationProvider;
+#endif
#if ENABLE(SPELLCHECK)
std::unique_ptr<WebKitTextChecker> textChecker;
#endif
@@ -278,6 +283,9 @@
#if ENABLE(BATTERY_STATUS)
priv->batteryProvider = WebKitBatteryProvider::create(priv->context->supplement<WebBatteryManagerProxy>());
#endif
+#if ENABLE(NOTIFICATIONS)
+ priv->notificationProvider = WebKitNotificationProvider::create(priv->context->supplement<WebNotificationManagerProxy>());
+#endif
#if ENABLE(SPELLCHECK)
priv->textChecker = WebKitTextChecker::create();
#endif
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp (177072 => 177073)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp 2014-12-10 17:12:28 UTC (rev 177072)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp 2014-12-10 17:36:40 UTC (rev 177073)
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2011 Igalia S.L.
* Portions Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved.
+ * Copyright (C) 2014 Collabora Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -42,6 +43,7 @@
#include "WebKitJavascriptResultPrivate.h"
#include "WebKitLoaderClient.h"
#include "WebKitMarshal.h"
+#include "WebKitNotificationPrivate.h"
#include "WebKitPolicyClient.h"
#include "WebKitPrintOperationPrivate.h"
#include "WebKitPrivate.h"
@@ -69,6 +71,10 @@
#include <wtf/gobject/GRefPtr.h>
#include <wtf/text/CString.h>
+#if USE(LIBNOTIFY)
+#include <libnotify/notify.h>
+#endif
+
using namespace WebKit;
using namespace WebCore;
@@ -124,6 +130,9 @@
AUTHENTICATE,
+ SHOW_NOTIFICATION,
+ CLOSE_NOTIFICATION,
+
LAST_SIGNAL
};
@@ -144,6 +153,9 @@
typedef HashMap<uint64_t, GRefPtr<WebKitWebResource> > LoadingResourcesMap;
typedef HashMap<uint64_t, GRefPtr<GTask> > SnapshotResultsMap;
+#if USE(LIBNOTIFY)
+typedef HashMap<uint64_t, GRefPtr<NotifyNotification>> NotifyNotificationsMap;
+#endif
class PageLoadStateObserver;
struct _WebKitWebViewPrivate {
@@ -194,6 +206,10 @@
SnapshotResultsMap snapshotResultsMap;
GRefPtr<WebKitAuthenticationRequest> authenticationRequest;
+
+#if USE(LIBNOTIFY)
+ NotifyNotificationsMap notifyNotificationsMap;
+#endif
};
static guint signals[LAST_SIGNAL] = { 0, };
@@ -562,6 +578,44 @@
webkitDownloadSetWebView(download.get(), WEBKIT_WEB_VIEW(webViewBase));
}
+static gboolean webkitWebViewShowNotification(WebKitWebView* webView, WebKitNotification* webNotification)
+{
+#if USE(LIBNOTIFY)
+ if (!notify_is_initted())
+ notify_init(g_get_prgname());
+
+ GRefPtr<NotifyNotification> notification = webView->priv->notifyNotificationsMap.get(webkit_notification_get_id(webNotification));
+ if (!notification) {
+ notification = adoptGRef(notify_notification_new(webkit_notification_get_title(webNotification),
+ webkit_notification_get_body(webNotification), nullptr));
+
+ webView->priv->notifyNotificationsMap.set(webkit_notification_get_id(webNotification), notification);
+ } else
+ notify_notification_update(notification.get(), webkit_notification_get_title(webNotification),
+ webkit_notification_get_body(webNotification), nullptr);
+
+ notify_notification_show(notification.get(), nullptr);
+ return TRUE;
+#else
+ UNUSED_PARAM(webNotification);
+ return FALSE;
+#endif
+}
+
+static gboolean webkitWebViewCloseNotification(WebKitWebView* webView, WebKitNotification* webNotification)
+{
+#if USE(LIBNOTIFY)
+ if (GRefPtr<NotifyNotification> notification = webView->priv->notifyNotificationsMap.get(webkit_notification_get_id(webNotification))) {
+ notify_notification_close(notification.get(), nullptr);
+ webView->priv->notifyNotificationsMap.remove(webkit_notification_get_id(webNotification));
+ }
+ return TRUE;
+#else
+ UNUSED_PARAM(webNotification);
+ return FALSE;
+#endif
+}
+
static void webkitWebViewConstructed(GObject* object)
{
G_OBJECT_CLASS(webkit_web_view_parent_class)->constructed(object);
@@ -713,6 +767,8 @@
webViewClass->permission_request = webkitWebViewPermissionRequest;
webViewClass->run_file_chooser = webkitWebViewRunFileChooser;
webViewClass->authenticate = webkitWebViewAuthenticate;
+ webViewClass->show_notification = webkitWebViewShowNotification;
+ webViewClass->close_notification = webkitWebViewCloseNotification;
/**
* WebKitWebView:web-context:
@@ -1574,6 +1630,56 @@
webkit_marshal_BOOLEAN__OBJECT,
G_TYPE_BOOLEAN, 1, /* number of parameters */
WEBKIT_TYPE_AUTHENTICATION_REQUEST);
+
+ /**
+ * WebKitWebView::show-notification:
+ * @web_view: the #WebKitWebView
+ * @notification: a #WebKitNofication
+ *
+ * This signal is emitted when a notification should be presented to the
+ * user. The @notification is kept alive until either: 1) the web page cancels it
+ * or 2) a navigation happens.
+ *
+ * The default handler will emit a notification using libnotify, if built with
+ * support for it.
+ *
+ * Returns: %TRUE to stop other handlers from being invoked. %FALSE otherwise.
+ *
+ * Since: 2.8
+ */
+ signals[SHOW_NOTIFICATION] =
+ g_signal_new("show-notification",
+ G_TYPE_FROM_CLASS(gObjectClass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(WebKitWebViewClass, show_notification),
+ g_signal_accumulator_true_handled, nullptr /* accumulator data */,
+ webkit_marshal_BOOLEAN__OBJECT,
+ G_TYPE_BOOLEAN, 1,
+ WEBKIT_TYPE_NOTIFICATION);
+
+ /**
+ * WebKitNotification::close-notification:
+ * @web_view: the #WebKitWebView
+ * @notification: a #WebKitNofication
+ *
+ * This signal is emitted when a notification should be withdrawn.
+ *
+ * The default handler will close the notification using libnotify, if built with
+ * support for it.
+ *
+ * Returns: %TRUE to stop other handlers from being invoked. %FALSE otherwise.
+ *
+ * Since: 2.8
+ */
+ signals[CLOSE_NOTIFICATION] =
+ g_signal_new("close-notification",
+ G_TYPE_FROM_CLASS(gObjectClass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(WebKitWebViewClass, close_notification),
+ g_signal_accumulator_true_handled, nullptr /* accumulator data */,
+ webkit_marshal_BOOLEAN__OBJECT,
+ G_TYPE_BOOLEAN, 1,
+ WEBKIT_TYPE_NOTIFICATION);
}
static void webkitWebViewCancelAuthenticationRequest(WebKitWebView* webView)
@@ -1957,6 +2063,19 @@
g_signal_emit(webView, signals[INSECURE_CONTENT_DETECTED], 0, type);
}
+bool webkitWebViewEmitShowNotification(WebKitWebView* webView, WebKitNotification* webNotification)
+{
+ gboolean handled;
+ g_signal_emit(webView, signals[SHOW_NOTIFICATION], 0, webNotification, &handled);
+ return handled;
+}
+
+void webkitWebViewEmitCloseNotification(WebKitWebView* webView, WebKitNotification* webNotification)
+{
+ gboolean handled;
+ g_signal_emit(webView, signals[CLOSE_NOTIFICATION], 0, webNotification, &handled);
+}
+
/**
* webkit_web_view_new:
*
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h (177072 => 177073)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h 2014-12-10 17:12:28 UTC (rev 177072)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h 2014-12-10 17:36:40 UTC (rev 177073)
@@ -238,12 +238,15 @@
const gchar *failing_uri,
GTlsCertificate *certificate,
GTlsCertificateFlags errors);
+ gboolean (* show_notification) (WebKitWebView *web_view,
+ WebKitNotification *notification);
+ gboolean (* close_notification) (WebKitWebView *web_view,
+ WebKitNotification *notification);
+
void (*_webkit_reserved0) (void);
void (*_webkit_reserved1) (void);
void (*_webkit_reserved2) (void);
void (*_webkit_reserved3) (void);
- void (*_webkit_reserved4) (void);
- void (*_webkit_reserved5) (void);
};
WEBKIT_API GType
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h (177072 => 177073)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h 2014-12-10 17:12:28 UTC (rev 177072)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h 2014-12-10 17:36:40 UTC (rev 177073)
@@ -57,6 +57,8 @@
void webkitWebViewSubmitFormRequest(WebKitWebView*, WebKitFormSubmissionRequest*);
void webkitWebViewHandleAuthenticationChallenge(WebKitWebView*, WebKit::AuthenticationChallengeProxy*);
void webkitWebViewInsecureContentDetected(WebKitWebView*, WebKitInsecureContentEvent);
+bool webkitWebViewEmitShowNotification(WebKitWebView*, WebKitNotification*);
+void webkitWebViewEmitCloseNotification(WebKitWebView*, WebKitNotification*);
void webkitWebViewWebProcessCrashed(WebKitWebView*);
#endif // WebKitWebViewPrivate_h
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt (177072 => 177073)
--- trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt 2014-12-10 17:12:28 UTC (rev 177072)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt 2014-12-10 17:36:40 UTC (rev 177073)
@@ -616,6 +616,45 @@
</SECTION>
<SECTION>
+<FILE>WebKitNotification</FILE>
+WebKitNotification
+webkit_notification_get_id
+webkit_notification_get_title
+webkit_notification_get_body
+
+<SUBSECTION Standard>
+WebKitNotificationClass
+WEBKIT_TYPE_NOTIFICATION
+WEBKIT_IS_NOTIFICATION
+WEBKIT_NOTIFICATION
+WEBKIT_NOTIFICATION_CLASS
+WEBKIT_IS_NOTIFICATION_CLASS
+WEBKIT_NOTIFICATION_GET_CLASS
+
+<SUBSECTION Private>
+WebKitNotificationPrivate
+webkit_notification_get_type
+</SECTION>
+
+<SECTION>
+<FILE>WebKitNotificationPermissionRequest</FILE>
+WebKitNotificationPermissionRequest
+
+<SUBSECTION Standard>
+WebKitNotificationPermissionRequestClass
+WEBKIT_TYPE_NOTIFICATION_PERMISSION_REQUEST
+WEBKIT_NOTIFICATION_PERMISSION_REQUEST
+WEBKIT_IS_NOTIFICATION_PERMISSION_REQUEST
+WEBKIT_NOTIFICATION_PERMISSION_REQUEST_CLASS
+WEBKIT_IS_NOTIFICATION_PERMISSION_REQUEST_CLASS
+WEBKIT_NOTIFICATION_PERMISSION_REQUEST_GET_CLASS
+
+<SUBSECTION Private>
+WebKitNotificationPermissionRequestPrivate
+webkit_notification_permission_request_get_type
+</SECTION>
+
+<SECTION>
<FILE>WebKitPolicyDecision</FILE>
WebKitPolicyDecision
webkit_policy_decision_download
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/webkit2.h (177072 => 177073)
--- trunk/Source/WebKit2/UIProcess/API/gtk/webkit2.h 2014-12-10 17:12:28 UTC (rev 177072)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/webkit2.h 2014-12-10 17:36:40 UTC (rev 177073)
@@ -50,6 +50,8 @@
#include <webkit2/WebKitMimeInfo.h>
#include <webkit2/WebKitNavigationAction.h>
#include <webkit2/WebKitNavigationPolicyDecision.h>
+#include <webkit2/WebKitNotification.h>
+#include <webkit2/WebKitNotificationPermissionRequest.h>
#include <webkit2/WebKitPermissionRequest.h>
#include <webkit2/WebKitPlugin.h>
#include <webkit2/WebKitPrintOperation.h>
Added: trunk/Source/cmake/FindLibNotify.cmake (0 => 177073)
--- trunk/Source/cmake/FindLibNotify.cmake (rev 0)
+++ trunk/Source/cmake/FindLibNotify.cmake 2014-12-10 17:36:40 UTC (rev 177073)
@@ -0,0 +1,55 @@
+# - Try to find LibNotify
+# This module defines the following variables:
+#
+# LIBNOTIFY_FOUND - LibNotify was found
+# LIBNOTIFY_INCLUDE_DIRS - the LibNotify include directories
+# LIBNOTIFY_LIBRARIES - link these to use LibNotify
+#
+# Copyright (C) 2012 Raphael Kubo da Costa <rak...@webkit.org>
+# Copyright (C) 2014 Collabora Ltd.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND ITS CONTRIBUTORS ``AS
+# IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ITS
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+find_package(PkgConfig)
+pkg_check_modules(LIBNOTIFY QUIET libnotify)
+
+find_path(LIBNOTIFY_INCLUDE_DIRS
+ NAMES notify.h
+ HINTS ${LIBNOTIFY_INCLUDEDIR}
+ ${LIBNOTIFY_INCLUDE_DIRS}
+ PATH_SUFFIXES libnotify
+)
+
+find_library(LIBNOTIFY_LIBRARIES
+ NAMES notify
+ HINTS ${LIBNOTIFY_LIBDIR}
+ ${LIBNOTIFY_LIBRARY_DIRS}
+)
+
+include(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibNotify REQUIRED_VARS LIBNOTIFY_INCLUDE_DIRS LIBNOTIFY_LIBRARIES
+ VERSION_VAR LIBNOTIFY_VERSION)
+
+mark_as_advanced(
+ LIBNOTIFY_INCLUDE_DIRS
+ LIBNOTIFY_LIBRARIES
+)
Modified: trunk/Source/cmake/OptionsGTK.cmake (177072 => 177073)
--- trunk/Source/cmake/OptionsGTK.cmake 2014-12-10 17:12:28 UTC (rev 177072)
+++ trunk/Source/cmake/OptionsGTK.cmake 2014-12-10 17:36:40 UTC (rev 177073)
@@ -50,6 +50,7 @@
find_package(EGL)
find_package(GeoClue2 2.1.5)
find_package(GnuTLS 3.0.0)
+find_package(LibNotify)
if (NOT GEOCLUE2_FOUND)
find_package(GeoClue)
@@ -151,6 +152,7 @@
WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NAVIGATOR_CONTENT_UTILS OFF)
WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NAVIGATOR_HWCONCURRENCY ON)
WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NETSCAPE_PLUGIN_API ON)
+WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NOTIFICATIONS ON)
WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_PICTURE_SIZES ON)
WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_QUOTA OFF)
WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_RESOLUTION_MEDIA_QUERY OFF)
@@ -173,6 +175,12 @@
WEBKIT_OPTION_DEFAULT_PORT_VALUE(WTF_USE_TILED_BACKING_STORE OFF)
WEBKIT_OPTION_END()
+if (LIBNOTIFY_FOUND)
+ add_definitions(-DWTF_USE_LIBNOTIFY=1)
+else ()
+ add_definitions(-DWTF_USE_LIBNOTIFY=0)
+endif ()
+
if (ENABLE_PLUGIN_PROCESS_GTK2)
find_package(GTK2 2.24.10 REQUIRED)
find_package(GDK2 2.24.10 REQUIRED)
Modified: trunk/Tools/ChangeLog (177072 => 177073)
--- trunk/Tools/ChangeLog 2014-12-10 17:12:28 UTC (rev 177072)
+++ trunk/Tools/ChangeLog 2014-12-10 17:36:40 UTC (rev 177073)
@@ -1,3 +1,19 @@
+2014-12-09 Gustavo Noronha Silva <gustavo.noro...@collabora.com>
+
+ [GTK][WK2] Add HTML5 Notifications support
+ https://bugs.webkit.org/show_bug.cgi?id=61140
+
+ Reviewed by Carlos Garcia Campos.
+
+ * Scripts/webkitperl/FeatureList.pm: enable notifications for GTK+.
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp:
+ (testWebViewNotification):
+ (beforeAll):
+ * MiniBrowser/gtk/BrowserWindow.c: also handle notification permission requests.
+ (permissionRequestDialogCallback):
+ (webViewDecidePermissionRequest):
+ (geolocationRequestDialogCallback): Deleted.
+
2014-12-09 Benjamin Poulain <bpoul...@apple.com>
Fix webkitpy test expectation
Modified: trunk/Tools/MiniBrowser/gtk/BrowserWindow.c (177072 => 177073)
--- trunk/Tools/MiniBrowser/gtk/BrowserWindow.c 2014-12-10 17:12:28 UTC (rev 177072)
+++ trunk/Tools/MiniBrowser/gtk/BrowserWindow.c 2014-12-10 17:36:40 UTC (rev 177073)
@@ -416,6 +416,10 @@
dialog_title = "Geolocation request";
dialog_message_format = "%s";
dialog_message = "Allow geolocation request?";
+ } else if (WEBKIT_IS_NOTIFICATION_PERMISSION_REQUEST(request)) {
+ dialog_title = "Notification request";
+ dialog_message_format = "%s";
+ dialog_message = "Allow notifications request?";
} else if (WEBKIT_IS_USER_MEDIA_PERMISSION_REQUEST(request)) {
dialog_message_format = "Allow access to %s device?";
gboolean is_for_audio_device = webkit_user_media_permission_is_for_audio_device(WEBKIT_USER_MEDIA_PERMISSION_REQUEST(request));
Modified: trunk/Tools/Scripts/webkitperl/FeatureList.pm (177072 => 177073)
--- trunk/Tools/Scripts/webkitperl/FeatureList.pm 2014-12-10 17:12:28 UTC (rev 177072)
+++ trunk/Tools/Scripts/webkitperl/FeatureList.pm 2014-12-10 17:36:40 UTC (rev 177073)
@@ -327,7 +327,7 @@
define => "ENABLE_NOSNIFF", default => isEfl(), value => \$nosniffSupport },
{ option => "notifications", desc => "Toggle Notifications support",
- define => "ENABLE_NOTIFICATIONS", default => 0, value => \$notificationsSupport },
+ define => "ENABLE_NOTIFICATIONS", default => isGtk(), value => \$notificationsSupport },
{ option => "orientation-events", desc => "Toggle Orientation Events support",
define => "ENABLE_ORIENTATION_EVENTS", default => isIOSWebKit(), value => \$orientationEventsSupport },
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp (177072 => 177073)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp 2014-12-10 17:12:28 UTC (rev 177072)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp 2014-12-10 17:36:40 UTC (rev 177073)
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 Igalia S.L.
+ * Copyright (C) 2014 Collabora Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -18,12 +19,15 @@
*/
#include "config.h"
+#include "WebKitTestServer.h"
#include "WebViewTest.h"
#include <_javascript_Core/JSStringRef.h>
#include <_javascript_Core/JSValueRef.h>
#include <glib/gstdio.h>
#include <wtf/gobject/GRefPtr.h>
+static WebKitTestServer* gServer;
+
static void testWebViewWebContext(WebViewTest* test, gconstpointer)
{
g_assert(webkit_web_view_get_context(test->m_webView) == test->m_webContext.get());
@@ -581,8 +585,142 @@
g_assert(test->getSnapshotAndCancel());
}
+class NotificationWebViewTest: public WebViewTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(NotificationWebViewTest);
+
+ enum NotificationEvent {
+ None,
+ Permission,
+ Shown,
+ Cancelled
+ };
+
+ static gboolean permissionRequestCallback(WebKitWebView*, WebKitPermissionRequest *request, NotificationWebViewTest* test)
+ {
+ g_assert(WEBKIT_IS_NOTIFICATION_PERMISSION_REQUEST(request));
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(request));
+
+ test->m_event = Permission;
+
+ webkit_permission_request_allow(request);
+
+ g_main_loop_quit(test->m_mainLoop);
+
+ return TRUE;
+ }
+
+ static gboolean showNotificationCallback(WebKitWebView*, WebKitNotification* notification, NotificationWebViewTest* test)
+ {
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(notification));
+ test->m_notification = notification;
+ test->m_event = Shown;
+ g_main_loop_quit(test->m_mainLoop);
+ return TRUE;
+ }
+
+ static gboolean closeNotificationCallback(WebKitWebView*, WebKitNotification*, NotificationWebViewTest* test)
+ {
+ test->m_notification = nullptr;
+ test->m_event = Cancelled;
+ g_main_loop_quit(test->m_mainLoop);
+ return TRUE;
+ }
+
+ NotificationWebViewTest()
+ : m_event(None)
+ {
+ g_signal_connect(m_webView, "permission-request", G_CALLBACK(permissionRequestCallback), this);
+ g_signal_connect(m_webView, "show-notification", G_CALLBACK(showNotificationCallback), this);
+ g_signal_connect(m_webView, "close-notification", G_CALLBACK(closeNotificationCallback), this);
+
+ }
+
+ ~NotificationWebViewTest()
+ {
+ g_signal_handlers_disconnect_matched(m_webView, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
+ }
+
+ void requestPermissionAndWaitUntilGiven()
+ {
+ m_event = None;
+ webkit_web_view_run_javascript(m_webView, "Notification.requestPermission();", nullptr, nullptr, nullptr);
+ g_main_loop_run(m_mainLoop);
+ }
+
+ void requestNotificationAndWaitUntilShown(const char* title, const char* body)
+ {
+ m_event = None;
+
+ GUniquePtr<char> jscode(g_strdup_printf("n = new Notification('%s', { body: '%s'});", title, body));
+ webkit_web_view_run_javascript(m_webView, jscode.get(), nullptr, nullptr, nullptr);
+
+ g_main_loop_run(m_mainLoop);
+ }
+
+ void closeNotificationAndWaitUntilCancelled()
+ {
+ m_event = None;
+ webkit_web_view_run_javascript(m_webView, "n.close()", nullptr, nullptr, nullptr);
+ g_main_loop_run(m_mainLoop);
+ }
+
+ NotificationEvent m_event;
+ WebKitNotification* m_notification;
+};
+
+static void testWebViewNotification(NotificationWebViewTest* test, gconstpointer)
+{
+ // Notifications don't work with local or special schemes.
+ test->loadURI(gServer->getURIForPath("/").data());
+ test->waitUntilLoadFinished();
+
+ test->requestPermissionAndWaitUntilGiven();
+
+ g_assert(test->m_event == NotificationWebViewTest::Permission);
+
+ static const char* title = "This is a notification";
+ static const char* body = "This is the body.";
+ test->requestNotificationAndWaitUntilShown(title, body);
+
+ g_assert(test->m_event == NotificationWebViewTest::Shown);
+ g_assert(test->m_notification);
+ g_assert_cmpstr(webkit_notification_get_title(test->m_notification), ==, title);
+ g_assert_cmpstr(webkit_notification_get_body(test->m_notification), ==, body);
+
+ test->closeNotificationAndWaitUntilCancelled();
+
+ g_assert(test->m_event == NotificationWebViewTest::Cancelled);
+
+ test->requestNotificationAndWaitUntilShown(title, body);
+
+ g_assert(test->m_event == NotificationWebViewTest::Shown);
+
+ test->loadURI(gServer->getURIForPath("/").data());
+ test->waitUntilLoadFinished();
+
+ g_assert(test->m_event == NotificationWebViewTest::Cancelled);
+}
+
+static void serverCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer)
+{
+ if (message->method != SOUP_METHOD_GET) {
+ soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED);
+ return;
+ }
+
+ if (g_str_equal(path, "/")) {
+ soup_message_set_status(message, SOUP_STATUS_OK);
+ soup_message_body_complete(message->response_body);
+ } else
+ soup_message_set_status(message, SOUP_STATUS_NOT_FOUND);
+}
+
void beforeAll()
{
+ gServer = new WebKitTestServer();
+ gServer->run(serverCallback);
+
WebViewTest::add("WebKitWebView", "web-context", testWebViewWebContext);
WebViewTest::add("WebKitWebView", "custom-charset", testWebViewCustomCharset);
WebViewTest::add("WebKitWebView", "settings", testWebViewSettings);
@@ -594,6 +732,7 @@
SaveWebViewTest::add("WebKitWebView", "save", testWebViewSave);
SnapshotWebViewTest::add("WebKitWebView", "snapshot", testWebViewSnapshot);
WebViewTest::add("WebKitWebView", "page-visibility", testWebViewPageVisibility);
+ NotificationWebViewTest::add("WebKitWebView", "notification", testWebViewNotification);
}
void afterAll()