diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-05-07 11:21:11 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-05-07 11:21:11 +0200 |
commit | 2cf6c8816a73e0132bd8fa3b509d62d7c51b6e47 (patch) | |
tree | 988e8c5b116dd0466244ae2fe5af8ee9be926d76 /Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp | |
parent | dd91e772430dc294e3bf478c119ef8d43c0a3358 (diff) | |
download | qtwebkit-2cf6c8816a73e0132bd8fa3b509d62d7c51b6e47.tar.gz |
Imported WebKit commit 7e538425aa020340619e927792f3d895061fb54b (http://svn.webkit.org/repository/webkit/trunk@116286)
Diffstat (limited to 'Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp')
-rw-r--r-- | Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp b/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp index 9e5cf9546..2d667ef5e 100644 --- a/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp +++ b/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp @@ -29,7 +29,7 @@ #include "WebPage.h" #include "WebProcess.h" -#if ENABLE(NOTIFICATIONS) +#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) #include "WebNotification.h" #include "WebNotificationManagerProxyMessages.h" #include "WebPageProxyMessages.h" @@ -45,7 +45,7 @@ using namespace WebCore; namespace WebKit { -#if ENABLE(NOTIFICATIONS) +#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) static uint64_t generateNotificationID() { static uint64_t uniqueNotificationID = 1; @@ -69,21 +69,21 @@ void WebNotificationManager::didReceiveMessage(CoreIPC::Connection* connection, void WebNotificationManager::initialize(const HashMap<String, bool>& permissions) { -#if ENABLE(NOTIFICATIONS) +#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) m_permissionsMap = permissions; #endif } void WebNotificationManager::didUpdateNotificationDecision(const String& originString, bool allowed) { -#if ENABLE(NOTIFICATIONS) +#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) m_permissionsMap.set(originString, allowed); #endif } void WebNotificationManager::didRemoveNotificationDecisions(const Vector<String>& originStrings) { -#if ENABLE(NOTIFICATIONS) +#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) size_t count = originStrings.size(); for (size_t i = 0; i < count; ++i) m_permissionsMap.remove(originStrings[i]); @@ -92,11 +92,12 @@ void WebNotificationManager::didRemoveNotificationDecisions(const Vector<String> NotificationClient::Permission WebNotificationManager::policyForOrigin(WebCore::SecurityOrigin *origin) const { -#if ENABLE(NOTIFICATIONS) +#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) if (!origin) return NotificationClient::PermissionNotAllowed; - - HashMap<String, bool>::const_iterator it = m_permissionsMap.find(origin->toString()); + + ASSERT(!origin->isUnique()); + HashMap<String, bool>::const_iterator it = m_permissionsMap.find(origin->toRawString()); if (it != m_permissionsMap.end()) return it->second ? NotificationClient::PermissionAllowed : NotificationClient::PermissionDenied; #endif @@ -106,18 +107,22 @@ NotificationClient::Permission WebNotificationManager::policyForOrigin(WebCore:: bool WebNotificationManager::show(Notification* notification, WebPage* page) { -#if ENABLE(NOTIFICATIONS) +#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) if (!notification || !page->corePage()->settings()->notificationsEnabled()) - return true; + return false; uint64_t notificationID = generateNotificationID(); m_notificationMap.set(notification, notificationID); m_notificationIDMap.set(notificationID, notification); - NotificationContextMap::iterator it = m_notificationContextMap.add(notification->scriptExecutionContext(), Vector<uint64_t>()).first; + NotificationContextMap::iterator it = m_notificationContextMap.add(notification->scriptExecutionContext(), Vector<uint64_t>()).iterator; it->second.append(notificationID); - - m_process->connection()->send(Messages::WebPageProxy::ShowNotification(notification->contents().title, notification->contents().body, notification->iconURL().string(), notification->replaceId(), notification->scriptExecutionContext()->securityOrigin()->toString(), notificationID), page->pageID()); + +#if ENABLE(NOTIFICATIONS) + m_process->connection()->send(Messages::WebPageProxy::ShowNotification(notification->title(), notification->body(), notification->iconURL().string(), notification->tag(), notification->scriptExecutionContext()->securityOrigin()->toString(), notificationID), page->pageID()); +#else + m_process->connection()->send(Messages::WebPageProxy::ShowNotification(notification->title(), notification->body(), notification->iconURL().string(), notification->replaceId(), notification->scriptExecutionContext()->securityOrigin()->toString(), notificationID), page->pageID()); +#endif return true; #else return false; @@ -126,7 +131,7 @@ bool WebNotificationManager::show(Notification* notification, WebPage* page) void WebNotificationManager::cancel(Notification* notification, WebPage* page) { -#if ENABLE(NOTIFICATIONS) +#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) if (!notification || !page->corePage()->settings()->notificationsEnabled()) return; @@ -140,7 +145,7 @@ void WebNotificationManager::cancel(Notification* notification, WebPage* page) void WebNotificationManager::clearNotifications(WebCore::ScriptExecutionContext* context, WebPage* page) { -#if ENABLE(NOTIFICATIONS) +#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) NotificationContextMap::iterator it = m_notificationContextMap.find(context); if (it == m_notificationContextMap.end()) return; @@ -152,6 +157,7 @@ void WebNotificationManager::clearNotifications(WebCore::ScriptExecutionContext* RefPtr<Notification> notification = m_notificationIDMap.take(notificationIDs[i]); if (!notification) continue; + notification->finalize(); m_notificationMap.remove(notification); } @@ -161,7 +167,7 @@ void WebNotificationManager::clearNotifications(WebCore::ScriptExecutionContext* void WebNotificationManager::didDestroyNotification(Notification* notification, WebPage* page) { -#if ENABLE(NOTIFICATIONS) +#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) uint64_t notificationID = m_notificationMap.take(notification); if (!notificationID) return; @@ -174,7 +180,7 @@ void WebNotificationManager::didDestroyNotification(Notification* notification, void WebNotificationManager::didShowNotification(uint64_t notificationID) { -#if ENABLE(NOTIFICATIONS) +#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) if (!isNotificationIDValid(notificationID)) return; @@ -188,7 +194,7 @@ void WebNotificationManager::didShowNotification(uint64_t notificationID) void WebNotificationManager::didClickNotification(uint64_t notificationID) { -#if ENABLE(NOTIFICATIONS) +#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) if (!isNotificationIDValid(notificationID)) return; @@ -202,7 +208,7 @@ void WebNotificationManager::didClickNotification(uint64_t notificationID) void WebNotificationManager::didCloseNotifications(const Vector<uint64_t>& notificationIDs) { -#if ENABLE(NOTIFICATIONS) +#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) size_t count = notificationIDs.size(); for (size_t i = 0; i < count; ++i) { uint64_t notificationID = notificationIDs[i]; @@ -221,7 +227,7 @@ void WebNotificationManager::didCloseNotifications(const Vector<uint64_t>& notif #endif } -#if ENABLE(NOTIFICATIONS) +#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) void WebNotificationManager::removeNotificationFromContextMap(uint64_t notificationID, Notification* notification) { // This is a helper function for managing the hash maps. |