| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 // TypeError exception. | 72 // TypeError exception. |
| 73 if (!registration.active()) | 73 if (!registration.active()) |
| 74 return ScriptPromise::reject( | 74 return ScriptPromise::reject( |
| 75 scriptState, | 75 scriptState, |
| 76 V8ThrowException::createTypeError(scriptState->isolate(), | 76 V8ThrowException::createTypeError(scriptState->isolate(), |
| 77 "No active registration available on " | 77 "No active registration available on " |
| 78 "the ServiceWorkerRegistration.")); | 78 "the ServiceWorkerRegistration.")); |
| 79 | 79 |
| 80 // If permission for notification's origin is not "granted", reject the | 80 // If permission for notification's origin is not "granted", reject the |
| 81 // promise with a TypeError exception, and terminate these substeps. | 81 // promise with a TypeError exception, and terminate these substeps. |
| 82 if (NotificationManager::from(executionContext)->permissionStatus() != | 82 if (NotificationManager::from(executionContext) |
| 83 ->permissionStatus(executionContext) != |
| 83 mojom::blink::PermissionStatus::GRANTED) | 84 mojom::blink::PermissionStatus::GRANTED) |
| 84 return ScriptPromise::reject( | 85 return ScriptPromise::reject( |
| 85 scriptState, | 86 scriptState, |
| 86 V8ThrowException::createTypeError( | 87 V8ThrowException::createTypeError( |
| 87 scriptState->isolate(), | 88 scriptState->isolate(), |
| 88 "No notification permission has been granted for this origin.")); | 89 "No notification permission has been granted for this origin.")); |
| 89 | 90 |
| 90 // Validate the developer-provided options to get the WebNotificationData. | 91 // Validate the developer-provided options to get the WebNotificationData. |
| 91 WebNotificationData data = createWebNotificationData(executionContext, title, | 92 WebNotificationData data = createWebNotificationData(executionContext, title, |
| 92 options, exceptionState); | 93 options, exceptionState); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 Platform::current()->notificationManager(); | 190 Platform::current()->notificationManager(); |
| 190 DCHECK(notificationManager); | 191 DCHECK(notificationManager); |
| 191 | 192 |
| 192 notificationManager->showPersistent( | 193 notificationManager->showPersistent( |
| 193 WebSecurityOrigin(origin.get()), data, loader->getResources(), | 194 WebSecurityOrigin(origin.get()), data, loader->getResources(), |
| 194 m_registration->webRegistration(), std::move(callbacks)); | 195 m_registration->webRegistration(), std::move(callbacks)); |
| 195 m_loaders.remove(loader); | 196 m_loaders.remove(loader); |
| 196 } | 197 } |
| 197 | 198 |
| 198 } // namespace blink | 199 } // namespace blink |
| OLD | NEW |