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 <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 9 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
10 #include "bindings/core/v8/ExceptionState.h" | 10 #include "bindings/core/v8/ExceptionState.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 ServiceWorkerRegistration* registration) | 59 ServiceWorkerRegistration* registration) |
60 : ContextLifecycleObserver(execution_context), | 60 : ContextLifecycleObserver(execution_context), |
61 registration_(registration) {} | 61 registration_(registration) {} |
62 | 62 |
63 ScriptPromise ServiceWorkerRegistrationNotifications::showNotification( | 63 ScriptPromise ServiceWorkerRegistrationNotifications::showNotification( |
64 ScriptState* script_state, | 64 ScriptState* script_state, |
65 ServiceWorkerRegistration& registration, | 65 ServiceWorkerRegistration& registration, |
66 const String& title, | 66 const String& title, |
67 const NotificationOptions& options, | 67 const NotificationOptions& options, |
68 ExceptionState& exception_state) { | 68 ExceptionState& exception_state) { |
69 ExecutionContext* execution_context = script_state->GetExecutionContext(); | 69 ExecutionContext* execution_context = ExecutionContext::From(script_state); |
70 | 70 |
71 // If context object's active worker is null, reject the promise with a | 71 // If context object's active worker is null, reject the promise with a |
72 // TypeError exception. | 72 // TypeError exception. |
73 if (!registration.active()) | 73 if (!registration.active()) |
74 return ScriptPromise::Reject( | 74 return ScriptPromise::Reject( |
75 script_state, | 75 script_state, |
76 V8ThrowException::CreateTypeError(script_state->GetIsolate(), | 76 V8ThrowException::CreateTypeError(script_state->GetIsolate(), |
77 "No active registration available on " | 77 "No active registration available on " |
78 "the ServiceWorkerRegistration.")); | 78 "the ServiceWorkerRegistration.")); |
79 | 79 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 Platform::Current()->GetNotificationManager(); | 191 Platform::Current()->GetNotificationManager(); |
192 DCHECK(notification_manager); | 192 DCHECK(notification_manager); |
193 | 193 |
194 notification_manager->ShowPersistent( | 194 notification_manager->ShowPersistent( |
195 WebSecurityOrigin(origin.Get()), data, loader->GetResources(), | 195 WebSecurityOrigin(origin.Get()), data, loader->GetResources(), |
196 registration_->WebRegistration(), std::move(callbacks)); | 196 registration_->WebRegistration(), std::move(callbacks)); |
197 loaders_.erase(loader); | 197 loaders_.erase(loader); |
198 } | 198 } |
199 | 199 |
200 } // namespace blink | 200 } // namespace blink |
OLD | NEW |