Chromium Code Reviews| 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..ae43bcbb6b67100bc1df5eb66c16abbebe8f37cd |
| --- /dev/null |
| +++ b/Source/modules/pushmessaging/PushManager.cpp |
| @@ -0,0 +1,45 @@ |
| +// 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() |
| +{ |
| +} |
| + |
| +PassRefPtr<PushManager> PushManager::create() |
| +{ |
| + 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.
|
| +} |
| + |
| +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 |