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

Unified 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. Address some review comments. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/pushmessaging/PushManager.h ('k') | Source/modules/pushmessaging/PushManager.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/pushmessaging/PushManager.cpp
diff --git a/Source/modules/pushmessaging/PushManager.cpp b/Source/modules/pushmessaging/PushManager.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..64fba54680870755f5780561047a8bdfc4a87bea
--- /dev/null
+++ b/Source/modules/pushmessaging/PushManager.cpp
@@ -0,0 +1,40 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "modules/pushmessaging/PushManager.h"
+
+#include "RuntimeEnabledFeatures.h"
+#include "bindings/v8/CallbackPromiseAdapter.h"
+#include "bindings/v8/ScriptPromise.h"
+#include "bindings/v8/ScriptPromiseResolver.h"
+#include "core/dom/Document.h"
+#include "core/dom/ExecutionContext.h"
+#include "modules/pushmessaging/PushController.h"
+#include "modules/pushmessaging/PushMessagingError.h"
+#include "modules/pushmessaging/PushRegistration.h"
+#include "public/platform/WebPushClient.h"
+
+namespace WebCore {
+
+PushManager::PushManager()
+{
+ ScriptWrappable::init(this);
+}
+
+PushManager::~PushManager()
+{
+}
+
+ScriptPromise PushManager::registerPushMessaging(ExecutionContext* context, const String& channelName)
+{
+ ASSERT(RuntimeEnabledFeatures::pushMessagingEnabled());
+ ScriptPromise promise = ScriptPromise::createPending(context);
+ RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(promise, context);
+
+ PushController::clientFrom(toDocument(context)->page())->registerPushMessaging(channelName, new CallbackPromiseAdapter<PushRegistration, PushMessagingError>(resolver, context));
+ return promise;
+}
+
+} // namespace WebCore
« no previous file with comments | « Source/modules/pushmessaging/PushManager.h ('k') | Source/modules/pushmessaging/PushManager.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698