Clear shown notifications when context is no longer active
authorjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Feb 2012 22:16:14 +0000 (22:16 +0000)
committerjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Feb 2012 22:16:14 +0000 (22:16 +0000)
commit827668eb9a0993ff119802ebc18a473dd7ccb619
tree3870c003c6cff110d312d9baaaf83bd16e6ec04c
parentd0b2a34ff91d1210eb5955bad6db1e9c5bc9a1f1
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.

Source/WebCore:

* 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.

Source/WebKit/win:

* WebCoreSupport/WebDesktopNotificationsDelegate.h:
(WebDesktopNotificationsDelegate): Add previously missing virtual functions.
* WebCoreSupport/WebDesktopNotificationsDelegate.cpp:
(WebDesktopNotificationsDelegate::notificationControllerDestroyed):
(WebDesktopNotificationsDelegate::cancelRequestsForPermission):

Source/WebKit2:

* 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):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@106592 268f45cc-cd09-0410-ab3c-d52691b4dbfc
18 files changed:
Source/WebCore/ChangeLog
Source/WebCore/notifications/NotificationCenter.cpp
Source/WebCore/notifications/NotificationPresenter.h
Source/WebCore/page/Frame.cpp
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebCoreSupport/WebDesktopNotificationsDelegate.cpp
Source/WebKit/win/WebCoreSupport/WebDesktopNotificationsDelegate.h
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/C/WKNotificationProvider.h
Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.cpp
Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.h
Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.messages.in
Source/WebKit2/UIProcess/Notifications/WebNotificationProvider.cpp
Source/WebKit2/UIProcess/Notifications/WebNotificationProvider.h
Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp
Source/WebKit2/WebProcess/Notifications/WebNotificationManager.h
Source/WebKit2/WebProcess/WebCoreSupport/WebNotificationClient.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebNotificationClient.h