| 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/notifications/ServiceWorkerRegistrationNotifications.h" | 6 #include "modules/notifications/ServiceWorkerRegistrationNotifications.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
| 9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 10 #include "bindings/core/v8/V8ThrowException.h" | 10 #include "bindings/core/v8/V8ThrowException.h" |
| 11 #include "core/dom/DOMException.h" | 11 #include "core/dom/DOMException.h" |
| 12 #include "core/dom/ExceptionCode.h" | 12 #include "core/dom/ExceptionCode.h" |
| 13 #include "core/dom/ExecutionContext.h" | 13 #include "core/dom/ExecutionContext.h" |
| 14 #include "modules/notifications/Notification.h" | 14 #include "modules/notifications/Notification.h" |
| 15 #include "modules/notifications/NotificationOptions.h" | 15 #include "modules/notifications/NotificationOptions.h" |
| 16 #include "platform/weborigin/KURL.h" | 16 #include "platform/weborigin/KURL.h" |
| 17 #include "public/platform/Platform.h" | 17 #include "public/platform/Platform.h" |
| 18 #include "public/platform/WebNotificationData.h" | |
| 19 #include "public/platform/WebNotificationManager.h" | |
| 20 #include "public/platform/WebSerializedOrigin.h" | 18 #include "public/platform/WebSerializedOrigin.h" |
| 19 #include "public/platform/modules/notifications/WebNotificationData.h" |
| 20 #include "public/platform/modules/notifications/WebNotificationManager.h" |
| 21 | 21 |
| 22 namespace blink { | 22 namespace blink { |
| 23 | 23 |
| 24 ScriptPromise ServiceWorkerRegistrationNotifications::showNotification(ScriptSta
te* scriptState, ServiceWorkerRegistration& serviceWorkerRegistration, const Str
ing& title, const NotificationOptions& options) | 24 ScriptPromise ServiceWorkerRegistrationNotifications::showNotification(ScriptSta
te* scriptState, ServiceWorkerRegistration& serviceWorkerRegistration, const Str
ing& title, const NotificationOptions& options) |
| 25 { | 25 { |
| 26 ExecutionContext* executionContext = scriptState->executionContext(); | 26 ExecutionContext* executionContext = scriptState->executionContext(); |
| 27 | 27 |
| 28 // If context object's active worker is null, reject promise with a TypeErro
r exception. | 28 // If context object's active worker is null, reject promise with a TypeErro
r exception. |
| 29 if (!serviceWorkerRegistration.active()) | 29 if (!serviceWorkerRegistration.active()) |
| 30 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr
ror(scriptState->isolate(), "No active registration available on the ServiceWork
erRegistration.")); | 30 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr
ror(scriptState->isolate(), "No active registration available on the ServiceWork
erRegistration.")); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 53 ASSERT(origin); | 53 ASSERT(origin); |
| 54 | 54 |
| 55 WebNotificationManager* notificationManager = Platform::current()->notificat
ionManager(); | 55 WebNotificationManager* notificationManager = Platform::current()->notificat
ionManager(); |
| 56 ASSERT(notificationManager); | 56 ASSERT(notificationManager); |
| 57 | 57 |
| 58 notificationManager->showPersistent(WebSerializedOrigin(*origin), notificati
on, serviceWorkerRegistration.webRegistration(), callbacks); | 58 notificationManager->showPersistent(WebSerializedOrigin(*origin), notificati
on, serviceWorkerRegistration.webRegistration(), callbacks); |
| 59 return promise; | 59 return promise; |
| 60 } | 60 } |
| 61 | 61 |
| 62 } // namespace blink | 62 } // namespace blink |
| OLD | NEW |