Diff
Modified: trunk/Source/WebCore/ChangeLog (106591 => 106592)
--- trunk/Source/WebCore/ChangeLog 2012-02-02 21:55:08 UTC (rev 106591)
+++ trunk/Source/WebCore/ChangeLog 2012-02-02 22:16:14 UTC (rev 106592)
@@ -1,3 +1,21 @@
+2012-02-02 Jon Lee <[email protected]>
+
+ Clear shown notifications when context is no longer active
+ https://bugs.webkit.org/show_bug.cgi?id=77363
+ <rdar://problem/10568907>
+
+ Reviewed by Darin Adler.
+
+ * notifications/NotificationPresenter.h: Add new virtual function to clear notifications
+ associated with a given execution context. By default the notifications are left alone, as
+ before. Individual implementations can override to allow notifications to clear them.
+
+ * notifications/NotificationCenter.cpp:
+ (WebCore::NotificationCenter::disconnectFrame): When disconnecting the page from the frame, we
+ call clearNotifications().
+ * page/Frame.cpp:
+ (WebCore::Frame::pageDestroyed): When the page is destroyed, tell the DOM window to reset notifications.
+
2012-02-02 Anders Carlsson <[email protected]>
The overhang area layer should have a linen background
Modified: trunk/Source/WebCore/notifications/NotificationCenter.cpp (106591 => 106592)
--- trunk/Source/WebCore/notifications/NotificationCenter.cpp 2012-02-02 21:55:08 UTC (rev 106591)
+++ trunk/Source/WebCore/notifications/NotificationCenter.cpp 2012-02-02 22:16:14 UTC (rev 106592)
@@ -66,6 +66,7 @@
if (!m_notificationPresenter)
return;
m_notificationPresenter->cancelRequestsForPermission(scriptExecutionContext());
+ m_notificationPresenter->clearNotifications(scriptExecutionContext());
m_notificationPresenter = 0;
}
Modified: trunk/Source/WebCore/notifications/NotificationPresenter.h (106591 => 106592)
--- trunk/Source/WebCore/notifications/NotificationPresenter.h 2012-02-02 21:55:08 UTC (rev 106591)
+++ trunk/Source/WebCore/notifications/NotificationPresenter.h 2012-02-02 22:16:14 UTC (rev 106592)
@@ -57,6 +57,10 @@
// Requests that a notification that has already been shown be canceled.
virtual void cancel(Notification*) = 0;
+ // When the user closes a page, or quits the client application, all of the page's
+ // associated notifications are cleared.
+ virtual void clearNotifications(ScriptExecutionContext*) { }
+
// Informs the presenter that a Notification object has been destroyed
// (such as by a page transition). The presenter may continue showing
// the notification, but must not attempt to call the event handlers.
Modified: trunk/Source/WebCore/page/Frame.cpp (106591 => 106592)
--- trunk/Source/WebCore/page/Frame.cpp 2012-02-02 21:55:08 UTC (rev 106591)
+++ trunk/Source/WebCore/page/Frame.cpp 2012-02-02 22:16:14 UTC (rev 106592)
@@ -668,6 +668,9 @@
if (m_domWindow) {
m_domWindow->resetGeolocation();
+#if ENABLE(NOTIFICATIONS)
+ m_domWindow->resetNotifications();
+#endif
m_domWindow->pageDestroyed();
}
Modified: trunk/Source/WebKit/win/ChangeLog (106591 => 106592)
--- trunk/Source/WebKit/win/ChangeLog 2012-02-02 21:55:08 UTC (rev 106591)
+++ trunk/Source/WebKit/win/ChangeLog 2012-02-02 22:16:14 UTC (rev 106592)
@@ -1,3 +1,17 @@
+2012-02-02 Jon Lee <[email protected]>
+
+ Clear shown notifications when context is no longer active
+ https://bugs.webkit.org/show_bug.cgi?id=77363
+ <rdar://problem/10568907>
+
+ Reviewed by Darin Adler.
+
+ * WebCoreSupport/WebDesktopNotificationsDelegate.h:
+ (WebDesktopNotificationsDelegate): Add previously missing virtual functions.
+ * WebCoreSupport/WebDesktopNotificationsDelegate.cpp:
+ (WebDesktopNotificationsDelegate::notificationControllerDestroyed):
+ (WebDesktopNotificationsDelegate::cancelRequestsForPermission):
+
2012-02-01 Anders Carlsson <[email protected]>
Another attempt to fix the Windows build.
Modified: trunk/Source/WebKit/win/WebCoreSupport/WebDesktopNotificationsDelegate.cpp (106591 => 106592)
--- trunk/Source/WebKit/win/WebCoreSupport/WebDesktopNotificationsDelegate.cpp 2012-02-02 21:55:08 UTC (rev 106591)
+++ trunk/Source/WebKit/win/WebCoreSupport/WebDesktopNotificationsDelegate.cpp 2012-02-02 22:16:14 UTC (rev 106592)
@@ -165,6 +165,10 @@
notificationDelegate()->notificationDestroyed(NotificationCOMWrapper::create(object));
}
+void WebDesktopNotificationsDelegate::notificationControllerDestroyed()
+{
+}
+
void WebDesktopNotificationsDelegate::requestPermission(SecurityOrigin* origin, PassRefPtr<VoidCallback> callback)
{
BString org(origin->toString());
@@ -172,6 +176,10 @@
notificationDelegate()->requestNotificationPermission(org);
}
+void WebDesktopNotificationsDelegate::cancelRequestsForPermission(ScriptExecutionContext* context)
+{
+}
+
NotificationPresenter::Permission WebDesktopNotificationsDelegate::checkPermission(const KURL& url)
{
int out = 0;
Modified: trunk/Source/WebKit/win/WebCoreSupport/WebDesktopNotificationsDelegate.h (106591 => 106592)
--- trunk/Source/WebKit/win/WebCoreSupport/WebDesktopNotificationsDelegate.h 2012-02-02 21:55:08 UTC (rev 106591)
+++ trunk/Source/WebKit/win/WebCoreSupport/WebDesktopNotificationsDelegate.h 2012-02-02 22:16:14 UTC (rev 106592)
@@ -49,7 +49,9 @@
virtual bool show(WebCore::Notification* object);
virtual void cancel(WebCore::Notification* object);
virtual void notificationObjectDestroyed(WebCore::Notification* object);
+ virtual void notificationControllerDestroyed();
virtual void requestPermission(WebCore::SecurityOrigin* origin, PassRefPtr<WebCore::VoidCallback> callback);
+ virtual void cancelRequestsForPermission(WebCore::ScriptExecutionContext*);
virtual WebCore::NotificationPresenter::Permission checkPermission(const KURL& url);
private:
Modified: trunk/Source/WebKit2/ChangeLog (106591 => 106592)
--- trunk/Source/WebKit2/ChangeLog 2012-02-02 21:55:08 UTC (rev 106591)
+++ trunk/Source/WebKit2/ChangeLog 2012-02-02 22:16:14 UTC (rev 106592)
@@ -1,3 +1,50 @@
+2012-02-02 Jon Lee <[email protected]>
+
+ Clear shown notifications when context is no longer active
+ https://bugs.webkit.org/show_bug.cgi?id=77363
+ <rdar://problem/10568907>
+
+ Reviewed by Darin Adler.
+
+ * WebProcess/WebCoreSupport/WebNotificationClient.cpp:
+ (WebKit::WebNotificationClient::clearNotifications): Forward the call to
+ WebNotificationManager.
+ * WebProcess/WebCoreSupport/WebNotificationClient.h:
+ (WebNotificationClient):
+
+ * WebProcess/Notifications/WebNotificationManager.h: Add an additional map that maps
+ all notifications associated with a given ScriptExecutionContext instance.
+ * WebProcess/Notifications/WebNotificationManager.cpp:
+ (WebKit::WebNotificationManager::show): Create a map entry for the notification's
+ context if it doesn't exist already, and note that notification's ID. Also, correct
+ the return value of show() if notifications are not enabled, to return false.
+ (WebKit::WebNotificationManager::didCloseNotifications): When the notification is closed,
+ we remove that notification from the map.
+ (WebKit::WebNotificationManager::clearNotifications): Use the map entry for the given
+ context, and pass that along to the proxy so that all of the notifications with those IDs
+ can be cleared. In the meantime, we remove that context's map entry.
+
+ * UIProcess/Notifications/WebNotificationManagerProxy.messages.in: New ClearNotifications()
+ message.
+ * UIProcess/Notifications/WebNotificationManagerProxy.h:
+ * UIProcess/Notifications/WebNotificationManagerProxy.cpp:
+ (WebKit::WebNotificationManagerProxy::clearNotifications): Forward the call to the provider.
+ Then remove this proxy's entries for the given notification IDs.
+
+ * UIProcess/Notifications/WebNotificationProvider.cpp:
+ (WebKit::WebNotificationProvider::clearNotifications): Convert the vector of IDs to a mutable
+ array.
+ * UIProcess/Notifications/WebNotificationProvider.h:
+ (WebNotificationProvider):
+
+ * UIProcess/API/C/WKNotificationProvider.h: Add WK API to tell the platform to clear the notifications.
+
+ Remove the #if guard since they already exist in WebNotificationManager functions:
+ * WebProcess/WebCoreSupport/WebNotificationClient.cpp:
+ (WebKit::WebNotificationClient::show):
+ (WebKit::WebNotificationClient::cancel):
+ (WebKit::WebNotificationClient::notificationObjectDestroyed):
+
2012-02-02 Anders Carlsson <[email protected]>
NPAPI will not send mouse up events when mouse is outside plugin area
Modified: trunk/Source/WebKit2/UIProcess/API/C/WKNotificationProvider.h (106591 => 106592)
--- trunk/Source/WebKit2/UIProcess/API/C/WKNotificationProvider.h 2012-02-02 21:55:08 UTC (rev 106591)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKNotificationProvider.h 2012-02-02 22:16:14 UTC (rev 106592)
@@ -38,6 +38,7 @@
typedef void (*WKNotificationProviderAddNotificationManagerCallback)(WKNotificationManagerRef manager, const void* clientInfo);
typedef void (*WKNotificationProviderRemoveNotificationManagerCallback)(WKNotificationManagerRef manager, const void* clientInfo);
typedef WKDictionaryRef (*WKNotificationProviderNotificationPermissionsCallback)(const void* clientInfo);
+typedef void (*WKNotificationProviderClearNotificationsCallback)(WKArrayRef notificationIDs, const void* clientInfo);
struct WKNotificationProvider {
int version;
@@ -48,6 +49,7 @@
WKNotificationProviderAddNotificationManagerCallback addNotificationManager;
WKNotificationProviderRemoveNotificationManagerCallback removeNotificationManager;
WKNotificationProviderNotificationPermissionsCallback notificationPermissions;
+ WKNotificationProviderClearNotificationsCallback clearNotifications;
};
typedef struct WKNotificationProvider WKNotificationProvider;
Modified: trunk/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.cpp (106591 => 106592)
--- trunk/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.cpp 2012-02-02 21:55:08 UTC (rev 106591)
+++ trunk/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.cpp 2012-02-02 22:16:14 UTC (rev 106592)
@@ -111,6 +111,14 @@
m_provider.didDestroyNotification(notification.get());
}
+void WebNotificationManagerProxy::clearNotifications(const Vector<uint64_t>& notificationIDs)
+{
+ m_provider.clearNotifications(notificationIDs);
+ size_t count = notificationIDs.size();
+ for (size_t i = 0; i < count; ++i)
+ m_notifications.remove(notificationIDs[i]);
+}
+
void WebNotificationManagerProxy::providerDidShowNotification(uint64_t notificationID)
{
if (!m_context)
Modified: trunk/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.h (106591 => 106592)
--- trunk/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.h 2012-02-02 21:55:08 UTC (rev 106591)
+++ trunk/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.h 2012-02-02 22:16:14 UTC (rev 106592)
@@ -80,6 +80,7 @@
// Message handlers
void cancel(uint64_t notificationID);
void didDestroyNotification(uint64_t notificationID);
+ void clearNotifications(const Vector<uint64_t>& notificationIDs);
typedef HashMap<uint64_t, RefPtr<WebNotification> > WebNotificationMap;
Modified: trunk/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.messages.in (106591 => 106592)
--- trunk/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.messages.in 2012-02-02 21:55:08 UTC (rev 106591)
+++ trunk/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.messages.in 2012-02-02 22:16:14 UTC (rev 106592)
@@ -23,4 +23,5 @@
messages -> WebNotificationManagerProxy {
Cancel(uint64_t notificationID);
DidDestroyNotification(uint64_t notificationID);
+ ClearNotifications(Vector<uint64_t> notificationIDs);
}
Modified: trunk/Source/WebKit2/UIProcess/Notifications/WebNotificationProvider.cpp (106591 => 106592)
--- trunk/Source/WebKit2/UIProcess/Notifications/WebNotificationProvider.cpp 2012-02-02 21:55:08 UTC (rev 106591)
+++ trunk/Source/WebKit2/UIProcess/Notifications/WebNotificationProvider.cpp 2012-02-02 22:16:14 UTC (rev 106592)
@@ -27,9 +27,11 @@
#include "WebNotificationProvider.h"
#include "ImmutableDictionary.h"
+#include "MutableArray.h"
#include "WKAPICast.h"
#include "WebNotification.h"
#include "WebNotificationManagerProxy.h"
+#include "WebNumber.h"
#include "WebSecurityOrigin.h"
namespace WebKit {
@@ -58,6 +60,20 @@
m_client.didDestroyNotification(toAPI(notification), m_client.clientInfo);
}
+void WebNotificationProvider::clearNotifications(const Vector<uint64_t>& notificationIDs)
+{
+ if (!m_client.clearNotifications)
+ return;
+
+ RefPtr<MutableArray> arrayIDs = MutableArray::create();
+ size_t count = notificationIDs.size();
+ arrayIDs->reserveCapacity(count);
+ for (size_t i = 0; i < count; ++i)
+ arrayIDs->append(WebUInt64::create(notificationIDs[i]).leakRef());
+
+ m_client.clearNotifications(toAPI(arrayIDs.get()), m_client.clientInfo);
+}
+
void WebNotificationProvider::addNotificationManager(WebNotificationManagerProxy* manager)
{
if (!m_client.addNotificationManager)
Modified: trunk/Source/WebKit2/UIProcess/Notifications/WebNotificationProvider.h (106591 => 106592)
--- trunk/Source/WebKit2/UIProcess/Notifications/WebNotificationProvider.h 2012-02-02 21:55:08 UTC (rev 106591)
+++ trunk/Source/WebKit2/UIProcess/Notifications/WebNotificationProvider.h 2012-02-02 22:16:14 UTC (rev 106592)
@@ -29,6 +29,7 @@
#include "APIClient.h"
#include "WKNotificationProvider.h"
#include <wtf/Forward.h>
+#include <wtf/Vector.h>
namespace WebKit {
@@ -43,6 +44,7 @@
void show(WebPageProxy*, WebNotification*);
void cancel(WebNotification*);
void didDestroyNotification(WebNotification*);
+ void clearNotifications(const Vector<uint64_t>& notificationIDs);
void addNotificationManager(WebNotificationManagerProxy*);
void removeNotificationManager(WebNotificationManagerProxy*);
Modified: trunk/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp (106591 => 106592)
--- trunk/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp 2012-02-02 21:55:08 UTC (rev 106591)
+++ trunk/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp 2012-02-02 22:16:14 UTC (rev 106592)
@@ -33,6 +33,7 @@
#include "WebNotification.h"
#include "WebNotificationManagerProxyMessages.h"
#include "WebPageProxyMessages.h"
+#include <WebCore/Document.h>
#include <WebCore/Notification.h>
#include <WebCore/Page.h>
#include <WebCore/ScriptExecutionContext.h>
@@ -113,9 +114,18 @@
m_notificationMap.set(notification, notificationID);
m_notificationIDMap.set(notificationID, notification);
+ NotificationContextMap::iterator it = m_notificationContextMap.find(notification->scriptExecutionContext());
+ if (it == m_notificationContextMap.end()) {
+ pair<NotificationContextMap::iterator, bool> addedPair = m_notificationContextMap.add(notification->scriptExecutionContext(), Vector<uint64_t>());
+ it = addedPair.first;
+ }
+ it->second.append(notificationID);
+
m_process->connection()->send(Messages::WebPageProxy::ShowNotification(notification->contents().title, notification->contents().body, notification->scriptExecutionContext()->securityOrigin()->toString(), notificationID), page->pageID());
+ return true;
+#else
+ return false;
#endif
- return true;
}
void WebNotificationManager::cancel(Notification* notification, WebPage* page)
@@ -132,6 +142,18 @@
#endif
}
+void WebNotificationManager::clearNotifications(WebCore::ScriptExecutionContext* context, WebPage* page)
+{
+#if ENABLE(NOTIFICATIONS)
+ NotificationContextMap::iterator it = m_notificationContextMap.find(context);
+ if (it == m_notificationContextMap.end())
+ return;
+
+ m_process->connection()->send(Messages::WebNotificationManagerProxy::ClearNotifications(it->second), page->pageID());
+ m_notificationContextMap.remove(it);
+#endif
+}
+
void WebNotificationManager::didDestroyNotification(Notification* notification, WebPage* page)
{
#if ENABLE(NOTIFICATIONS)
@@ -185,6 +207,12 @@
if (!notification)
continue;
+ NotificationContextMap::iterator it = m_notificationContextMap.find(notification->scriptExecutionContext());
+ ASSERT(it != m_notificationContextMap.end());
+ size_t index = it->second.find(notificationID);
+ ASSERT(index != notFound);
+ it->second.remove(index);
+
notification->dispatchCloseEvent();
}
#endif
Modified: trunk/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.h (106591 => 106592)
--- trunk/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.h 2012-02-02 21:55:08 UTC (rev 106591)
+++ trunk/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.h 2012-02-02 22:16:14 UTC (rev 106592)
@@ -59,6 +59,7 @@
bool show(WebCore::Notification*, WebPage*);
void cancel(WebCore::Notification*, WebPage*);
+ void clearNotifications(WebCore::ScriptExecutionContext*, WebPage*);
// This callback comes from WebCore, not messaged from the UI process.
void didDestroyNotification(WebCore::Notification*, WebPage*);
@@ -86,6 +87,9 @@
typedef HashMap<uint64_t, RefPtr<WebCore::Notification> > NotificationIDMap;
NotificationIDMap m_notificationIDMap;
+ typedef HashMap<RefPtr<WebCore::ScriptExecutionContext>, Vector<uint64_t> > NotificationContextMap;
+ NotificationContextMap m_notificationContextMap;
+
HashMap<String, bool> m_permissionsMap;
#endif
};
Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebNotificationClient.cpp (106591 => 106592)
--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebNotificationClient.cpp 2012-02-02 21:55:08 UTC (rev 106591)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebNotificationClient.cpp 2012-02-02 22:16:14 UTC (rev 106592)
@@ -32,7 +32,6 @@
#include "WebNotificationManager.h"
#include "WebPage.h"
#include "WebProcess.h"
-#include <WebCore/NotImplemented.h>
#include <WebCore/ScriptExecutionContext.h>
using namespace WebCore;
@@ -50,31 +49,22 @@
bool WebNotificationClient::show(Notification* notification)
{
-#if ENABLE(NOTIFICATIONS)
return WebProcess::shared().notificationManager().show(notification, m_page);
-#else
- notImplemented();
- return false;
-#endif
}
void WebNotificationClient::cancel(Notification* notification)
{
-#if ENABLE(NOTIFICATIONS)
WebProcess::shared().notificationManager().cancel(notification, m_page);
-#else
- notImplemented();
-#endif
}
+void WebNotificationClient::clearNotifications(ScriptExecutionContext* context)
+{
+ WebProcess::shared().notificationManager().clearNotifications(context, m_page);
+}
+
void WebNotificationClient::notificationObjectDestroyed(Notification* notification)
{
-#if ENABLE(NOTIFICATIONS)
WebProcess::shared().notificationManager().didDestroyNotification(notification, m_page);
-#else
- UNUSED_PARAM(notification);
- notImplemented();
-#endif
}
void WebNotificationClient::notificationControllerDestroyed()
Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebNotificationClient.h (106591 => 106592)
--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebNotificationClient.h 2012-02-02 21:55:08 UTC (rev 106591)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebNotificationClient.h 2012-02-02 22:16:14 UTC (rev 106592)
@@ -47,6 +47,7 @@
private:
virtual bool show(WebCore::Notification*) OVERRIDE;
virtual void cancel(WebCore::Notification*) OVERRIDE;
+ virtual void clearNotifications(WebCore::ScriptExecutionContext*) OVERRIDE;
virtual void notificationObjectDestroyed(WebCore::Notification*) OVERRIDE;
virtual void notificationControllerDestroyed() OVERRIDE;
virtual void requestPermission(WebCore::ScriptExecutionContext*, PassRefPtr<WebCore::VoidCallback>) OVERRIDE;