Move push client to frame.

Depends on https://codereview.chromium.org/720443002/

BUG=304341,350378

Review URL: https://codereview.chromium.org/687933002

git-svn-id: svn://svn.chromium.org/blink/trunk@185228 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 23375ca9
......@@ -20,9 +20,9 @@ PassOwnPtrWillBeRawPtr<PushController> PushController::create(WebPushClient* cli
return adoptPtrWillBeNoop(new PushController(client));
}
WebPushClient* PushController::clientFrom(Page* page)
WebPushClient* PushController::clientFrom(LocalFrame* frame)
{
if (PushController* controller = PushController::from(page))
if (PushController* controller = PushController::from(frame))
return controller->client();
return 0;
}
......@@ -32,9 +32,9 @@ const char* PushController::supplementName()
return "PushController";
}
void providePushControllerTo(Page& page, WebPushClient* client)
void providePushControllerTo(LocalFrame& frame, WebPushClient* client)
{
PushController::provideTo(page, PushController::supplementName(), PushController::create(client));
PushController::provideTo(frame, PushController::supplementName(), PushController::create(client));
}
} // namespace blink
......@@ -5,7 +5,7 @@
#ifndef PushController_h
#define PushController_h
#include "core/page/Page.h"
#include "core/frame/LocalFrame.h"
#include "platform/Supplementable.h"
#include "wtf/Forward.h"
#include "wtf/Noncopyable.h"
......@@ -15,27 +15,27 @@ namespace blink {
class WebPushClient;
class PushController final : public NoBaseWillBeGarbageCollected<PushController>, public WillBeHeapSupplement<Page> {
class PushController final : public NoBaseWillBeGarbageCollected<PushController>, public WillBeHeapSupplement<LocalFrame> {
WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(PushController);
WTF_MAKE_NONCOPYABLE(PushController);
public:
static PassOwnPtrWillBeRawPtr<PushController> create(WebPushClient*);
static const char* supplementName();
static PushController* from(Page* page) { return static_cast<PushController*>(WillBeHeapSupplement<Page>::from(page, supplementName())); }
static WebPushClient* clientFrom(Page*);
static PushController* from(LocalFrame* frame) { return static_cast<PushController*>(WillBeHeapSupplement<LocalFrame>::from(frame, supplementName())); }
static WebPushClient* clientFrom(LocalFrame*);
WebPushClient* client() const { return m_client; }
virtual void trace(Visitor* visitor) override { WillBeHeapSupplement<Page>::trace(visitor); }
virtual void trace(Visitor* visitor) override { WillBeHeapSupplement<LocalFrame>::trace(visitor); }
private:
explicit PushController(WebPushClient*);
WebPushClient* client() const { return m_client; }
WebPushClient* m_client;
};
void providePushControllerTo(Page&, WebPushClient*);
void providePushControllerTo(LocalFrame&, WebPushClient*);
} // namespace blink
......
......@@ -38,7 +38,7 @@ ScriptPromise PushManager::registerPushMessaging(ScriptState* scriptState)
ASSERT(scriptState->executionContext()->isDocument());
Document* document = toDocument(scriptState->executionContext());
if (!document->domWindow() || !document->page())
if (!document->domWindow() || !document->frame())
return ScriptPromise::rejectWithDOMException(scriptState, DOMException::create(AbortError, "Document is detached from window."));
WebServiceWorkerProvider* serviceWorkerProvider = NavigatorServiceWorker::serviceWorker(*document->domWindow()->navigator())->provider();
......@@ -48,7 +48,7 @@ ScriptPromise PushManager::registerPushMessaging(ScriptState* scriptState)
// FIXME: Once everything except permission request goes through platform,
// delete WebPushClient and usage such as this one.
// See crbug.com/389194
WebPushClient* client = PushController::clientFrom(document->page());
WebPushClient* client = PushController::clientFrom(document->frame());
ASSERT(client);
RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scriptState);
......@@ -70,9 +70,9 @@ ScriptPromise PushManager::hasPermission(ScriptState* scriptState)
ASSERT(scriptState->executionContext()->isDocument());
Document* document = toDocument(scriptState->executionContext());
if (!document->domWindow() || !document->page())
if (!document->domWindow() || !document->frame())
return ScriptPromise::rejectWithDOMException(scriptState, DOMException::create(InvalidStateError, "Document is detached from window."));
blink::WebPushClient* client = PushController::clientFrom(document->page());
blink::WebPushClient* client = PushController::clientFrom(document->frame());
ASSERT(client);
// The currently implemented specification does not require a Service Worker to be present for the
......
......@@ -151,6 +151,7 @@
#include "modules/geolocation/GeolocationController.h"
#include "modules/notifications/NotificationController.h"
#include "modules/notifications/NotificationPermissionClient.h"
#include "modules/push_messaging/PushController.h"
#include "modules/screen_orientation/ScreenOrientationController.h"
#include "platform/TraceEvent.h"
#include "platform/UserGestureIndicator.h"
......@@ -1582,8 +1583,10 @@ void WebLocalFrameImpl::setCoreFrame(PassRefPtrWillBeRawPtr<LocalFrame> frame)
// FIXME: we shouldn't add overhead to every frame by registering these objects when they're not used.
if (m_frame) {
OwnPtr<NotificationPresenterImpl> notificationPresenter = adoptPtr(new NotificationPresenterImpl());
if (m_client)
if (m_client) {
notificationPresenter->initialize(m_client->notificationPresenter());
providePushControllerTo(*m_frame, m_client->pushClient());
}
provideNotification(*m_frame, notificationPresenter.release());
provideNotificationPermissionClientTo(*m_frame, NotificationPermissionClientImpl::create());
......
......@@ -91,7 +91,6 @@
#include "modules/encryptedmedia/MediaKeysController.h"
#include "modules/filesystem/InspectorFileSystemAgent.h"
#include "modules/indexeddb/InspectorIndexedDBAgent.h"
#include "modules/push_messaging/PushController.h"
#include "platform/ContextMenu.h"
#include "platform/ContextMenuItem.h"
#include "platform/Cursor.h"
......@@ -448,7 +447,6 @@ WebViewImpl::WebViewImpl(WebViewClient* client)
m_page->makeOrdinary();
if (m_client) {
providePushControllerTo(*m_page, m_client->webPushClient());
setDeviceScaleFactor(m_client->screenInfo().deviceScaleFactor);
setVisibilityState(m_client->visibilityState(), true);
}
......
......@@ -79,6 +79,7 @@ class WebSocketHandle;
class WebNode;
class WebPlugin;
class WebPluginPlaceholder;
class WebPushClient;
class WebRTCPeerConnectionHandler;
class WebScreenOrientationClient;
class WebSharedWorker;
......@@ -337,8 +338,12 @@ public:
// Push API ---------------------------------------------------
// Requests permission to use the Push API in the origin of this frame.
// FIXME: Merge this into WebPushClient as it's not going away as originally planned.
virtual void requestPushPermission(WebCallback* callback) { }
// Used to access the embedder for the Push API.
virtual WebPushClient* pushClient() { return 0; }
// Editing -------------------------------------------------------------
......
......@@ -60,7 +60,6 @@ class WebImage;
class WebInputElement;
class WebKeyboardEvent;
class WebNode;
class WebPushClient;
class WebRange;
class WebSpeechRecognizer;
class WebStorageNamespace;
......@@ -282,11 +281,6 @@ public:
}
// Push Messaging -------------------------------------------------------
virtual WebPushClient* webPushClient() { return 0; }
// Content detection ----------------------------------------------------
// Retrieves detectable content (e.g., email addresses, phone numbers)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment