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 "modules/notifications/ServiceWorkerRegistrationNotifications.h" | 5 #include "modules/notifications/ServiceWorkerRegistrationNotifications.h" |
6 | 6 |
7 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 7 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
10 #include "core/dom/ExecutionContext.h" | 10 #include "core/dom/ExecutionContext.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 NotificationArray() = delete; | 43 NotificationArray() = delete; |
44 }; | 44 }; |
45 | 45 |
46 } // namespace | 46 } // namespace |
47 | 47 |
48 ServiceWorkerRegistrationNotifications::ServiceWorkerRegistrationNotifications(E
xecutionContext* executionContext, ServiceWorkerRegistration* registration) | 48 ServiceWorkerRegistrationNotifications::ServiceWorkerRegistrationNotifications(E
xecutionContext* executionContext, ServiceWorkerRegistration* registration) |
49 : ContextLifecycleObserver(executionContext), m_registration(registration) | 49 : ContextLifecycleObserver(executionContext), m_registration(registration) |
50 { | 50 { |
51 } | 51 } |
52 | 52 |
| 53 ServiceWorkerRegistrationNotifications::~ServiceWorkerRegistrationNotifications(
) |
| 54 { |
| 55 } |
| 56 |
53 ScriptPromise ServiceWorkerRegistrationNotifications::showNotification(ScriptSta
te* scriptState, ServiceWorkerRegistration& registration, const String& title, c
onst NotificationOptions& options, ExceptionState& exceptionState) | 57 ScriptPromise ServiceWorkerRegistrationNotifications::showNotification(ScriptSta
te* scriptState, ServiceWorkerRegistration& registration, const String& title, c
onst NotificationOptions& options, ExceptionState& exceptionState) |
54 { | 58 { |
55 ExecutionContext* executionContext = scriptState->getExecutionContext(); | 59 ExecutionContext* executionContext = scriptState->getExecutionContext(); |
56 | 60 |
57 // If context object's active worker is null, reject promise with a TypeErro
r exception. | 61 // If context object's active worker is null, reject promise with a TypeErro
r exception. |
58 if (!registration.active()) | 62 if (!registration.active()) |
59 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr
ror(scriptState->isolate(), "No active registration available on the ServiceWork
erRegistration.")); | 63 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr
ror(scriptState->isolate(), "No active registration available on the ServiceWork
erRegistration.")); |
60 | 64 |
61 // If permission for notification's origin is not "granted", reject promise
with a TypeError exception, and terminate these substeps. | 65 // If permission for notification's origin is not "granted", reject promise
with a TypeError exception, and terminate these substeps. |
62 if (Notification::checkPermission(executionContext) != mojom::PermissionStat
us::GRANTED) | 66 if (Notification::checkPermission(executionContext) != mojom::PermissionStat
us::GRANTED) |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 DCHECK(m_loaders.contains(loader)); | 140 DCHECK(m_loaders.contains(loader)); |
137 | 141 |
138 WebNotificationManager* notificationManager = Platform::current()->notificat
ionManager(); | 142 WebNotificationManager* notificationManager = Platform::current()->notificat
ionManager(); |
139 DCHECK(notificationManager); | 143 DCHECK(notificationManager); |
140 | 144 |
141 notificationManager->showPersistent(WebSecurityOrigin(origin.get()), data, l
oader->getResources(), m_registration->webRegistration(), callbacks.leakPtr()); | 145 notificationManager->showPersistent(WebSecurityOrigin(origin.get()), data, l
oader->getResources(), m_registration->webRegistration(), callbacks.leakPtr()); |
142 m_loaders.remove(loader); | 146 m_loaders.remove(loader); |
143 } | 147 } |
144 | 148 |
145 } // namespace blink | 149 } // namespace blink |
OLD | NEW |