Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1130)

Unified Diff: Source/modules/notifications/ServiceWorkerRegistrationNotifications.cpp

Issue 993893002: Add the data attribute to the Notification object (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/modules/notifications/ServiceWorkerRegistrationNotifications.cpp
diff --git a/Source/modules/notifications/ServiceWorkerRegistrationNotifications.cpp b/Source/modules/notifications/ServiceWorkerRegistrationNotifications.cpp
index eaf56e840d7437aab3a97453af1835a9dce4f7e9..2a5975005d4ea99de689779ac38d9874526af2f6 100644
--- a/Source/modules/notifications/ServiceWorkerRegistrationNotifications.cpp
+++ b/Source/modules/notifications/ServiceWorkerRegistrationNotifications.cpp
@@ -6,7 +6,11 @@
#include "modules/notifications/ServiceWorkerRegistrationNotifications.h"
#include "bindings/core/v8/CallbackPromiseAdapter.h"
+#include "bindings/core/v8/ExceptionState.h"
#include "bindings/core/v8/ScriptPromiseResolver.h"
+#include "bindings/core/v8/ScriptValue.h"
+#include "bindings/core/v8/SerializedScriptValue.h"
+#include "bindings/core/v8/SerializedScriptValueFactory.h"
#include "bindings/core/v8/V8ThrowException.h"
#include "core/dom/DOMException.h"
#include "core/dom/ExceptionCode.h"
@@ -21,7 +25,7 @@
namespace blink {
-ScriptPromise ServiceWorkerRegistrationNotifications::showNotification(ScriptState* scriptState, ServiceWorkerRegistration& serviceWorkerRegistration, const String& title, const NotificationOptions& options)
+ScriptPromise ServiceWorkerRegistrationNotifications::showNotification(ScriptState* scriptState, ServiceWorkerRegistration& serviceWorkerRegistration, const String& title, const NotificationOptions& options, ExceptionState& exceptionState)
{
ExecutionContext* executionContext = scriptState->executionContext();
@@ -36,6 +40,14 @@ ScriptPromise ServiceWorkerRegistrationNotifications::showNotification(ScriptSta
RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scriptState);
ScriptPromise promise = resolver->promise();
+ // FIXME: Unifying these code paths at some point in the future
Peter Beverloo 2015/03/12 01:16:26 micro nit: Unifying -> Unify. It would also be goo
Sanghyun Park 2015/03/12 02:58:47 I'll fix this.
+ RefPtr<SerializedScriptValue> data;
+ if (options.hasData()) {
+ data = SerializedScriptValueFactory::instance().create(options.data(), 0, exceptionState, options.data().isolate());
+ if (exceptionState.hadException())
+ return ScriptPromise::reject(scriptState, V8ThrowException::createTypeError(scriptState->isolate(), "No data property can be serialized"));
Peter Beverloo 2015/03/12 01:16:26 Per the specification: "4. Set notification's
Peter Beverloo 2015/03/12 02:28:50 Scrap the above :-). Right now you're throwing a
Sanghyun Park 2015/03/12 02:58:47 I see. Thank you so much for finding solution. I'l
+ }
+
// FIXME: Do the appropriate CORS checks on the icon URL.
KURL iconUrl;
@@ -46,7 +58,7 @@ ScriptPromise ServiceWorkerRegistrationNotifications::showNotification(ScriptSta
}
WebNotificationData::Direction dir = options.dir() == "rtl" ? WebNotificationData::DirectionRightToLeft : WebNotificationData::DirectionLeftToRight;
- WebNotificationData notification(title, dir, options.lang(), options.body(), options.tag(), iconUrl, options.silent());
+ WebNotificationData notification(title, dir, options.lang(), options.body(), options.tag(), iconUrl, options.silent(), data.release());
WebNotificationShowCallbacks* callbacks = new CallbackPromiseAdapter<void, void>(resolver);
SecurityOrigin* origin = executionContext->securityOrigin();

Powered by Google App Engine
This is Rietveld 408576698