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

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

Issue 993893002: Add the data attribute to the Notification object (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix layout test failures. 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
« no previous file with comments | « Source/modules/notifications/Notification.h ('k') | Source/modules/notifications/Notification.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/notifications/Notification.cpp
diff --git a/Source/modules/notifications/Notification.cpp b/Source/modules/notifications/Notification.cpp
index 1ae79f16e69b4af63edbbd9a5138601a727f6436..89fe61c4ffa0bb89b62a3e2a24cea916ee94f0f0 100644
--- a/Source/modules/notifications/Notification.cpp
+++ b/Source/modules/notifications/Notification.cpp
@@ -31,7 +31,11 @@
#include "config.h"
#include "modules/notifications/Notification.h"
+#include "bindings/core/v8/ExceptionState.h"
+#include "bindings/core/v8/ScriptState.h"
+#include "bindings/core/v8/ScriptValue.h"
#include "bindings/core/v8/ScriptWrappable.h"
+#include "bindings/core/v8/SerializedScriptValueFactory.h"
#include "core/dom/Document.h"
#include "core/dom/ExecutionContext.h"
#include "core/dom/ExecutionContextTask.h"
@@ -72,6 +76,13 @@ Notification* Notification::create(ExecutionContext* context, const String& titl
return nullptr;
}
+ RefPtr<SerializedScriptValue> data;
+ if (options.hasData()) {
+ data = SerializedScriptValueFactory::instance().create(options.data(), nullptr, exceptionState, options.data().isolate());
+ if (exceptionState.hadException())
+ return nullptr;
+ }
+
Notification* notification = new Notification(title, context);
notification->setBody(options.body());
@@ -79,6 +90,7 @@ Notification* Notification::create(ExecutionContext* context, const String& titl
notification->setLang(options.lang());
notification->setDir(options.dir());
notification->setSilent(options.silent());
+ notification->setSerializedData(data.release());
if (options.hasIcon()) {
KURL iconUrl = options.icon().isEmpty() ? KURL() : context->completeURL(options.icon());
if (!iconUrl.isEmpty() && iconUrl.isValid())
@@ -272,6 +284,14 @@ bool Notification::hasPendingActivity() const
return m_state == NotificationStateShowing || m_asyncRunner.isActive();
}
+ScriptValue Notification::data(ScriptState* scriptState) const
+{
+ if (!m_serializedData)
+ return ScriptValue::createNull(scriptState);
+
+ return ScriptValue(scriptState, m_serializedData->deserialize(scriptState->isolate()));
+}
+
DEFINE_TRACE(Notification)
{
RefCountedGarbageCollectedEventTargetWithInlineData<Notification>::trace(visitor);
« no previous file with comments | « Source/modules/notifications/Notification.h ('k') | Source/modules/notifications/Notification.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698