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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 // If permission for notification's origin is not "granted", reject promise
with a TypeError exception, and terminate these substeps. | 66 // If permission for notification's origin is not "granted", reject promise
with a TypeError exception, and terminate these substeps. |
67 if (Notification::checkPermission(executionContext) != WebNotificationPermis
sionAllowed) | 67 if (Notification::checkPermission(executionContext) != WebNotificationPermis
sionAllowed) |
68 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr
ror(scriptState->isolate(), "No notification permission has been granted for thi
s origin.")); | 68 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr
ror(scriptState->isolate(), "No notification permission has been granted for thi
s origin.")); |
69 | 69 |
70 if (options.hasVibrate() && options.silent()) | 70 if (options.hasVibrate() && options.silent()) |
71 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr
ror(scriptState->isolate(), "Silent notifications must not specify vibration pat
terns.")); | 71 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr
ror(scriptState->isolate(), "Silent notifications must not specify vibration pat
terns.")); |
72 | 72 |
73 // FIXME: Unify the code path here with the Notification.create() function. | 73 // FIXME: Unify the code path here with the Notification.create() function. |
74 Vector<char> dataAsWireBytes; | 74 Vector<char> dataAsWireBytes; |
75 if (options.hasData()) { | 75 if (options.hasData()) { |
76 RefPtr<SerializedScriptValue> data = SerializedScriptValueFactory::insta
nce().create(options.data(), nullptr, exceptionState, options.data().isolate()); | 76 RefPtr<SerializedScriptValue> data = SerializedScriptValueFactory::insta
nce().create(options.data().isolate(), options.data(), nullptr, exceptionState); |
77 if (exceptionState.hadException()) | 77 if (exceptionState.hadException()) |
78 return exceptionState.reject(scriptState); | 78 return exceptionState.reject(scriptState); |
79 | 79 |
80 data->toWireBytes(dataAsWireBytes); | 80 data->toWireBytes(dataAsWireBytes); |
81 } | 81 } |
82 | 82 |
83 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); | 83 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); |
84 ScriptPromise promise = resolver->promise(); | 84 ScriptPromise promise = resolver->promise(); |
85 | 85 |
86 // FIXME: Do the appropriate CORS checks on the icon URL. | 86 // FIXME: Do the appropriate CORS checks on the icon URL. |
(...skipping 28 matching lines...) Expand all Loading... |
115 WebNotificationGetCallbacks* callbacks = new CallbackPromiseAdapter<Notifica
tionArray, void>(resolver); | 115 WebNotificationGetCallbacks* callbacks = new CallbackPromiseAdapter<Notifica
tionArray, void>(resolver); |
116 | 116 |
117 WebNotificationManager* notificationManager = Platform::current()->notificat
ionManager(); | 117 WebNotificationManager* notificationManager = Platform::current()->notificat
ionManager(); |
118 ASSERT(notificationManager); | 118 ASSERT(notificationManager); |
119 | 119 |
120 notificationManager->getNotifications(options.tag(), serviceWorkerRegistrati
on.webRegistration(), callbacks); | 120 notificationManager->getNotifications(options.tag(), serviceWorkerRegistrati
on.webRegistration(), callbacks); |
121 return promise; | 121 return promise; |
122 } | 122 } |
123 | 123 |
124 } // namespace blink | 124 } // namespace blink |
OLD | NEW |