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

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

Issue 1005353002: Add data property in persistent web notification (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/Notification.cpp
diff --git a/Source/modules/notifications/Notification.cpp b/Source/modules/notifications/Notification.cpp
index 89fe61c4ffa0bb89b62a3e2a24cea916ee94f0f0..6f59fbd158e5ac182a18b8b30d801ffe296357cf 100644
--- a/Source/modules/notifications/Notification.cpp
+++ b/Source/modules/notifications/Notification.cpp
@@ -48,6 +48,7 @@
#include "platform/UserGestureIndicator.h"
#include "public/platform/Platform.h"
#include "public/platform/WebSerializedOrigin.h"
+#include "public/platform/WebString.h"
#include "public/platform/modules/notifications/WebNotificationData.h"
#include "public/platform/modules/notifications/WebNotificationManager.h"
@@ -121,6 +122,11 @@ Notification* Notification::create(ExecutionContext* context, const String& pers
if (!data.icon.isEmpty())
notification->setIconUrl(data.icon);
+ if (!data.data.isEmpty()) {
+ notification->setSerializedData(SerializedScriptValueFactory::instance().createFromWire(data.data));
+ notification->serializedData()->registerMemoryAllocatedWithCurrentScriptContext();
+ }
+
notification->setState(NotificationStateShowing);
notification->suspendIfNeeded();
return notification;
@@ -162,7 +168,13 @@ void Notification::show()
// FIXME: Do CSP checks on the associated notification icon.
WebNotificationData::Direction dir = m_dir == "rtl" ? WebNotificationData::DirectionRightToLeft : WebNotificationData::DirectionLeftToRight;
- WebNotificationData notificationData(m_title, dir, m_lang, m_body, m_tag, m_iconUrl, m_silent);
+
+ // No send data property in non-persistent notification.
Peter Beverloo 2015/03/15 22:35:04 nit: drop line 172, it doesn't add anything. Lines
Sanghyun Park 2015/03/16 00:00:21 I'll fix this
+ // The lifetime and availability of non-persistent notifications
+ // is tied to the page they were created by, and thus the data
+ // doesn't have to be known to the embedder.
+ String emptyDataAsWireString;
+ WebNotificationData notificationData(m_title, dir, m_lang, m_body, m_tag, m_iconUrl, m_silent, emptyDataAsWireString);
notificationManager()->show(WebSerializedOrigin(*origin), notificationData, this);
m_state = NotificationStateShowing;

Powered by Google App Engine
This is Rietveld 408576698