Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: Source/modules/pushmessaging/PushManager.cpp

Issue 152763002: DO NOT REVIEW Bindings and plumbing for push messaging API. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase. Flip flag to experimental. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "modules/pushmessaging/PushManager.h"
7
8 #include "RuntimeEnabledFeatures.h"
9 #include "bindings/v8/CallbackPromiseAdapter.h"
10 #include "bindings/v8/ScriptPromise.h"
11 #include "bindings/v8/ScriptPromiseResolver.h"
12 #include "core/dom/Document.h"
13 #include "core/dom/ExecutionContext.h"
14 #include "modules/pushmessaging/PushController.h"
15 #include "modules/pushmessaging/PushMessagingError.h"
16 #include "modules/pushmessaging/PushRegistration.h"
17 #include "public/platform/WebPushClient.h"
18
19 namespace WebCore {
20
21 PushManager::PushManager()
22 {
23 ScriptWrappable::init(this);
24 }
25
26 PushManager::~PushManager()
27 {
28 }
29
30 PassRefPtr<PushManager> PushManager::create()
31 {
32 return adoptRef(new PushManager());
Peter Beverloo 2014/03/10 13:59:28 adoptRefWillBeNoop(). Can probably be moved to the
Michael van Ouwerkerk 2014/03/10 15:12:04 Moved to header.
33 }
34
35 ScriptPromise PushManager::registerPushMessaging(ExecutionContext* context, cons t String& channelName)
36 {
37 ASSERT(RuntimeEnabledFeatures::pushMessagingEnabled());
38 ScriptPromise promise = ScriptPromise::createPending(context);
39 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(promi se, context);
40
41 PushController::clientFrom(toDocument(context)->page())->registerPushMessagi ng(channelName, new CallbackPromiseAdapter<PushRegistration, PushMessagingError> (resolver, context));
42 return promise;
43 }
44
45 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698