[WK2] Extend WebNotification to include its origin https://bugs.webkit.org/show_bug...
authorjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Dec 2011 18:44:43 +0000 (18:44 +0000)
committerjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Dec 2011 18:44:43 +0000 (18:44 +0000)
Reviewed by Sam Weinig.

* Shared/API/c/WKSecurityOrigin.h: Expose API that converts the security origin to database
identifier.
* Shared/API/c/WKSecurityOrigin.cpp:
(WKSecurityOriginCopyDatabaseIdentifier):

* UIProcess/Notifications/WebNotification.h: Extend WebNotification to include the origin.
(WebKit::WebNotification::create):
(WebKit::WebNotification::origin):
* UIProcess/Notifications/WebNotification.cpp: Remove unneeded encode() and decode() functions.
(WebKit::WebNotification::WebNotification):

* UIProcess/API/C/WKNotification.h: Expose WebNotification's origin().
* UIProcess/API/C/WKNotification.cpp:
(WKNotificationGetSecurityOrigin):

* UIProcess/Notifications/WebNotificationManagerProxy.messages.in: Update show() to include the
origin of the notification.
* UIProcess/Notifications/WebNotificationManagerProxy.cpp:
(WebKit::WebNotificationManagerProxy::show):
* UIProcess/Notifications/WebNotificationManagerProxy.h:
* WebProcess/Notifications/WebNotificationManager.cpp:
(WebKit::WebNotificationManager::show): Pass the notification's exec context's origin as
identifier.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@102960 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/Shared/API/c/WKSecurityOrigin.cpp
Source/WebKit2/Shared/API/c/WKSecurityOrigin.h
Source/WebKit2/UIProcess/API/C/WKNotification.cpp
Source/WebKit2/UIProcess/API/C/WKNotification.h
Source/WebKit2/UIProcess/Notifications/WebNotification.cpp
Source/WebKit2/UIProcess/Notifications/WebNotification.h
Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.cpp
Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.h
Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.messages.in
Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp

index 93a8e91..9356d19 100644 (file)
@@ -1,3 +1,35 @@
+2011-12-15  Jon Lee  <jonlee@apple.com>
+
+        [WK2] Extend WebNotification to include its origin
+        https://bugs.webkit.org/show_bug.cgi?id=74615
+        <rdar://problem/10587164>
+
+        Reviewed by Sam Weinig.
+
+        * Shared/API/c/WKSecurityOrigin.h: Expose API that converts the security origin to database
+        identifier.
+        * Shared/API/c/WKSecurityOrigin.cpp:
+        (WKSecurityOriginCopyDatabaseIdentifier):
+
+        * UIProcess/Notifications/WebNotification.h: Extend WebNotification to include the origin.
+        (WebKit::WebNotification::create):
+        (WebKit::WebNotification::origin):
+        * UIProcess/Notifications/WebNotification.cpp: Remove unneeded encode() and decode() functions.
+        (WebKit::WebNotification::WebNotification):
+
+        * UIProcess/API/C/WKNotification.h: Expose WebNotification's origin().
+        * UIProcess/API/C/WKNotification.cpp:
+        (WKNotificationGetSecurityOrigin):
+
+        * UIProcess/Notifications/WebNotificationManagerProxy.messages.in: Update show() to include the
+        origin of the notification.
+        * UIProcess/Notifications/WebNotificationManagerProxy.cpp:
+        (WebKit::WebNotificationManagerProxy::show):
+        * UIProcess/Notifications/WebNotificationManagerProxy.h:
+        * WebProcess/Notifications/WebNotificationManager.cpp:
+        (WebKit::WebNotificationManager::show): Pass the notification's exec context's origin as
+        identifier.
+
 2011-12-15  Rafael Brandao  <rafael.lobo@openbossa.org>
 
         [Qt][WK2] Add test for download policy on navigation request
index f9c519a..cf7624f 100644 (file)
@@ -48,6 +48,11 @@ WKSecurityOriginRef WKSecurityOriginCreate(WKStringRef protocol, WKStringRef hos
     return toAPI(securityOrigin.release().leakRef());
 }
 
+WKStringRef WKSecurityOriginCopyDatabaseIdentifier(WKSecurityOriginRef securityOrigin)
+{
+    return toCopiedAPI(toImpl(securityOrigin)->databaseIdentifier());
+}
+
 WKStringRef WKSecurityOriginCopyProtocol(WKSecurityOriginRef securityOrigin)
 {
     return toCopiedAPI(toImpl(securityOrigin)->protocol());
index 04c08de..29040d8 100644 (file)
@@ -37,6 +37,7 @@ WK_EXPORT WKTypeID WKSecurityOriginGetTypeID();
 WK_EXPORT WKSecurityOriginRef WKSecurityOriginCreateFromIdentifier(WKStringRef identifier);
 WK_EXPORT WKSecurityOriginRef WKSecurityOriginCreate(WKStringRef protocol, WKStringRef host, int port);
 
+WK_EXPORT WKStringRef WKSecurityOriginCopyDatabaseIdentifier(WKSecurityOriginRef securityOrigin);
 WK_EXPORT WKStringRef WKSecurityOriginCopyProtocol(WKSecurityOriginRef securityOrigin);
 WK_EXPORT WKStringRef WKSecurityOriginCopyHost(WKSecurityOriginRef securityOrigin);
 WK_EXPORT unsigned short WKSecurityOriginGetPort(WKSecurityOriginRef securityOrigin);
index 088e773..db7d1f0 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "WKAPICast.h"
 #include "WebNotification.h"
+#include "WebSecurityOrigin.h"
 
 using namespace WebKit;
 
@@ -46,6 +47,11 @@ WKStringRef WKNotificationCopyBody(WKNotificationRef notification)
     return toCopiedAPI(toImpl(notification)->body());
 }
 
+WKSecurityOriginRef WKNotificationGetSecurityOrigin(WKNotificationRef notification)
+{
+    return toAPI(toImpl(notification)->origin());
+}
+
 uint64_t WKNotificationGetID(WKNotificationRef notification)
 {
     return toImpl(notification)->notificationID();
index d395f5d..07311af 100644 (file)
@@ -36,6 +36,7 @@ WK_EXPORT WKTypeID WKNotificationGetTypeID();
 
 WK_EXPORT WKStringRef WKNotificationCopyTitle(WKNotificationRef notification);
 WK_EXPORT WKStringRef WKNotificationCopyBody(WKNotificationRef notification);
+WK_EXPORT WKSecurityOriginRef WKNotificationGetSecurityOrigin(WKNotificationRef notification);
 WK_EXPORT uint64_t WKNotificationGetID(WKNotificationRef notification);
 
 #ifdef __cplusplus
index 05f8b71..7bb7443 100644 (file)
 
 namespace WebKit {
 
-WebNotification::WebNotification(const String& title, const String& body, uint64_t notificationID)
+WebNotification::WebNotification(const String& title, const String& body, const String& originIdentifier, uint64_t notificationID)
     : m_title(title)
     , m_body(body)
+    , m_origin(WebSecurityOrigin::create(originIdentifier))
     , m_notificationID(notificationID)
 {
 }
 
-void WebNotification::encode(CoreIPC::ArgumentEncoder* encoder) const
-{
-    encoder->encode(CoreIPC::In(m_title, m_body, m_notificationID));
-}
-
-bool WebNotification::decode(CoreIPC::ArgumentDecoder* decoder, WebNotification& notification)
-{
-    return decoder->decode(CoreIPC::Out(notification.m_title, notification.m_body, notification.m_notificationID));
-}
-
 } // namespace WebKit
index 730d39d..0b89a0a 100644 (file)
@@ -27,7 +27,9 @@
 #define WebNotification_h
 
 #include "APIObject.h"
+#include "WebSecurityOrigin.h"
 #include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
 #include <wtf/text/WTFString.h>
 
 namespace CoreIPC {
@@ -38,32 +40,30 @@ class ArgumentEncoder;
 } // namespace CoreIPC
 
 namespace WebKit {
-    
+
 class WebNotification : public APIObject {
 public:
     static const Type APIType = TypeNotification;
     
-    static PassRefPtr<WebNotification> create(const String& title, const String& body, uint64_t notificationID)
+    static PassRefPtr<WebNotification> create(const String& title, const String& body, const String& originIdentifier, uint64_t notificationID)
     {
-        return adoptRef(new WebNotification(title, body, notificationID));
+        return adoptRef(new WebNotification(title, body, originIdentifier, notificationID));
     }
     
     const String& title() const { return m_title; }
-    
     const String& body() const { return m_body; }
+    WebSecurityOrigin* origin() const { return m_origin.get(); }
     
     uint64_t notificationID() const { return m_notificationID; }
 
-    void encode(CoreIPC::ArgumentEncoder*) const;
-    static bool decode(CoreIPC::ArgumentDecoder*, WebNotification&);
-
 private:
-    WebNotification(const String& title, const String& body, uint64_t notificationID);
+    WebNotification(const String& title, const String& body, const String& originIdentifier, uint64_t notificationID);
 
     virtual Type type() const { return APIType; }
     
     String m_title;
     String m_body;
+    RefPtr<WebSecurityOrigin> m_origin;
     uint64_t m_notificationID;
 };
 
index 5536728..3ae3d7a 100644 (file)
@@ -68,14 +68,14 @@ void WebNotificationManagerProxy::didReceiveSyncMessage(CoreIPC::Connection* con
     didReceiveSyncWebNotificationManagerProxyMessage(connection, messageID, arguments, reply);
 }
 
-void WebNotificationManagerProxy::show(const String& title, const String& body, uint64_t notificationID)
+void WebNotificationManagerProxy::show(const String& title, const String& body, const String& originIdentifier, uint64_t notificationID)
 {
     if (!isNotificationIDValid(notificationID))
         return;
     
     m_provider.addNotificationManager(this);
 
-    RefPtr<WebNotification> notification = WebNotification::create(title, body, notificationID);
+    RefPtr<WebNotification> notification = WebNotification::create(title, body, originIdentifier, notificationID);
     m_notifications.set(notificationID, notification);
     m_provider.show(notification.get());
 }
index ac70ebb..57e108b 100644 (file)
@@ -71,7 +71,7 @@ private:
     void didReceiveSyncWebNotificationManagerProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&);
     
     // Message handlers
-    void show(const WTF::String& title, const WTF::String& body, uint64_t notificationID);
+    void show(const WTF::String& title, const WTF::String& body, const WTF::String& originIdentifier, uint64_t notificationID);
     void cancel(uint64_t notificationID);
     void didDestroyNotification(uint64_t notificationID);
     void notificationPermissionLevel(const WTF::String& originIdentifier, uint64_t& permissionLevel);
index 46671b4..4c6bda9 100644 (file)
@@ -21,7 +21,7 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 messages -> WebNotificationManagerProxy {
-    Show(WTF::String title, WTF::String body, uint64_t notificationID);
+    Show(WTF::String title, WTF::String body, WTF::String originIdentifier, uint64_t notificationID);
     Cancel(uint64_t notificationID);
     DidDestroyNotification(uint64_t notificationID);
 
index 9fcaceb..813ec85 100644 (file)
@@ -33,6 +33,8 @@
 #include "WebNotification.h"
 #include "WebNotificationManagerProxyMessages.h"
 #include <WebCore/Notification.h>
+#include <WebCore/ScriptExecutionContext.h>
+#include <WebCore/SecurityOrigin.h>
 #endif
 
 using namespace WebCore;
@@ -71,7 +73,7 @@ bool WebNotificationManager::show(Notification* notification, WebPage* page)
     m_notificationMap.set(notification, notificationID);
     m_notificationIDMap.set(notificationID, notification);
     
-    m_process->connection()->send(Messages::WebNotificationManagerProxy::Show(notification->contents().title, notification->contents().body, notificationID), page->pageID());
+    m_process->connection()->send(Messages::WebNotificationManagerProxy::Show(notification->contents().title, notification->contents().body, notification->scriptExecutionContext()->securityOrigin()->databaseIdentifier(), notificationID), page->pageID());
 #endif
     return true;
 }