Changeset 106592 in webkit
- Timestamp:
- Feb 2, 2012 2:16:14 PM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r106588 r106592 1 2012-02-02 Jon Lee <jonlee@apple.com> 2 3 Clear shown notifications when context is no longer active 4 https://bugs.webkit.org/show_bug.cgi?id=77363 5 <rdar://problem/10568907> 6 7 Reviewed by Darin Adler. 8 9 * notifications/NotificationPresenter.h: Add new virtual function to clear notifications 10 associated with a given execution context. By default the notifications are left alone, as 11 before. Individual implementations can override to allow notifications to clear them. 12 13 * notifications/NotificationCenter.cpp: 14 (WebCore::NotificationCenter::disconnectFrame): When disconnecting the page from the frame, we 15 call clearNotifications(). 16 * page/Frame.cpp: 17 (WebCore::Frame::pageDestroyed): When the page is destroyed, tell the DOM window to reset notifications. 18 1 19 2012-02-02 Anders Carlsson <andersca@apple.com> 2 20 -
trunk/Source/WebCore/notifications/NotificationCenter.cpp
r97667 r106592 67 67 return; 68 68 m_notificationPresenter->cancelRequestsForPermission(scriptExecutionContext()); 69 m_notificationPresenter->clearNotifications(scriptExecutionContext()); 69 70 m_notificationPresenter = 0; 70 71 } -
trunk/Source/WebCore/notifications/NotificationPresenter.h
r103975 r106592 58 58 virtual void cancel(Notification*) = 0; 59 59 60 // When the user closes a page, or quits the client application, all of the page's 61 // associated notifications are cleared. 62 virtual void clearNotifications(ScriptExecutionContext*) { } 63 60 64 // Informs the presenter that a Notification object has been destroyed 61 65 // (such as by a page transition). The presenter may continue showing -
trunk/Source/WebCore/page/Frame.cpp
r104372 r106592 669 669 if (m_domWindow) { 670 670 m_domWindow->resetGeolocation(); 671 #if ENABLE(NOTIFICATIONS) 672 m_domWindow->resetNotifications(); 673 #endif 671 674 m_domWindow->pageDestroyed(); 672 675 } -
trunk/Source/WebKit/win/ChangeLog
r106513 r106592 1 2012-02-02 Jon Lee <jonlee@apple.com> 2 3 Clear shown notifications when context is no longer active 4 https://bugs.webkit.org/show_bug.cgi?id=77363 5 <rdar://problem/10568907> 6 7 Reviewed by Darin Adler. 8 9 * WebCoreSupport/WebDesktopNotificationsDelegate.h: 10 (WebDesktopNotificationsDelegate): Add previously missing virtual functions. 11 * WebCoreSupport/WebDesktopNotificationsDelegate.cpp: 12 (WebDesktopNotificationsDelegate::notificationControllerDestroyed): 13 (WebDesktopNotificationsDelegate::cancelRequestsForPermission): 14 1 15 2012-02-01 Anders Carlsson <andersca@apple.com> 2 16 -
trunk/Source/WebKit/win/WebCoreSupport/WebDesktopNotificationsDelegate.cpp
r82120 r106592 166 166 } 167 167 168 void WebDesktopNotificationsDelegate::notificationControllerDestroyed() 169 { 170 } 171 168 172 void WebDesktopNotificationsDelegate::requestPermission(SecurityOrigin* origin, PassRefPtr<VoidCallback> callback) 169 173 { … … 171 175 if (hasNotificationDelegate()) 172 176 notificationDelegate()->requestNotificationPermission(org); 177 } 178 179 void WebDesktopNotificationsDelegate::cancelRequestsForPermission(ScriptExecutionContext* context) 180 { 173 181 } 174 182 -
trunk/Source/WebKit/win/WebCoreSupport/WebDesktopNotificationsDelegate.h
r82120 r106592 50 50 virtual void cancel(WebCore::Notification* object); 51 51 virtual void notificationObjectDestroyed(WebCore::Notification* object); 52 virtual void notificationControllerDestroyed(); 52 53 virtual void requestPermission(WebCore::SecurityOrigin* origin, PassRefPtr<WebCore::VoidCallback> callback); 54 virtual void cancelRequestsForPermission(WebCore::ScriptExecutionContext*); 53 55 virtual WebCore::NotificationPresenter::Permission checkPermission(const KURL& url); 54 56 -
trunk/Source/WebKit2/ChangeLog
r106572 r106592 1 2012-02-02 Jon Lee <jonlee@apple.com> 2 3 Clear shown notifications when context is no longer active 4 https://bugs.webkit.org/show_bug.cgi?id=77363 5 <rdar://problem/10568907> 6 7 Reviewed by Darin Adler. 8 9 * WebProcess/WebCoreSupport/WebNotificationClient.cpp: 10 (WebKit::WebNotificationClient::clearNotifications): Forward the call to 11 WebNotificationManager. 12 * WebProcess/WebCoreSupport/WebNotificationClient.h: 13 (WebNotificationClient): 14 15 * WebProcess/Notifications/WebNotificationManager.h: Add an additional map that maps 16 all notifications associated with a given ScriptExecutionContext instance. 17 * WebProcess/Notifications/WebNotificationManager.cpp: 18 (WebKit::WebNotificationManager::show): Create a map entry for the notification's 19 context if it doesn't exist already, and note that notification's ID. Also, correct 20 the return value of show() if notifications are not enabled, to return false. 21 (WebKit::WebNotificationManager::didCloseNotifications): When the notification is closed, 22 we remove that notification from the map. 23 (WebKit::WebNotificationManager::clearNotifications): Use the map entry for the given 24 context, and pass that along to the proxy so that all of the notifications with those IDs 25 can be cleared. In the meantime, we remove that context's map entry. 26 27 * UIProcess/Notifications/WebNotificationManagerProxy.messages.in: New ClearNotifications() 28 message. 29 * UIProcess/Notifications/WebNotificationManagerProxy.h: 30 * UIProcess/Notifications/WebNotificationManagerProxy.cpp: 31 (WebKit::WebNotificationManagerProxy::clearNotifications): Forward the call to the provider. 32 Then remove this proxy's entries for the given notification IDs. 33 34 * UIProcess/Notifications/WebNotificationProvider.cpp: 35 (WebKit::WebNotificationProvider::clearNotifications): Convert the vector of IDs to a mutable 36 array. 37 * UIProcess/Notifications/WebNotificationProvider.h: 38 (WebNotificationProvider): 39 40 * UIProcess/API/C/WKNotificationProvider.h: Add WK API to tell the platform to clear the notifications. 41 42 Remove the #if guard since they already exist in WebNotificationManager functions: 43 * WebProcess/WebCoreSupport/WebNotificationClient.cpp: 44 (WebKit::WebNotificationClient::show): 45 (WebKit::WebNotificationClient::cancel): 46 (WebKit::WebNotificationClient::notificationObjectDestroyed): 47 1 48 2012-02-02 Anders Carlsson <andersca@apple.com> 2 49 -
trunk/Source/WebKit2/UIProcess/API/C/WKNotificationProvider.h
r105364 r106592 39 39 typedef void (*WKNotificationProviderRemoveNotificationManagerCallback)(WKNotificationManagerRef manager, const void* clientInfo); 40 40 typedef WKDictionaryRef (*WKNotificationProviderNotificationPermissionsCallback)(const void* clientInfo); 41 typedef void (*WKNotificationProviderClearNotificationsCallback)(WKArrayRef notificationIDs, const void* clientInfo); 41 42 42 43 struct WKNotificationProvider { … … 49 50 WKNotificationProviderRemoveNotificationManagerCallback removeNotificationManager; 50 51 WKNotificationProviderNotificationPermissionsCallback notificationPermissions; 52 WKNotificationProviderClearNotificationsCallback clearNotifications; 51 53 }; 52 54 typedef struct WKNotificationProvider WKNotificationProvider; -
trunk/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.cpp
r105364 r106592 112 112 } 113 113 114 void WebNotificationManagerProxy::clearNotifications(const Vector<uint64_t>& notificationIDs) 115 { 116 m_provider.clearNotifications(notificationIDs); 117 size_t count = notificationIDs.size(); 118 for (size_t i = 0; i < count; ++i) 119 m_notifications.remove(notificationIDs[i]); 120 } 121 114 122 void WebNotificationManagerProxy::providerDidShowNotification(uint64_t notificationID) 115 123 { -
trunk/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.h
r105364 r106592 81 81 void cancel(uint64_t notificationID); 82 82 void didDestroyNotification(uint64_t notificationID); 83 void clearNotifications(const Vector<uint64_t>& notificationIDs); 83 84 84 85 typedef HashMap<uint64_t, RefPtr<WebNotification> > WebNotificationMap; -
trunk/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.messages.in
r105364 r106592 24 24 Cancel(uint64_t notificationID); 25 25 DidDestroyNotification(uint64_t notificationID); 26 ClearNotifications(Vector<uint64_t> notificationIDs); 26 27 } -
trunk/Source/WebKit2/UIProcess/Notifications/WebNotificationProvider.cpp
r105364 r106592 28 28 29 29 #include "ImmutableDictionary.h" 30 #include "MutableArray.h" 30 31 #include "WKAPICast.h" 31 32 #include "WebNotification.h" 32 33 #include "WebNotificationManagerProxy.h" 34 #include "WebNumber.h" 33 35 #include "WebSecurityOrigin.h" 34 36 … … 59 61 } 60 62 63 void WebNotificationProvider::clearNotifications(const Vector<uint64_t>& notificationIDs) 64 { 65 if (!m_client.clearNotifications) 66 return; 67 68 RefPtr<MutableArray> arrayIDs = MutableArray::create(); 69 size_t count = notificationIDs.size(); 70 arrayIDs->reserveCapacity(count); 71 for (size_t i = 0; i < count; ++i) 72 arrayIDs->append(WebUInt64::create(notificationIDs[i]).leakRef()); 73 74 m_client.clearNotifications(toAPI(arrayIDs.get()), m_client.clientInfo); 75 } 76 61 77 void WebNotificationProvider::addNotificationManager(WebNotificationManagerProxy* manager) 62 78 { -
trunk/Source/WebKit2/UIProcess/Notifications/WebNotificationProvider.h
r105364 r106592 30 30 #include "WKNotificationProvider.h" 31 31 #include <wtf/Forward.h> 32 #include <wtf/Vector.h> 32 33 33 34 namespace WebKit { … … 44 45 void cancel(WebNotification*); 45 46 void didDestroyNotification(WebNotification*); 47 void clearNotifications(const Vector<uint64_t>& notificationIDs); 46 48 47 49 void addNotificationManager(WebNotificationManagerProxy*); -
trunk/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp
r105367 r106592 34 34 #include "WebNotificationManagerProxyMessages.h" 35 35 #include "WebPageProxyMessages.h" 36 #include <WebCore/Document.h> 36 37 #include <WebCore/Notification.h> 37 38 #include <WebCore/Page.h> … … 114 115 m_notificationIDMap.set(notificationID, notification); 115 116 117 NotificationContextMap::iterator it = m_notificationContextMap.find(notification->scriptExecutionContext()); 118 if (it == m_notificationContextMap.end()) { 119 pair<NotificationContextMap::iterator, bool> addedPair = m_notificationContextMap.add(notification->scriptExecutionContext(), Vector<uint64_t>()); 120 it = addedPair.first; 121 } 122 it->second.append(notificationID); 123 116 124 m_process->connection()->send(Messages::WebPageProxy::ShowNotification(notification->contents().title, notification->contents().body, notification->scriptExecutionContext()->securityOrigin()->toString(), notificationID), page->pageID()); 117 #endif118 125 return true; 126 #else 127 return false; 128 #endif 119 129 } 120 130 … … 130 140 131 141 m_process->connection()->send(Messages::WebNotificationManagerProxy::Cancel(notificationID), page->pageID()); 142 #endif 143 } 144 145 void WebNotificationManager::clearNotifications(WebCore::ScriptExecutionContext* context, WebPage* page) 146 { 147 #if ENABLE(NOTIFICATIONS) 148 NotificationContextMap::iterator it = m_notificationContextMap.find(context); 149 if (it == m_notificationContextMap.end()) 150 return; 151 152 m_process->connection()->send(Messages::WebNotificationManagerProxy::ClearNotifications(it->second), page->pageID()); 153 m_notificationContextMap.remove(it); 132 154 #endif 133 155 } … … 186 208 continue; 187 209 210 NotificationContextMap::iterator it = m_notificationContextMap.find(notification->scriptExecutionContext()); 211 ASSERT(it != m_notificationContextMap.end()); 212 size_t index = it->second.find(notificationID); 213 ASSERT(index != notFound); 214 it->second.remove(index); 215 188 216 notification->dispatchCloseEvent(); 189 217 } -
trunk/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.h
r105364 r106592 60 60 bool show(WebCore::Notification*, WebPage*); 61 61 void cancel(WebCore::Notification*, WebPage*); 62 void clearNotifications(WebCore::ScriptExecutionContext*, WebPage*); 62 63 // This callback comes from WebCore, not messaged from the UI process. 63 64 void didDestroyNotification(WebCore::Notification*, WebPage*); … … 87 88 NotificationIDMap m_notificationIDMap; 88 89 90 typedef HashMap<RefPtr<WebCore::ScriptExecutionContext>, Vector<uint64_t> > NotificationContextMap; 91 NotificationContextMap m_notificationContextMap; 92 89 93 HashMap<String, bool> m_permissionsMap; 90 94 #endif -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebNotificationClient.cpp
r103975 r106592 33 33 #include "WebPage.h" 34 34 #include "WebProcess.h" 35 #include <WebCore/NotImplemented.h>36 35 #include <WebCore/ScriptExecutionContext.h> 37 36 … … 51 50 bool WebNotificationClient::show(Notification* notification) 52 51 { 53 #if ENABLE(NOTIFICATIONS)54 52 return WebProcess::shared().notificationManager().show(notification, m_page); 55 #else56 notImplemented();57 return false;58 #endif59 53 } 60 54 61 55 void WebNotificationClient::cancel(Notification* notification) 62 56 { 63 #if ENABLE(NOTIFICATIONS)64 57 WebProcess::shared().notificationManager().cancel(notification, m_page); 65 #else 66 notImplemented(); 67 #endif 58 } 59 60 void WebNotificationClient::clearNotifications(ScriptExecutionContext* context) 61 { 62 WebProcess::shared().notificationManager().clearNotifications(context, m_page); 68 63 } 69 64 70 65 void WebNotificationClient::notificationObjectDestroyed(Notification* notification) 71 66 { 72 #if ENABLE(NOTIFICATIONS)73 67 WebProcess::shared().notificationManager().didDestroyNotification(notification, m_page); 74 #else75 UNUSED_PARAM(notification);76 notImplemented();77 #endif78 68 } 79 69 -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebNotificationClient.h
r103975 r106592 48 48 virtual bool show(WebCore::Notification*) OVERRIDE; 49 49 virtual void cancel(WebCore::Notification*) OVERRIDE; 50 virtual void clearNotifications(WebCore::ScriptExecutionContext*) OVERRIDE; 50 51 virtual void notificationObjectDestroyed(WebCore::Notification*) OVERRIDE; 51 52 virtual void notificationControllerDestroyed() OVERRIDE;
Note: See TracChangeset
for help on using the changeset viewer.