diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-02-03 09:55:33 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-02-03 09:55:33 +0100 |
commit | cd44dc59cdfc39534aef4d417e9f3c412e3be139 (patch) | |
tree | 8d89889ba95ed6ec9322e733846cc9cce9d7dff1 /Source/WebKit2/UIProcess/Notifications | |
parent | d11f84f5b5cdc0d92a08af01b13472fdd5f9acb9 (diff) | |
download | qtwebkit-cd44dc59cdfc39534aef4d417e9f3c412e3be139.tar.gz |
Imported WebKit commit fce473cb4d55aa9fe9d0b0322a2fffecb731b961 (http://svn.webkit.org/repository/webkit/trunk@106560)
Diffstat (limited to 'Source/WebKit2/UIProcess/Notifications')
7 files changed, 64 insertions, 35 deletions
diff --git a/Source/WebKit2/UIProcess/Notifications/WebNotification.cpp b/Source/WebKit2/UIProcess/Notifications/WebNotification.cpp index 7bb74432c..065bbbf7f 100644 --- a/Source/WebKit2/UIProcess/Notifications/WebNotification.cpp +++ b/Source/WebKit2/UIProcess/Notifications/WebNotification.cpp @@ -33,10 +33,10 @@ namespace WebKit { -WebNotification::WebNotification(const String& title, const String& body, const String& originIdentifier, uint64_t notificationID) +WebNotification::WebNotification(const String& title, const String& body, const String& originString, uint64_t notificationID) : m_title(title) , m_body(body) - , m_origin(WebSecurityOrigin::create(originIdentifier)) + , m_origin(WebSecurityOrigin::createFromString(originString)) , m_notificationID(notificationID) { } diff --git a/Source/WebKit2/UIProcess/Notifications/WebNotification.h b/Source/WebKit2/UIProcess/Notifications/WebNotification.h index 0b89a0aab..9447da427 100644 --- a/Source/WebKit2/UIProcess/Notifications/WebNotification.h +++ b/Source/WebKit2/UIProcess/Notifications/WebNotification.h @@ -45,9 +45,9 @@ class WebNotification : public APIObject { public: static const Type APIType = TypeNotification; - static PassRefPtr<WebNotification> create(const String& title, const String& body, const String& originIdentifier, uint64_t notificationID) + static PassRefPtr<WebNotification> create(const String& title, const String& body, const String& originString, uint64_t notificationID) { - return adoptRef(new WebNotification(title, body, originIdentifier, notificationID)); + return adoptRef(new WebNotification(title, body, originString, notificationID)); } const String& title() const { return m_title; } @@ -57,7 +57,7 @@ public: uint64_t notificationID() const { return m_notificationID; } private: - WebNotification(const String& title, const String& body, const String& originIdentifier, uint64_t notificationID); + WebNotification(const String& title, const String& body, const String& originString, uint64_t notificationID); virtual Type type() const { return APIType; } diff --git a/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.cpp b/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.cpp index 7d7c045db..e74ad07b7 100644 --- a/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.cpp +++ b/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.cpp @@ -27,6 +27,7 @@ #include "WebNotificationManagerProxy.h" #include "ImmutableArray.h" +#include "ImmutableDictionary.h" #include "WebContext.h" #include "WebNotification.h" #include "WebNotificationManagerMessages.h" @@ -57,26 +58,31 @@ void WebNotificationManagerProxy::invalidate() void WebNotificationManagerProxy::initializeProvider(const WKNotificationProvider *provider) { m_provider.initialize(provider); + m_provider.addNotificationManager(this); } -void WebNotificationManagerProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments) +void WebNotificationManagerProxy::populateCopyOfNotificationPermissions(HashMap<String, bool>& permissions) { - didReceiveWebNotificationManagerProxyMessage(connection, messageID, arguments); + RefPtr<ImmutableDictionary> knownPermissions = m_provider.notificationPermissions(); + permissions.clear(); + RefPtr<ImmutableArray> knownOrigins = knownPermissions->keys(); + for (size_t i = 0; i < knownOrigins->size(); ++i) { + WebString* origin = knownOrigins->at<WebString>(i); + permissions.set(origin->string(), knownPermissions->get<WebBoolean>(origin->string())->value()); + } } -void WebNotificationManagerProxy::didReceiveSyncMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments, OwnPtr<CoreIPC::ArgumentEncoder>& reply) +void WebNotificationManagerProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments) { - didReceiveSyncWebNotificationManagerProxyMessage(connection, messageID, arguments, reply); + didReceiveWebNotificationManagerProxyMessage(connection, messageID, arguments); } -void WebNotificationManagerProxy::show(WebPageProxy* page, const String& title, const String& body, const String& originIdentifier, uint64_t notificationID) +void WebNotificationManagerProxy::show(WebPageProxy* page, const String& title, const String& body, const String& originString, uint64_t notificationID) { if (!isNotificationIDValid(notificationID)) return; - m_provider.addNotificationManager(this); - - RefPtr<WebNotification> notification = WebNotification::create(title, body, originIdentifier, notificationID); + RefPtr<WebNotification> notification = WebNotification::create(title, body, originString, notificationID); m_notifications.set(notificationID, notification); m_provider.show(page, notification.get()); } @@ -90,7 +96,6 @@ void WebNotificationManagerProxy::cancel(uint64_t notificationID) if (!notification) return; - m_provider.addNotificationManager(this); m_provider.cancel(notification.get()); } @@ -106,12 +111,6 @@ void WebNotificationManagerProxy::didDestroyNotification(uint64_t notificationID m_provider.didDestroyNotification(notification.get()); } -void WebNotificationManagerProxy::notificationPermissionLevel(const String& originIdentifier, uint64_t& permissionLevel) -{ - RefPtr<WebSecurityOrigin> origin = WebSecurityOrigin::create(originIdentifier); - permissionLevel = m_provider.policyForNotificationPermissionAtOrigin(origin.get()); -} - void WebNotificationManagerProxy::providerDidShowNotification(uint64_t notificationID) { if (!m_context) @@ -148,4 +147,30 @@ void WebNotificationManagerProxy::providerDidCloseNotifications(ImmutableArray* m_context->sendToAllProcesses(Messages::WebNotificationManager::DidCloseNotifications(vectorNotificationIDs)); } +void WebNotificationManagerProxy::providerDidUpdateNotificationPolicy(const WebSecurityOrigin* origin, bool allowed) +{ + if (!m_context) + return; + + m_context->sendToAllProcesses(Messages::WebNotificationManager::DidUpdateNotificationDecision(origin->toString(), allowed)); +} + +void WebNotificationManagerProxy::providerDidRemoveNotificationPolicies(ImmutableArray* origins) +{ + if (!m_context) + return; + + size_t size = origins->size(); + if (!size) + return; + + Vector<String> originStrings; + originStrings.reserveInitialCapacity(size); + + for (size_t i = 0; i < size; ++i) + originStrings.append(origins->at<WebSecurityOrigin>(i)->toString()); + + m_context->sendToAllProcesses(Messages::WebNotificationManager::DidRemoveNotificationDecisions(originStrings)); +} + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.h b/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.h index 1705abcf4..8f4b9e9de 100644 --- a/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.h +++ b/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.h @@ -29,9 +29,11 @@ #include "APIObject.h" #include "MessageID.h" #include "WebNotificationProvider.h" +#include <WebCore/NotificationPresenter.h> #include <wtf/HashMap.h> #include <wtf/OwnPtr.h> #include <wtf/PassRefPtr.h> +#include <wtf/text/StringHash.h> namespace CoreIPC { class ArgumentDecoder; @@ -44,6 +46,7 @@ namespace WebKit { class ImmutableArray; class WebContext; class WebPageProxy; +class WebSecurityOrigin; class WebNotificationManagerProxy : public APIObject { public: @@ -55,15 +58,17 @@ public: void clearContext() { m_context = 0; } void initializeProvider(const WKNotificationProvider*); + void populateCopyOfNotificationPermissions(HashMap<String, bool>&); - void show(WebPageProxy*, const WTF::String& title, const WTF::String& body, const WTF::String& originIdentifier, uint64_t notificationID); + void show(WebPageProxy*, const String& title, const String& body, const String& originString, uint64_t notificationID); void providerDidShowNotification(uint64_t notificationID); void providerDidClickNotification(uint64_t notificationID); void providerDidCloseNotifications(ImmutableArray* notificationIDs); + void providerDidUpdateNotificationPolicy(const WebSecurityOrigin*, bool allowed); + void providerDidRemoveNotificationPolicies(ImmutableArray* origins); void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); - void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&); private: explicit WebNotificationManagerProxy(WebContext*); @@ -71,12 +76,10 @@ private: virtual Type type() const { return APIType; } void didReceiveWebNotificationManagerProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); - void didReceiveSyncWebNotificationManagerProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&); // Message handlers void cancel(uint64_t notificationID); void didDestroyNotification(uint64_t notificationID); - void notificationPermissionLevel(const WTF::String& originIdentifier, uint64_t& permissionLevel); typedef HashMap<uint64_t, RefPtr<WebNotification> > WebNotificationMap; diff --git a/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.messages.in b/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.messages.in index 04d1a01b1..a06fd0292 100644 --- a/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.messages.in +++ b/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.messages.in @@ -23,6 +23,4 @@ messages -> WebNotificationManagerProxy { Cancel(uint64_t notificationID); DidDestroyNotification(uint64_t notificationID); - - NotificationPermissionLevel(WTF::String originIdentifier) -> (uint64_t policy) } diff --git a/Source/WebKit2/UIProcess/Notifications/WebNotificationProvider.cpp b/Source/WebKit2/UIProcess/Notifications/WebNotificationProvider.cpp index 080aea666..afd13bccd 100644 --- a/Source/WebKit2/UIProcess/Notifications/WebNotificationProvider.cpp +++ b/Source/WebKit2/UIProcess/Notifications/WebNotificationProvider.cpp @@ -26,6 +26,7 @@ #include "config.h" #include "WebNotificationProvider.h" +#include "ImmutableDictionary.h" #include "WKAPICast.h" #include "WebNotification.h" #include "WebNotificationManagerProxy.h" @@ -57,14 +58,6 @@ void WebNotificationProvider::didDestroyNotification(WebNotification* notificati m_client.didDestroyNotification(toAPI(notification), m_client.clientInfo); } -int WebNotificationProvider::policyForNotificationPermissionAtOrigin(WebSecurityOrigin* origin) -{ - if (!m_client.policyForNotificationPermissionAtOrigin) - return INT_MIN; - - return m_client.policyForNotificationPermissionAtOrigin(toAPI(origin), m_client.clientInfo); -} - void WebNotificationProvider::addNotificationManager(WebNotificationManagerProxy* manager) { if (!m_client.addNotificationManager) @@ -81,4 +74,12 @@ void WebNotificationProvider::removeNotificationManager(WebNotificationManagerPr m_client.removeNotificationManager(toAPI(manager), m_client.clientInfo); } +PassRefPtr<ImmutableDictionary> WebNotificationProvider::notificationPermissions() +{ + if (!m_client.notificationPermissions) + return ImmutableDictionary::create(); + + return adoptRef(toImpl(m_client.notificationPermissions(m_client.clientInfo))); +} + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/Notifications/WebNotificationProvider.h b/Source/WebKit2/UIProcess/Notifications/WebNotificationProvider.h index 43d963919..8503ee27c 100644 --- a/Source/WebKit2/UIProcess/Notifications/WebNotificationProvider.h +++ b/Source/WebKit2/UIProcess/Notifications/WebNotificationProvider.h @@ -32,6 +32,7 @@ namespace WebKit { +class ImmutableDictionary; class WebNotification; class WebNotificationManagerProxy; class WebPageProxy; @@ -42,10 +43,11 @@ public: void show(WebPageProxy*, WebNotification*); void cancel(WebNotification*); void didDestroyNotification(WebNotification*); - int policyForNotificationPermissionAtOrigin(WebSecurityOrigin*); void addNotificationManager(WebNotificationManagerProxy*); void removeNotificationManager(WebNotificationManagerProxy*); + + PassRefPtr<ImmutableDictionary> notificationPermissions(); }; } // namespace WebKit |