<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[179745] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/179745">179745</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2015-02-06 06:50:20 -0800 (Fri, 06 Feb 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>[GTK] Remove WebKitWebView::close-notification signal
https://bugs.webkit.org/show_bug.cgi?id=141330
Reviewed by Gustavo Noronha Silva.
Source/WebKit2:
In favor of a WebKitNotification::closed signal and
webkit_notification_close() method that both applications and
WebKit can use to close a notification. This also fixes the
onclose event that was not fired when the notification was
closed. It also brings back padding space in WebKitWebViewClass.
* UIProcess/API/gtk/WebKitNotification.cpp:
(webkit_notification_class_init): Add WebKitNotification::closed signal.
(webkit_notification_close): Emit WebKitNotification::closed.
* UIProcess/API/gtk/WebKitNotification.h:
* UIProcess/API/gtk/WebKitNotificationProvider.cpp:
(WebKitNotificationProvider::notificationCloseCallback): Callback
for WebKitNotification::closed signal that notifies the WebProcess
and removes the notification from the map.
(WebKitNotificationProvider::show): Connect to WebKitNotification::closed.
(WebKitNotificationProvider::cancelNotificationByID): Call webkit_notification_close().
* UIProcess/API/gtk/WebKitNotificationProvider.h:
* UIProcess/API/gtk/WebKitWebView.cpp:
(notifyNotificationClosed): The user closed the annotation, call
webkit_notification_close().
(webNotificationClosed): The WebKitNotification has been closed,
close the libnotify notification if it hasn't been closed yet.
(webkitWebViewShowNotification): Create the libnotifiy
notification if needed and associate it to the WebKitNotification
as user data. Connect to the closed signal of both, the libnotifiy
notification and the WebKit notification.
(webkitWebViewCloseNotification): Deleted.
(webkit_web_view_class_init): Remove close-notification signal and
the default hanlder.
(webkitWebViewEmitCloseNotification): Deleted.
* UIProcess/API/gtk/WebKitWebView.h:
* UIProcess/API/gtk/WebKitWebViewPrivate.h:
* UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt: Add webkit_notification_close.
Tools:
Update notifications unit tests according to the API changes, and
add a test case to check that onclose event is fired when a
notification is closed by the user.
* TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp:
(testWebViewNotification):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitNotificationcpp">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotification.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitNotificationh">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotification.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitNotificationProvidercpp">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotificationProvider.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitNotificationProviderh">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotificationProvider.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewcpp">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewh">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewPrivateh">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkdocswebkit2gtk40sectionstxt">trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkTestWebKitWebViewcpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (179744 => 179745)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-02-06 14:46:17 UTC (rev 179744)
+++ trunk/Source/WebKit2/ChangeLog        2015-02-06 14:50:20 UTC (rev 179745)
</span><span class="lines">@@ -1,5 +1,46 @@
</span><span class="cx"> 2015-02-06 Carlos Garcia Campos <cgarcia@igalia.com>
</span><span class="cx">
</span><ins>+ [GTK] Remove WebKitWebView::close-notification signal
+ https://bugs.webkit.org/show_bug.cgi?id=141330
+
+ Reviewed by Gustavo Noronha Silva.
+
+ In favor of a WebKitNotification::closed signal and
+ webkit_notification_close() method that both applications and
+ WebKit can use to close a notification. This also fixes the
+ onclose event that was not fired when the notification was
+ closed. It also brings back padding space in WebKitWebViewClass.
+
+ * UIProcess/API/gtk/WebKitNotification.cpp:
+ (webkit_notification_class_init): Add WebKitNotification::closed signal.
+ (webkit_notification_close): Emit WebKitNotification::closed.
+ * UIProcess/API/gtk/WebKitNotification.h:
+ * UIProcess/API/gtk/WebKitNotificationProvider.cpp:
+ (WebKitNotificationProvider::notificationCloseCallback): Callback
+ for WebKitNotification::closed signal that notifies the WebProcess
+ and removes the notification from the map.
+ (WebKitNotificationProvider::show): Connect to WebKitNotification::closed.
+ (WebKitNotificationProvider::cancelNotificationByID): Call webkit_notification_close().
+ * UIProcess/API/gtk/WebKitNotificationProvider.h:
+ * UIProcess/API/gtk/WebKitWebView.cpp:
+ (notifyNotificationClosed): The user closed the annotation, call
+ webkit_notification_close().
+ (webNotificationClosed): The WebKitNotification has been closed,
+ close the libnotify notification if it hasn't been closed yet.
+ (webkitWebViewShowNotification): Create the libnotifiy
+ notification if needed and associate it to the WebKitNotification
+ as user data. Connect to the closed signal of both, the libnotifiy
+ notification and the WebKit notification.
+ (webkitWebViewCloseNotification): Deleted.
+ (webkit_web_view_class_init): Remove close-notification signal and
+ the default hanlder.
+ (webkitWebViewEmitCloseNotification): Deleted.
+ * UIProcess/API/gtk/WebKitWebView.h:
+ * UIProcess/API/gtk/WebKitWebViewPrivate.h:
+ * UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt: Add webkit_notification_close.
+
+2015-02-06 Carlos Garcia Campos <cgarcia@igalia.com>
+
</ins><span class="cx"> ASSERTION FAILED: !m_adoptionIsRequired in WTF::RefCountedBase::ref
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=141035
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitNotificationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotification.cpp (179744 => 179745)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotification.cpp        2015-02-06 14:46:17 UTC (rev 179744)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotification.cpp        2015-02-06 14:50:20 UTC (rev 179745)
</span><span class="lines">@@ -42,6 +42,12 @@
</span><span class="cx"> PROP_BODY
</span><span class="cx"> };
</span><span class="cx">
</span><ins>+enum {
+ CLOSED,
+
+ LAST_SIGNAL
+};
+
</ins><span class="cx"> struct _WebKitNotificationPrivate {
</span><span class="cx"> CString title;
</span><span class="cx"> CString body;
</span><span class="lines">@@ -50,6 +56,8 @@
</span><span class="cx"> WebKitWebView* webView;
</span><span class="cx"> };
</span><span class="cx">
</span><ins>+static guint signals[LAST_SIGNAL] = { 0, };
+
</ins><span class="cx"> WEBKIT_DEFINE_TYPE(WebKitNotification, webkit_notification, G_TYPE_OBJECT)
</span><span class="cx">
</span><span class="cx"> static void webkitNotificationGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec)
</span><span class="lines">@@ -120,6 +128,27 @@
</span><span class="cx"> _("The body for the notification"),
</span><span class="cx"> nullptr,
</span><span class="cx"> WEBKIT_PARAM_READABLE));
</span><ins>+
+ /**
+ * WebKitNotification::closed:
+ * @notification: the #WebKitNotification on which the signal is emitted
+ *
+ * Emitted when a notification has been withdrawn.
+ *
+ * The default handler will close the notification using libnotify, if built with
+ * support for it.
+ *
+ * Since: 2.8
+ */
+ signals[CLOSED] =
+ g_signal_new(
+ "closed",
+ G_TYPE_FROM_CLASS(notificationClass),
+ G_SIGNAL_RUN_LAST,
+ 0, 0,
+ nullptr,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> WebKitNotification* webkitNotificationCreate(WebKitWebView* webView, const WebKit::WebNotification& webNotification)
</span><span class="lines">@@ -187,3 +216,18 @@
</span><span class="cx">
</span><span class="cx"> return notification->priv->body.data();
</span><span class="cx"> }
</span><ins>+
+/**
+ * webkit_notification_close:
+ * @notification: a #WebKitNotification
+ *
+ * Closes the notification.
+ *
+ * Since: 2.8
+ */
+void webkit_notification_close(WebKitNotification* notification)
+{
+ g_return_if_fail(WEBKIT_IS_NOTIFICATION(notification));
+
+ g_signal_emit(notification, signals[CLOSED], 0);
+}
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitNotificationh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotification.h (179744 => 179745)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotification.h        2015-02-06 14:46:17 UTC (rev 179744)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotification.h        2015-02-06 14:50:20 UTC (rev 179745)
</span><span class="lines">@@ -70,6 +70,9 @@
</span><span class="cx"> WEBKIT_API const gchar *
</span><span class="cx"> webkit_notification_get_body (WebKitNotification *notification);
</span><span class="cx">
</span><ins>+WEBKIT_API void
+webkit_notification_close (WebKitNotification* notification);
+
</ins><span class="cx"> G_END_DECLS
</span><span class="cx">
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitNotificationProvidercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotificationProvider.cpp (179744 => 179745)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotificationProvider.cpp        2015-02-06 14:46:17 UTC (rev 179744)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotificationProvider.cpp        2015-02-06 14:50:20 UTC (rev 179745)
</span><span class="lines">@@ -86,12 +86,22 @@
</span><span class="cx"> WKNotificationManagerSetProvider(toAPI(notificationManager), reinterpret_cast<WKNotificationProviderBase*>(&wkNotificationProvider));
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void WebKitNotificationProvider::notificationCloseCallback(WebKitNotification* notification, WebKitNotificationProvider* provider)
+{
+ uint64_t notificationID = webkit_notification_get_id(notification);
+ Vector<RefPtr<API::Object>, 1> arrayIDs;
+ arrayIDs.uncheckedAppend(API::UInt64::create(notificationID));
+ provider->m_notificationManager->providerDidCloseNotifications(API::Array::create(WTF::move(arrayIDs)).get());
+ provider->m_notifications.remove(notificationID);
+}
+
</ins><span class="cx"> void WebKitNotificationProvider::show(WebPageProxy* page, const WebNotification& webNotification)
</span><span class="cx"> {
</span><span class="cx"> GRefPtr<WebKitNotification> notification = m_notifications.get(webNotification.notificationID());
</span><span class="cx">
</span><span class="cx"> if (!notification) {
</span><span class="cx"> notification = adoptGRef(webkitNotificationCreate(WEBKIT_WEB_VIEW(page->viewWidget()), webNotification));
</span><ins>+ g_signal_connect(notification.get(), "closed", G_CALLBACK(notificationCloseCallback), this);
</ins><span class="cx"> m_notifications.set(webNotification.notificationID(), notification);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -102,9 +112,7 @@
</span><span class="cx"> void WebKitNotificationProvider::cancelNotificationByID(uint64_t notificationID)
</span><span class="cx"> {
</span><span class="cx"> if (GRefPtr<WebKitNotification> notification = m_notifications.get(notificationID))
</span><del>- webkitWebViewEmitCloseNotification(webkitNotificationGetWebView(notification.get()), notification.get());
-
- m_notifications.remove(notificationID);
</del><ins>+ webkit_notification_close(notification.get());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void WebKitNotificationProvider::cancel(const WebNotification& webNotification)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitNotificationProviderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotificationProvider.h (179744 => 179745)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotificationProvider.h        2015-02-06 14:46:17 UTC (rev 179744)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNotificationProvider.h        2015-02-06 14:50:20 UTC (rev 179745)
</span><span class="lines">@@ -45,6 +45,7 @@
</span><span class="cx"> WebKitNotificationProvider(WebNotificationManagerProxy*);
</span><span class="cx">
</span><span class="cx"> void cancelNotificationByID(uint64_t);
</span><ins>+ static void notificationCloseCallback(WebKitNotification*, WebKitNotificationProvider*);
</ins><span class="cx">
</span><span class="cx"> RefPtr<WebNotificationManagerProxy> m_notificationManager;
</span><span class="cx"> HashMap<uint64_t, GRefPtr<WebKitNotification>> m_notifications;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp (179744 => 179745)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp        2015-02-06 14:46:17 UTC (rev 179744)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp        2015-02-06 14:50:20 UTC (rev 179745)
</span><span class="lines">@@ -131,7 +131,6 @@
</span><span class="cx"> AUTHENTICATE,
</span><span class="cx">
</span><span class="cx"> SHOW_NOTIFICATION,
</span><del>- CLOSE_NOTIFICATION,
</del><span class="cx">
</span><span class="cx"> LAST_SIGNAL
</span><span class="cx"> };
</span><span class="lines">@@ -155,9 +154,7 @@
</span><span class="cx">
</span><span class="cx"> typedef HashMap<uint64_t, GRefPtr<WebKitWebResource> > LoadingResourcesMap;
</span><span class="cx"> typedef HashMap<uint64_t, GRefPtr<GTask> > SnapshotResultsMap;
</span><del>-#if USE(LIBNOTIFY)
-typedef HashMap<uint64_t, GRefPtr<NotifyNotification>> NotifyNotificationsMap;
-#endif
</del><ins>+
</ins><span class="cx"> class PageLoadStateObserver;
</span><span class="cx">
</span><span class="cx"> struct _WebKitWebViewPrivate {
</span><span class="lines">@@ -209,9 +206,6 @@
</span><span class="cx"> SnapshotResultsMap snapshotResultsMap;
</span><span class="cx"> GRefPtr<WebKitAuthenticationRequest> authenticationRequest;
</span><span class="cx">
</span><del>-#if USE(LIBNOTIFY)
- NotifyNotificationsMap notifyNotificationsMap;
-#endif
</del><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> static guint signals[LAST_SIGNAL] = { 0, };
</span><span class="lines">@@ -583,46 +577,53 @@
</span><span class="cx"> webkitDownloadSetWebView(download.get(), WEBKIT_WEB_VIEW(webViewBase));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static gboolean webkitWebViewShowNotification(WebKitWebView* webView, WebKitNotification* webNotification)
</del><ins>+#if USE(LIBNOTIFY)
+static const char* gNotifyNotificationID = "wk-notify-notification";
+
+static void notifyNotificationClosed(NotifyNotification*, WebKitNotification* webNotification)
</ins><span class="cx"> {
</span><ins>+ g_object_set_data(G_OBJECT(webNotification), gNotifyNotificationID, nullptr);
+ webkit_notification_close(webNotification);
+}
+
+static void webNotificationClosed(WebKitNotification* webNotification)
+{
+ NotifyNotification* notification = NOTIFY_NOTIFICATION(g_object_get_data(G_OBJECT(webNotification), gNotifyNotificationID));
+ if (!notification)
+ return;
+
+ notify_notification_close(notification, nullptr);
+ g_object_set_data(G_OBJECT(webNotification), gNotifyNotificationID, nullptr);
+}
+#endif // USE(LIBNOTIFY)
+
+static gboolean webkitWebViewShowNotification(WebKitWebView*, WebKitNotification* webNotification)
+{
</ins><span class="cx"> #if USE(LIBNOTIFY)
</span><span class="cx"> if (!notify_is_initted())
</span><span class="cx"> notify_init(g_get_prgname());
</span><span class="cx">
</span><del>- GRefPtr<NotifyNotification> notification = webView->priv->notifyNotificationsMap.get(webkit_notification_get_id(webNotification));
</del><ins>+ NotifyNotification* notification = NOTIFY_NOTIFICATION(g_object_get_data(G_OBJECT(webNotification), gNotifyNotificationID));
</ins><span class="cx"> if (!notification) {
</span><del>- notification = adoptGRef(notify_notification_new(webkit_notification_get_title(webNotification),
- webkit_notification_get_body(webNotification), nullptr));
</del><ins>+ notification = notify_notification_new(webkit_notification_get_title(webNotification),
+ webkit_notification_get_body(webNotification), nullptr);
</ins><span class="cx">
</span><del>- webView->priv->notifyNotificationsMap.set(webkit_notification_get_id(webNotification), notification);
- } else
- notify_notification_update(notification.get(), webkit_notification_get_title(webNotification),
</del><ins>+ g_signal_connect_object(notification, "closed", G_CALLBACK(notifyNotificationClosed), webNotification, static_cast<GConnectFlags>(0));
+ g_signal_connect(webNotification, "closed", G_CALLBACK(webNotificationClosed), nullptr);
+ g_object_set_data_full(G_OBJECT(webNotification), gNotifyNotificationID, notification, static_cast<GDestroyNotify>(g_object_unref));
+ } else {
+ notify_notification_update(notification, webkit_notification_get_title(webNotification),
</ins><span class="cx"> webkit_notification_get_body(webNotification), nullptr);
</span><ins>+ }
</ins><span class="cx">
</span><del>- notify_notification_show(notification.get(), nullptr);
</del><ins>+ notify_notification_show(notification, nullptr);
</ins><span class="cx"> return TRUE;
</span><span class="cx"> #else
</span><del>- UNUSED_PARAM(webView);
</del><span class="cx"> UNUSED_PARAM(webNotification);
</span><span class="cx"> return FALSE;
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span><del>-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(webView);
- UNUSED_PARAM(webNotification);
- return FALSE;
-#endif
-}
-
</del><span class="cx"> static void webkitWebViewConstructed(GObject* object)
</span><span class="cx"> {
</span><span class="cx"> G_OBJECT_CLASS(webkit_web_view_parent_class)->constructed(object);
</span><span class="lines">@@ -784,7 +785,6 @@
</span><span class="cx"> webViewClass->run_file_chooser = webkitWebViewRunFileChooser;
</span><span class="cx"> webViewClass->authenticate = webkitWebViewAuthenticate;
</span><span class="cx"> webViewClass->show_notification = webkitWebViewShowNotification;
</span><del>- webViewClass->close_notification = webkitWebViewCloseNotification;
</del><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * WebKitWebView:web-context:
</span><span class="lines">@@ -1714,30 +1714,6 @@
</span><span class="cx"> webkit_marshal_BOOLEAN__OBJECT,
</span><span class="cx"> G_TYPE_BOOLEAN, 1,
</span><span class="cx"> WEBKIT_TYPE_NOTIFICATION);
</span><del>-
- /**
- * 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);
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void webkitWebViewCancelAuthenticationRequest(WebKitWebView* webView)
</span><span class="lines">@@ -2115,12 +2091,6 @@
</span><span class="cx"> return handled;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void webkitWebViewEmitCloseNotification(WebKitWebView* webView, WebKitNotification* webNotification)
-{
- gboolean handled;
- g_signal_emit(webView, signals[CLOSE_NOTIFICATION], 0, webNotification, &handled);
-}
-
</del><span class="cx"> /**
</span><span class="cx"> * webkit_web_view_new:
</span><span class="cx"> *
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h (179744 => 179745)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h        2015-02-06 14:46:17 UTC (rev 179744)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h        2015-02-06 14:50:20 UTC (rev 179745)
</span><span class="lines">@@ -244,13 +244,12 @@
</span><span class="cx"> GTlsCertificateFlags errors);
</span><span class="cx"> gboolean (* show_notification) (WebKitWebView *web_view,
</span><span class="cx"> WebKitNotification *notification);
</span><del>- gboolean (* close_notification) (WebKitWebView *web_view,
- WebKitNotification *notification);
</del><span class="cx">
</span><span class="cx"> void (*_webkit_reserved0) (void);
</span><span class="cx"> void (*_webkit_reserved1) (void);
</span><span class="cx"> void (*_webkit_reserved2) (void);
</span><span class="cx"> void (*_webkit_reserved3) (void);
</span><ins>+ void (*_webkit_reserved4) (void);
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> WEBKIT_API GType
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h (179744 => 179745)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h        2015-02-06 14:46:17 UTC (rev 179744)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h        2015-02-06 14:50:20 UTC (rev 179745)
</span><span class="lines">@@ -59,7 +59,6 @@
</span><span class="cx"> void webkitWebViewHandleAuthenticationChallenge(WebKitWebView*, WebKit::AuthenticationChallengeProxy*);
</span><span class="cx"> void webkitWebViewInsecureContentDetected(WebKitWebView*, WebKitInsecureContentEvent);
</span><span class="cx"> bool webkitWebViewEmitShowNotification(WebKitWebView*, WebKitNotification*);
</span><del>-void webkitWebViewEmitCloseNotification(WebKitWebView*, WebKitNotification*);
</del><span class="cx"> void webkitWebViewWebProcessCrashed(WebKitWebView*);
</span><span class="cx"> void webkitWebViewIsPlayingAudioChanged(WebKitWebView*);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkdocswebkit2gtk40sectionstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt (179744 => 179745)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt        2015-02-06 14:46:17 UTC (rev 179744)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt        2015-02-06 14:50:20 UTC (rev 179745)
</span><span class="lines">@@ -626,6 +626,7 @@
</span><span class="cx"> webkit_notification_get_id
</span><span class="cx"> webkit_notification_get_title
</span><span class="cx"> webkit_notification_get_body
</span><ins>+webkit_notification_close
</ins><span class="cx">
</span><span class="cx"> <SUBSECTION Standard>
</span><span class="cx"> WebKitNotificationClass
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (179744 => 179745)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2015-02-06 14:46:17 UTC (rev 179744)
+++ trunk/Tools/ChangeLog        2015-02-06 14:50:20 UTC (rev 179745)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2015-02-06 Carlos Garcia Campos <cgarcia@igalia.com>
+
+ [GTK] Remove WebKitWebView::close-notification signal
+ https://bugs.webkit.org/show_bug.cgi?id=141330
+
+ Reviewed by Gustavo Noronha Silva.
+
+ Update notifications unit tests according to the API changes, and
+ add a test case to check that onclose event is fired when a
+ notification is closed by the user.
+
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp:
+ (testWebViewNotification):
+
</ins><span class="cx"> 2015-02-05 Alexey Proskuryakov <ap@apple.com>
</span><span class="cx">
</span><span class="cx"> Dashboard doesn't consider building ASan a productive step
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestWebKitWebViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp (179744 => 179745)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp        2015-02-06 14:46:17 UTC (rev 179744)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp        2015-02-06 14:50:20 UTC (rev 179745)
</span><span class="lines">@@ -602,7 +602,8 @@
</span><span class="cx"> None,
</span><span class="cx"> Permission,
</span><span class="cx"> Shown,
</span><del>- Cancelled
</del><ins>+ Closed,
+ OnClosed,
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> static gboolean permissionRequestCallback(WebKitWebView*, WebKitPermissionRequest *request, NotificationWebViewTest* test)
</span><span class="lines">@@ -619,35 +620,50 @@
</span><span class="cx"> return TRUE;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ static gboolean notificationClosedCallback(WebKitNotification* notification, NotificationWebViewTest* test)
+ {
+ g_assert(test->m_notification == notification);
+ test->m_notification = nullptr;
+ test->m_event = Closed;
+ if (g_main_loop_is_running(test->m_mainLoop))
+ g_main_loop_quit(test->m_mainLoop);
+ return TRUE;
+ }
+
</ins><span class="cx"> static gboolean showNotificationCallback(WebKitWebView*, WebKitNotification* notification, NotificationWebViewTest* test)
</span><span class="cx"> {
</span><span class="cx"> test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(notification));
</span><span class="cx"> test->m_notification = notification;
</span><ins>+ g_signal_connect(notification, "closed", G_CALLBACK(notificationClosedCallback), test);
</ins><span class="cx"> test->m_event = Shown;
</span><span class="cx"> g_main_loop_quit(test->m_mainLoop);
</span><span class="cx"> return TRUE;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- static gboolean closeNotificationCallback(WebKitWebView*, WebKitNotification*, NotificationWebViewTest* test)
</del><ins>+ static void notificationsMessageReceivedCallback(WebKitUserContentManager* userContentManager, WebKitJavascriptResult*, NotificationWebViewTest* test)
</ins><span class="cx"> {
</span><del>- test->m_notification = nullptr;
- test->m_event = Cancelled;
</del><ins>+ test->m_event = OnClosed;
</ins><span class="cx"> g_main_loop_quit(test->m_mainLoop);
</span><del>- return TRUE;
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> NotificationWebViewTest()
</span><del>- : m_event(None)
</del><ins>+ : WebViewTest(webkit_user_content_manager_new())
+ , m_notification(nullptr)
+ , m_event(None)
</ins><span class="cx"> {
</span><span class="cx"> g_signal_connect(m_webView, "permission-request", G_CALLBACK(permissionRequestCallback), this);
</span><span class="cx"> g_signal_connect(m_webView, "show-notification", G_CALLBACK(showNotificationCallback), this);
</span><del>- g_signal_connect(m_webView, "close-notification", G_CALLBACK(closeNotificationCallback), this);
-
</del><ins>+ WebKitUserContentManager* manager = webkit_web_view_get_user_content_manager(m_webView);
+ webkit_user_content_manager_register_script_message_handler(manager, "notifications");
+ g_signal_connect(manager, "script-message-received::notifications", G_CALLBACK(notificationsMessageReceivedCallback), this);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> ~NotificationWebViewTest()
</span><span class="cx"> {
</span><span class="cx"> g_signal_handlers_disconnect_matched(m_webView, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
</span><ins>+ WebKitUserContentManager* manager = webkit_web_view_get_user_content_manager(m_webView);
+ g_signal_handlers_disconnect_matched(manager, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
+ webkit_user_content_manager_unregister_script_message_handler(manager, "notifications");
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void requestPermissionAndWaitUntilGiven()
</span><span class="lines">@@ -667,13 +683,23 @@
</span><span class="cx"> g_main_loop_run(m_mainLoop);
</span><span class="cx"> }
</span><span class="cx">
</span><del>- void closeNotificationAndWaitUntilCancelled()
</del><ins>+ void closeNotificationAndWaitUntilClosed()
</ins><span class="cx"> {
</span><span class="cx"> m_event = None;
</span><span class="cx"> webkit_web_view_run_javascript(m_webView, "n.close()", nullptr, nullptr, nullptr);
</span><span class="cx"> g_main_loop_run(m_mainLoop);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ void closeNotificationAndWaitUntilOnClosed()
+ {
+ g_assert(m_notification);
+ m_event = None;
+ runJavaScriptAndWaitUntilFinished("n.onclose = function() { window.webkit.messageHandlers.notifications.postMessage('closed'); }", nullptr);
+ webkit_notification_close(m_notification);
+ g_assert(m_event == Closed);
+ g_main_loop_run(m_mainLoop);
+ }
+
</ins><span class="cx"> NotificationEvent m_event;
</span><span class="cx"> WebKitNotification* m_notification;
</span><span class="cx"> };
</span><span class="lines">@@ -685,7 +711,6 @@
</span><span class="cx"> test->waitUntilLoadFinished();
</span><span class="cx">
</span><span class="cx"> test->requestPermissionAndWaitUntilGiven();
</span><del>-
</del><span class="cx"> g_assert(test->m_event == NotificationWebViewTest::Permission);
</span><span class="cx">
</span><span class="cx"> static const char* title = "This is a notification";
</span><span class="lines">@@ -697,18 +722,21 @@
</span><span class="cx"> g_assert_cmpstr(webkit_notification_get_title(test->m_notification), ==, title);
</span><span class="cx"> g_assert_cmpstr(webkit_notification_get_body(test->m_notification), ==, body);
</span><span class="cx">
</span><del>- test->closeNotificationAndWaitUntilCancelled();
</del><ins>+ test->closeNotificationAndWaitUntilClosed();
+ g_assert(test->m_event == NotificationWebViewTest::Closed);
</ins><span class="cx">
</span><del>- g_assert(test->m_event == NotificationWebViewTest::Cancelled);
</del><ins>+ test->requestNotificationAndWaitUntilShown(title, body);
+ g_assert(test->m_event == NotificationWebViewTest::Shown);
</ins><span class="cx">
</span><ins>+ test->closeNotificationAndWaitUntilOnClosed();
+ g_assert(test->m_event == NotificationWebViewTest::OnClosed);
+
</ins><span class="cx"> test->requestNotificationAndWaitUntilShown(title, body);
</span><del>-
</del><span class="cx"> g_assert(test->m_event == NotificationWebViewTest::Shown);
</span><span class="cx">
</span><span class="cx"> test->loadURI(gServer->getURIForPath("/").data());
</span><span class="cx"> test->waitUntilLoadFinished();
</span><del>-
- g_assert(test->m_event == NotificationWebViewTest::Cancelled);
</del><ins>+ g_assert(test->m_event == NotificationWebViewTest::Closed);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void testWebViewIsPlayingAudio(IsPlayingAudioWebViewTest* test, gconstpointer)
</span></span></pre>
</div>
</div>
</body>
</html>