diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-02-09 14:16:12 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-02-09 14:16:12 +0100 |
commit | 03e12282df9aa1e1fb05a8b90f1cfc2e08764cec (patch) | |
tree | 52599cd0ab782b1768e23ad176f7618f98333cb6 /Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp | |
parent | cd44dc59cdfc39534aef4d417e9f3c412e3be139 (diff) | |
download | qtwebkit-03e12282df9aa1e1fb05a8b90f1cfc2e08764cec.tar.gz |
Imported WebKit commit e09a82039aa4273ab318b71122e92d8e5f233525 (http://svn.webkit.org/repository/webkit/trunk@107223)
Diffstat (limited to 'Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp')
-rw-r--r-- | Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp b/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp index 0c865292d..84b52c2ac 100644 --- a/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp +++ b/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp @@ -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 @@ bool WebNotificationManager::show(Notification* notification, WebPage* page) m_notificationMap.set(notification, notificationID); m_notificationIDMap.set(notificationID, notification); - m_process->connection()->send(Messages::WebPageProxy::ShowNotification(notification->contents().title, notification->contents().body, notification->scriptExecutionContext()->securityOrigin()->toString(), notificationID), page->pageID()); -#endif + 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->iconURL().string(), notification->scriptExecutionContext()->securityOrigin()->toString(), notificationID), page->pageID()); return true; +#else + return false; +#endif } void WebNotificationManager::cancel(Notification* notification, WebPage* page) @@ -132,6 +142,18 @@ void WebNotificationManager::cancel(Notification* notification, WebPage* page) #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 @@ void WebNotificationManager::didCloseNotifications(const Vector<uint64_t>& notif 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 |