Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "modules/push_messaging/PushManager.h" | 6 #include "modules/push_messaging/PushManager.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
| 9 #include "bindings/core/v8/ScriptPromise.h" | 9 #include "bindings/core/v8/ScriptPromise.h" |
| 10 #include "bindings/core/v8/ScriptPromiseResolver.h" | 10 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 | 26 |
| 27 PushManager::PushManager() | 27 PushManager::PushManager() |
| 28 { | 28 { |
| 29 } | 29 } |
| 30 | 30 |
| 31 ScriptPromise PushManager::registerPushMessaging(ScriptState* scriptState) | 31 ScriptPromise PushManager::registerPushMessaging(ScriptState* scriptState) |
| 32 { | 32 { |
| 33 ASSERT(scriptState->executionContext()->isDocument()); | 33 ASSERT(scriptState->executionContext()->isDocument()); |
| 34 | 34 |
| 35 Document* document = toDocument(scriptState->executionContext()); | 35 Document* document = toDocument(scriptState->executionContext()); |
| 36 if (!document->domWindow() || !document->page()) | 36 if (!document->domWindow() || !document->page() || !document->frame()) |
|
Peter Beverloo
2014/10/29 11:25:07
Remove the "!document->page()" check.
Michael van Ouwerkerk
2014/11/11 17:20:06
Done.
| |
| 37 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(AbortError, "Document is detached from window.")); | 37 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(AbortError, "Document is detached from window.")); |
| 38 | 38 |
| 39 WebServiceWorkerProvider* serviceWorkerProvider = NavigatorServiceWorker::se rviceWorker(*document->domWindow()->navigator())->provider(); | 39 WebServiceWorkerProvider* serviceWorkerProvider = NavigatorServiceWorker::se rviceWorker(*document->domWindow()->navigator())->provider(); |
| 40 if (!serviceWorkerProvider) | 40 if (!serviceWorkerProvider) |
| 41 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(AbortError, "No Service Worker installed for this document.")); | 41 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(AbortError, "No Service Worker installed for this document.")); |
| 42 | 42 |
| 43 WebPushClient* client = PushController::clientFrom(document->page()); | 43 WebPushClient* client = PushController::clientFrom(document->frame()); |
| 44 ASSERT(client); | 44 ASSERT(client); |
|
Peter Beverloo
2014/10/29 11:25:07
We're going to be hitting this assert when using l
Michael van Ouwerkerk
2014/11/11 17:20:06
No, there is already an implementation of pushClie
| |
| 45 | 45 |
| 46 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip tState); | 46 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip tState); |
| 47 ScriptPromise promise = resolver->promise(); | 47 ScriptPromise promise = resolver->promise(); |
| 48 client->registerPushMessaging(new CallbackPromiseAdapter<PushRegistration, P ushError>(resolver), serviceWorkerProvider); | 48 client->registerPushMessaging(new CallbackPromiseAdapter<PushRegistration, P ushError>(resolver), serviceWorkerProvider); |
| 49 return promise; | 49 return promise; |
| 50 } | 50 } |
| 51 | 51 |
| 52 } // namespace blink | 52 } // namespace blink |
| OLD | NEW |