NOTIFICATIONS should be implemented as PageSupplement
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Feb 2012 07:29:30 +0000 (07:29 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Feb 2012 07:29:30 +0000 (07:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=79052

Patch by Hajime Morrita <morrita@chromium.org> on 2012-02-22
Reviewed by Adam Barth.

Source/WebCore:

Turned NotificationController to a PageSupplement.

No new tests. No behavior change.

* notifications/NotificationController.cpp:
(WebCore::NotificationController::clientFrom):
(WebCore):
(WebCore::NotificationController::supplementName):
(WebCore::provideNotification):
* notifications/NotificationController.h:
(NotificationController):
(WebCore::NotificationController::from):
* notifications/NotificationPresenter.h:
(WebCore):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::webkitNotifications):
* page/Page.cpp:
(WebCore::Page::Page):
(WebCore::Page::PageClients::PageClients):
* page/Page.h:
(WebCore):
(PageClients):
(Page):

Source/WebKit/chromium:

* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::WebViewImpl):

Source/WebKit/mac:

* WebView/WebView.mm:
(-[WebView _commonInitializationWithFrameName:groupName:]):

Source/WebKit/qt:

* Api/qwebpage.cpp:
(QWebPagePrivate::QWebPagePrivate):

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

13 files changed:
Source/WebCore/ChangeLog
Source/WebCore/notifications/NotificationController.cpp
Source/WebCore/notifications/NotificationController.h
Source/WebCore/notifications/NotificationPresenter.h
Source/WebCore/page/DOMWindow.cpp
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/WebViewImpl.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit/qt/Api/qwebpage.cpp
Source/WebKit/qt/ChangeLog

index 1661545..c0fe04e 100644 (file)
@@ -1,3 +1,34 @@
+2012-02-22  Hajime Morrita  <morrita@chromium.org>
+
+        NOTIFICATIONS should be implemented as PageSupplement
+        https://bugs.webkit.org/show_bug.cgi?id=79052
+
+        Reviewed by Adam Barth.
+
+        Turned NotificationController to a PageSupplement.
+
+        No new tests. No behavior change.
+
+        * notifications/NotificationController.cpp:
+        (WebCore::NotificationController::clientFrom):
+        (WebCore):
+        (WebCore::NotificationController::supplementName):
+        (WebCore::provideNotification):
+        * notifications/NotificationController.h:
+        (NotificationController):
+        (WebCore::NotificationController::from):
+        * notifications/NotificationPresenter.h:
+        (WebCore):
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::webkitNotifications):
+        * page/Page.cpp:
+        (WebCore::Page::Page):
+        (WebCore::Page::PageClients::PageClients):
+        * page/Page.h:
+        (WebCore):
+        (PageClients):
+        (Page):
+
 2012-02-22  Dmitry Lomov  <dslomov@google.com>
 
         [Chromium][V8] Support Uint8ClampedArray in postMessage
index c86aa12..cbdc3ea 100644 (file)
@@ -50,6 +50,24 @@ PassOwnPtr<NotificationController> NotificationController::create(Page* page, No
     return adoptPtr(new NotificationController(page, client));
 }
 
+NotificationPresenter* NotificationController::clientFrom(Page* page)
+{
+    if (NotificationController* controller = NotificationController::from(page))
+        return controller->client();
+    return 0;
+}
+
+const AtomicString& NotificationController::supplementName()
+{
+    DEFINE_STATIC_LOCAL(AtomicString, name, ("NotificationController"));
+    return name;
+}
+
+void provideNotification(Page* page, NotificationPresenter* client)
+{
+    PageSupplement::provideTo(page, NotificationController::supplementName(), NotificationController::create(page, client));
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(NOTIFICATIONS)
index a958a05..33a95d5 100644 (file)
@@ -28,6 +28,7 @@
 
 #if ENABLE(NOTIFICATIONS)
 
+#include "PageSupplement.h"
 #include <wtf/Forward.h>
 #include <wtf/Noncopyable.h>
 
@@ -36,12 +37,16 @@ namespace WebCore {
 class NotificationPresenter;
 class Page;
 
-class NotificationController {
+class NotificationController : public PageSupplement {
     WTF_MAKE_NONCOPYABLE(NotificationController);
 public:
     ~NotificationController();
 
     static PassOwnPtr<NotificationController> create(Page*, NotificationPresenter*);
+    static const AtomicString& supplementName();
+    static NotificationController* from(Frame* frame) { return static_cast<NotificationController*>(PageSupplement::from(frame, supplementName())); }
+    static NotificationController* from(Page* page) { return static_cast<NotificationController*>(PageSupplement::from(page, supplementName())); }
+    static NotificationPresenter* clientFrom(Page*);
 
     NotificationPresenter* client() { return m_client; }
     
index 108f055..1935384 100644 (file)
@@ -40,6 +40,7 @@ namespace WebCore {
 class Document;
 class Notification;
 class KURL;
+class Page;
 class ScriptExecutionContext;
 
 class NotificationPresenter {
@@ -84,6 +85,8 @@ protected:
     virtual ~NotificationPresenter() { }
 };
 
+void provideNotification(Page*, NotificationPresenter*);
+
 } // namespace WebCore
 
 #endif // NotificationPresenter_h
index 45d960b..9ff0af8 100644 (file)
@@ -719,7 +719,7 @@ NotificationCenter* DOMWindow::webkitNotifications() const
     if (!page)
         return 0;
 
-    NotificationPresenter* provider = page->notificationController()->client();
+    NotificationPresenter* provider = NotificationController::clientFrom(page);
     if (provider) 
         m_notifications = NotificationCenter::create(document, provider);    
       
index 6b62a9f..1bad0a4 100644 (file)
@@ -51,8 +51,6 @@
 #include "MediaCanStartListener.h"
 #include "Navigator.h"
 #include "NetworkStateNotifier.h"
-#include "NotificationController.h"
-#include "NotificationPresenter.h"
 #include "PageGroup.h"
 #include "PluginData.h"
 #include "PluginView.h"
@@ -70,6 +68,7 @@
 #include "StorageArea.h"
 #include "StorageNamespace.h"
 #include "TextResourceDecoder.h"
+#include "VoidCallback.h"
 #include "Widget.h"
 #include <wtf/HashMap.h>
 #include <wtf/RefCountedLeakCounter.h>
@@ -129,9 +128,6 @@ Page::Page(PageClients& pageClients)
 #if ENABLE(CLIENT_BASED_GEOLOCATION)
     , m_geolocationController(GeolocationController::create(this, pageClients.geolocationClient))
 #endif
-#if ENABLE(NOTIFICATIONS)
-    , m_notificationController(NotificationController::create(this, pageClients.notificationClient))
-#endif
 #if ENABLE(POINTER_LOCK)
     , m_pointerLockController(PointerLockController::create(this))
 #endif
@@ -1071,7 +1067,6 @@ Page::PageClients::PageClients()
     , dragClient(0)
     , inspectorClient(0)
     , geolocationClient(0)
-    , notificationClient(0)
 {
 }
 
index d46f643..685eed7 100644 (file)
@@ -70,8 +70,6 @@ namespace WebCore {
     class InspectorController;
     class MediaCanStartListener;
     class Node;
-    class NotificationController;
-    class NotificationPresenter;
     class PageGroup;
     class PluginData;
     class PointerLockController;
@@ -84,9 +82,6 @@ namespace WebCore {
     class ScrollingCoordinator;
     class Settings;
     class StorageNamespace;
-#if ENABLE(NOTIFICATIONS)
-    class NotificationPresenter;
-#endif
 
     typedef uint64_t LinkHash;
 
@@ -114,7 +109,6 @@ namespace WebCore {
             InspectorClient* inspectorClient;
             GeolocationClient* geolocationClient;
             RefPtr<BackForwardList> backForwardClient;
-            NotificationPresenter* notificationClient;
         };
 
         Page(PageClients&);
@@ -175,9 +169,6 @@ namespace WebCore {
 #if ENABLE(CLIENT_BASED_GEOLOCATION)
         GeolocationController* geolocationController() const { return m_geolocationController.get(); }
 #endif
-#if ENABLE(NOTIFICATIONS)
-        NotificationController* notificationController() const { return m_notificationController.get(); }
-#endif
 #if ENABLE(POINTER_LOCK)
         PointerLockController* pointerLockController() const { return m_pointerLockController.get(); }
 #endif
@@ -369,9 +360,6 @@ namespace WebCore {
 #if ENABLE(CLIENT_BASED_GEOLOCATION)
         OwnPtr<GeolocationController> m_geolocationController;
 #endif
-#if ENABLE(NOTIFICATIONS)
-        OwnPtr<NotificationController> m_notificationController;
-#endif
 #if ENABLE(POINTER_LOCK)
         OwnPtr<PointerLockController> m_pointerLockController;
 #endif
@@ -425,10 +413,6 @@ namespace WebCore {
 
         RefPtr<StorageNamespace> m_sessionStorage;
 
-#if ENABLE(NOTIFICATIONS)
-        NotificationPresenter* m_notificationPresenter;
-#endif
-
         ViewMode m_viewMode;
 
         double m_minimumTimerInterval;
index d20badf..d7b744d 100644 (file)
@@ -1,3 +1,13 @@
+2012-02-22  Hajime Morrita  <morrita@chromium.org>
+
+        NOTIFICATIONS should be implemented as PageSupplement
+        https://bugs.webkit.org/show_bug.cgi?id=79052
+
+        Reviewed by Adam Barth.
+
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::WebViewImpl):
+
 2012-02-22  Dana Jansens  <danakj@chromium.org>
 
         [chromium] Add unit test for surface occlusion
index 34da0de..9c514ba 100644 (file)
@@ -398,9 +398,6 @@ WebViewImpl::WebViewImpl(WebViewClient* client)
     pageClients.dragClient = &m_dragClientImpl;
     pageClients.inspectorClient = &m_inspectorClientImpl;
     pageClients.geolocationClient = m_geolocationClientProxy.get();
-#if ENABLE(NOTIFICATIONS)
-    pageClients.notificationClient = notificationPresenterImpl();
-#endif
     pageClients.backForwardClient = BackForwardListChromium::create(this);
 
     m_page = adoptPtr(new Page(pageClients));
@@ -410,6 +407,9 @@ WebViewImpl::WebViewImpl(WebViewClient* client)
 #if ENABLE(INPUT_SPEECH)
     provideSpeechInputTo(m_page.get(), m_speechInputClient.get());
 #endif
+#if ENABLE(NOTIFICATIONS)
+    provideNotification(m_page.get(), notificationPresenterImpl());
+#endif
 
     provideDeviceOrientationTo(m_page.get(), m_deviceOrientationClientProxy.get());
     m_geolocationClientProxy->setController(m_page->geolocationController());
index ee2fdb7..208638f 100644 (file)
@@ -1,3 +1,13 @@
+2012-02-22  Hajime Morrita  <morrita@chromium.org>
+
+        NOTIFICATIONS should be implemented as PageSupplement
+        https://bugs.webkit.org/show_bug.cgi?id=79052
+
+        Reviewed by Adam Barth.
+
+        * WebView/WebView.mm:
+        (-[WebView _commonInitializationWithFrameName:groupName:]):
+
 2012-02-21  Ryosuke Niwa  <rniwa@webkit.org>
 
         Remove the remaining uses of CSSStyleDeclaration in Editor
index 1611a6d..8c1d5dd 100644 (file)
@@ -742,10 +742,10 @@ static NSString *leakOutlookQuirksUserScriptContents()
 #if ENABLE(CLIENT_BASED_GEOLOCATION)
     pageClients.geolocationClient = new WebGeolocationClient(self);
 #endif
+    _private->page = new Page(pageClients);
 #if ENABLE(NOTIFICATIONS)
-    pageClients.notificationClient = new WebNotificationClient(self);
+    WebCore::provideNotification(_private->page, new WebNotificationClient(self));
 #endif
-    _private->page = new Page(pageClients);
 #if ENABLE(DEVICE_ORIENTATION)
     WebCore::provideDeviceOrientationTo(_private->page, new WebDeviceOrientationClient(self));
 #endif
index e0dc778..8634133 100644 (file)
@@ -332,9 +332,6 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq)
     else
         pageClients.geolocationClient = new GeolocationClientQt(q);
 #endif
-#if ENABLE(NOTIFICATIONS)
-    pageClients.notificationClient = NotificationPresenterClientQt::notificationPresenter();
-#endif
     page = new Page(pageClients);
 #if ENABLE(DEVICE_ORIENTATION)
     if (useMock)
@@ -343,6 +340,9 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq)
         WebCore::provideDeviceOrientationTo(page, new DeviceOrientationClientQt);
     WebCore::provideDeviceMotionTo(page, new DeviceMotionClientQt);
 #endif
+#if ENABLE(NOTIFICATIONS)
+    WebCore::provideNotification(page, NotificationPresenterClientQt::notificationPresenter());
+#endif
 
     // By default each page is put into their own unique page group, which affects popup windows
     // and visited links. Page groups (per process only) is a feature making it possible to use
index da5eb87..876897e 100644 (file)
@@ -1,3 +1,13 @@
+2012-02-22  Hajime Morrita  <morrita@chromium.org>
+
+        NOTIFICATIONS should be implemented as PageSupplement
+        https://bugs.webkit.org/show_bug.cgi?id=79052
+
+        Reviewed by Adam Barth.
+
+        * Api/qwebpage.cpp:
+        (QWebPagePrivate::QWebPagePrivate):
+
 2012-02-21  Ryosuke Niwa  <rniwa@webkit.org>
 
         Remove the remaining uses of CSSStyleDeclaration in Editor