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" |
11 #include "bindings/core/v8/ScriptState.h" | 11 #include "bindings/core/v8/ScriptState.h" |
12 #include "core/dom/DOMException.h" | 12 #include "core/dom/DOMException.h" |
13 #include "core/dom/Document.h" | 13 #include "core/dom/Document.h" |
14 #include "core/dom/ExceptionCode.h" | 14 #include "core/dom/ExceptionCode.h" |
15 #include "core/dom/ExecutionContext.h" | 15 #include "core/dom/ExecutionContext.h" |
16 #include "core/frame/LocalDOMWindow.h" | 16 #include "core/frame/LocalDOMWindow.h" |
17 #include "modules/push_messaging/PushController.h" | 17 #include "modules/push_messaging/PushController.h" |
18 #include "modules/push_messaging/PushError.h" | 18 #include "modules/push_messaging/PushError.h" |
19 #include "modules/push_messaging/PushPermissionCallback.h" | 19 #include "modules/push_messaging/PushPermissionStatusCallback.h" |
20 #include "modules/push_messaging/PushRegistration.h" | 20 #include "modules/push_messaging/PushRegistration.h" |
21 #include "modules/serviceworkers/NavigatorServiceWorker.h" | 21 #include "modules/serviceworkers/NavigatorServiceWorker.h" |
22 #include "modules/serviceworkers/ServiceWorkerContainer.h" | 22 #include "modules/serviceworkers/ServiceWorkerContainer.h" |
23 #include "public/platform/WebPushClient.h" | 23 #include "public/platform/WebPushClient.h" |
24 #include "wtf/RefPtr.h" | 24 #include "wtf/RefPtr.h" |
25 | 25 |
26 namespace blink { | 26 namespace blink { |
27 | 27 |
28 PushManager::PushManager() | 28 PushManager::PushManager() |
29 { | 29 { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 ASSERT(client); | 65 ASSERT(client); |
66 | 66 |
67 // The currently implemented specification does not require a Service Worker
to be present for the | 67 // The currently implemented specification does not require a Service Worker
to be present for the |
68 // hasPermission() call to work, but it will become a requirement soon. | 68 // hasPermission() call to work, but it will become a requirement soon. |
69 WebServiceWorkerProvider* serviceWorkerProvider = NavigatorServiceWorker::se
rviceWorker(*document->domWindow()->navigator())->provider(); | 69 WebServiceWorkerProvider* serviceWorkerProvider = NavigatorServiceWorker::se
rviceWorker(*document->domWindow()->navigator())->provider(); |
70 if (!serviceWorkerProvider) | 70 if (!serviceWorkerProvider) |
71 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, "No Service Worker installed for this document.")); | 71 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, "No Service Worker installed for this document.")); |
72 | 72 |
73 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip
tState); | 73 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip
tState); |
74 | 74 |
75 client->getPermissionStatus(new PushPermissionCallback(resolver), serviceWor
kerProvider); | 75 client->getPermissionStatus(new PushPermissionStatusCallback(resolver), serv
iceWorkerProvider); |
76 return resolver->promise(); | 76 return resolver->promise(); |
77 } | 77 } |
78 | 78 |
79 } // namespace blink | 79 } // namespace blink |
OLD | NEW |