[WK2] Add SPI to retrieve internal IDs for web notifications
authorjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Aug 2012 17:47:54 +0000 (17:47 +0000)
committerjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Aug 2012 17:47:54 +0000 (17:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=95100
<rdar://problem/12180208>

Reviewed by Alexey Proskuryakov.

This is work toward providing Mac support for web notifications in DRT and WTR (77969).

Add function to retrieve the internal ID for a notification. This is needed by tests to support simulating
a user click on a notification.

* DerivedSources.pri: Expose JSNotification.h as private header.
* WebProcess/InjectedBundle/API/c/WKBundle.cpp:
(WKBundleGetWebNotificationID): Calls into notification manager to get internal ID.
* WebProcess/InjectedBundle/API/c/WKBundlePrivate.h: Add WKBundleGetWebNotificationID() to be able
retrieve notification ID.
* WebProcess/InjectedBundle/InjectedBundle.cpp:
(WebKit::InjectedBundle::webNotificationID):
(WebKit):
* WebProcess/InjectedBundle/InjectedBundle.h:
(InjectedBundle):
* WebProcess/Notifications/WebNotificationManager.cpp:
(WebKit::WebNotificationManager::notificationIDForTesting):
(WebKit):
* WebProcess/Notifications/WebNotificationManager.h:
(WebNotificationManager):

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

Source/WebKit2/ChangeLog
Source/WebKit2/DerivedSources.pri
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h
Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp
Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h
Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp
Source/WebKit2/WebProcess/Notifications/WebNotificationManager.h

index 36d03e9..4d78971 100644 (file)
@@ -1,3 +1,32 @@
+2012-08-29  Jon Lee  <jonlee@apple.com>
+
+        [WK2] Add SPI to retrieve internal IDs for web notifications
+        https://bugs.webkit.org/show_bug.cgi?id=95100
+        <rdar://problem/12180208>
+
+        Reviewed by Alexey Proskuryakov.
+
+        This is work toward providing Mac support for web notifications in DRT and WTR (77969).
+
+        Add function to retrieve the internal ID for a notification. This is needed by tests to support simulating
+        a user click on a notification.
+
+        * DerivedSources.pri: Expose JSNotification.h as private header.
+        * WebProcess/InjectedBundle/API/c/WKBundle.cpp:
+        (WKBundleGetWebNotificationID): Calls into notification manager to get internal ID.
+        * WebProcess/InjectedBundle/API/c/WKBundlePrivate.h: Add WKBundleGetWebNotificationID() to be able
+        retrieve notification ID.
+        * WebProcess/InjectedBundle/InjectedBundle.cpp:
+        (WebKit::InjectedBundle::webNotificationID):
+        (WebKit):
+        * WebProcess/InjectedBundle/InjectedBundle.h:
+        (InjectedBundle):
+        * WebProcess/Notifications/WebNotificationManager.cpp:
+        (WebKit::WebNotificationManager::notificationIDForTesting):
+        (WebKit):
+        * WebProcess/Notifications/WebNotificationManager.h:
+        (WebNotificationManager):
+
 2012-08-28  Martin Robinson  <mrobinson@igalia.com>
 
         [GTK] Enable the edge distance anti-aliasing for accelerated compositing layers
index 26cbb2b..2e18542 100644 (file)
@@ -22,6 +22,7 @@ WEBCORE_GENERATED_HEADERS_FOR_WEBKIT2 += \
     $$WEBCORE_GENERATED_SOURCES_DIR/JSElement.h \
     $$WEBCORE_GENERATED_SOURCES_DIR/JSHTMLElement.h \
     $$WEBCORE_GENERATED_SOURCES_DIR/JSNode.h \
+    $$WEBCORE_GENERATED_SOURCES_DIR/JSNotification.h \
     $$WEBCORE_GENERATED_SOURCES_DIR/JSRange.h \
 
 defineReplace(message_header_generator_output) {
index e8d837d..6919a1e 100644 (file)
@@ -270,3 +270,9 @@ void WKBundleRemoveAllWebNotificationPermissions(WKBundleRef bundleRef, WKBundle
 {
     toImpl(bundleRef)->removeAllWebNotificationPermissions(toImpl(pageRef));
 }
+
+uint64_t WKBundleGetWebNotificationID(WKBundleRef bundleRef, JSContextRef context, JSValueRef notification)
+{
+    return toImpl(bundleRef)->webNotificationID(context, notification);
+}
+
index e4be207..7cba263 100644 (file)
@@ -102,6 +102,8 @@ WK_EXPORT bool WKBundleIsProcessingUserGesture(WKBundleRef bundle);
 
 WK_EXPORT void WKBundleSetPageVisibilityState(WKBundleRef bundle, WKBundlePageRef page, int state, bool isInitialState);
 
+WK_EXPORT uint64_t WKBundleGetWebNotificationID(WKBundleRef bundle, JSContextRef context, JSValueRef notificaiton);
+
 #ifdef __cplusplus
 }
 #endif
index 284341c..b58538a 100644 (file)
@@ -54,6 +54,7 @@
 #include <WebCore/GeolocationController.h>
 #include <WebCore/GeolocationPosition.h>
 #include <WebCore/JSDOMWindow.h>
+#include <WebCore/JSNotification.h>
 #include <WebCore/Page.h>
 #include <WebCore/PageGroup.h>
 #include <WebCore/PageVisibilityState.h>
@@ -555,4 +556,16 @@ void InjectedBundle::removeAllWebNotificationPermissions(WebPage* page)
 #endif
 }
 
+uint64_t InjectedBundle::webNotificationID(JSContextRef jsContext, JSValueRef jsNotification)
+{
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
+    WebCore::Notification* notification = toNotification(toJS(toJS(jsContext), jsNotification));
+    if (!notification)
+        return 0;
+    return WebProcess::shared().notificationManager().notificationIDForTesting(notification);
+#else
+    return 0;
+#endif
+}
+
 } // namespace WebKit
index e7b82bd..b01fdc5 100644 (file)
@@ -126,6 +126,7 @@ public:
     void setUserStyleSheetLocation(WebPageGroupProxy*, const String&);
     void setWebNotificationPermission(WebPage*, const String& originString, bool allowed);
     void removeAllWebNotificationPermissions(WebPage*);
+    uint64_t webNotificationID(JSContextRef, JSValueRef);
 
     // UserContent API
     void addUserScript(WebPageGroupProxy*, InjectedBundleScriptWorld*, const String& source, const String& url, ImmutableArray* whitelist, ImmutableArray* blacklist, WebCore::UserScriptInjectionTime, WebCore::UserContentInjectedFrames);
index 0a65a2d..2823da7 100644 (file)
@@ -112,6 +112,17 @@ void WebNotificationManager::removeAllPermissionsForTesting()
 #endif
 }
 
+uint64_t WebNotificationManager::notificationIDForTesting(Notification* notification)
+{
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
+    if (!notification)
+        return 0;
+    return m_notificationMap.get(notification);
+#else
+    return 0;
+#endif
+}
+
 bool WebNotificationManager::show(Notification* notification, WebPage* page)
 {
 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
index 65b3fa4..6a70fc6 100644 (file)
@@ -64,14 +64,13 @@ public:
     void didDestroyNotification(WebCore::Notification*, WebPage*);
 
     void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
-    
+    void didUpdateNotificationDecision(const String& originString, bool allowed);
+
     // Looks in local cache for permission. If not found, returns DefaultDenied.
     WebCore::NotificationClient::Permission policyForOrigin(WebCore::SecurityOrigin*) const;
 
-    void didUpdateNotificationDecision(const String& originString, bool allowed);
-
-    // For testing purposes only.
     void removeAllPermissionsForTesting();
+    uint64_t notificationIDForTesting(WebCore::Notification*);
 
 private:
     // Implemented in generated WebNotificationManagerMessageReceiver.cpp