| 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/ExceptionState.h" | 9 #include "bindings/core/v8/ExceptionState.h" |
| 10 #include "bindings/core/v8/ScriptPromiseResolver.h" | 10 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 Vector<char> dataAsWireBytes; | 67 Vector<char> dataAsWireBytes; |
| 68 if (options.hasData()) { | 68 if (options.hasData()) { |
| 69 RefPtr<SerializedScriptValue> data = SerializedScriptValueFactory::insta
nce().create(options.data().isolate(), options.data(), nullptr, exceptionState); | 69 RefPtr<SerializedScriptValue> data = SerializedScriptValueFactory::insta
nce().create(options.data().isolate(), options.data(), nullptr, exceptionState); |
| 70 if (exceptionState.hadException()) | 70 if (exceptionState.hadException()) |
| 71 return exceptionState.reject(scriptState); | 71 return exceptionState.reject(scriptState); |
| 72 | 72 |
| 73 data->toWireBytes(dataAsWireBytes); | 73 data->toWireBytes(dataAsWireBytes); |
| 74 } | 74 } |
| 75 | 75 |
| 76 for (const NotificationAction& action : options.actions()) { | 76 for (const NotificationAction& action : options.actions()) { |
| 77 if (action.action().isEmpty()) |
| 78 return ScriptPromise::reject(scriptState, V8ThrowException::createTy
peError(scriptState->isolate(), "NotificationAction action must not be empty."))
; |
| 77 if (action.title().isEmpty()) | 79 if (action.title().isEmpty()) |
| 78 return ScriptPromise::reject(scriptState, V8ThrowException::createTy
peError(scriptState->isolate(), "Notification action titles must not be empty.")
); | 80 return ScriptPromise::reject(scriptState, V8ThrowException::createTy
peError(scriptState->isolate(), "NotificationAction title must not be empty.")); |
| 79 } | 81 } |
| 80 | 82 |
| 81 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); | 83 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); |
| 82 ScriptPromise promise = resolver->promise(); | 84 ScriptPromise promise = resolver->promise(); |
| 83 | 85 |
| 84 // FIXME: Do the appropriate CORS checks on the icon URL. | 86 // FIXME: Do the appropriate CORS checks on the icon URL. |
| 85 | 87 |
| 86 KURL iconUrl; | 88 KURL iconUrl; |
| 87 if (options.hasIcon() && !options.icon().isEmpty()) { | 89 if (options.hasIcon() && !options.icon().isEmpty()) { |
| 88 iconUrl = executionContext->completeURL(options.icon()); | 90 iconUrl = executionContext->completeURL(options.icon()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 115 WebNotificationGetCallbacks* callbacks = new CallbackPromiseAdapter<Notifica
tionArray, void>(resolver); | 117 WebNotificationGetCallbacks* callbacks = new CallbackPromiseAdapter<Notifica
tionArray, void>(resolver); |
| 116 | 118 |
| 117 WebNotificationManager* notificationManager = Platform::current()->notificat
ionManager(); | 119 WebNotificationManager* notificationManager = Platform::current()->notificat
ionManager(); |
| 118 ASSERT(notificationManager); | 120 ASSERT(notificationManager); |
| 119 | 121 |
| 120 notificationManager->getNotifications(options.tag(), serviceWorkerRegistrati
on.webRegistration(), callbacks); | 122 notificationManager->getNotifications(options.tag(), serviceWorkerRegistrati
on.webRegistration(), callbacks); |
| 121 return promise; | 123 return promise; |
| 122 } | 124 } |
| 123 | 125 |
| 124 } // namespace blink | 126 } // namespace blink |
| OLD | NEW |