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

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
« no previous file with comments | « no previous file | Source/modules/notifications/ServiceWorkerRegistrationNotifications.h » ('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 89fe61c4ffa0bb89b62a3e2a24cea916ee94f0f0..1dd3a947ddb0548d6fcab6eca34bee9fbbf68786 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,11 @@ 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);
+
+ // 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;
« no previous file with comments | « no previous file | Source/modules/notifications/ServiceWorkerRegistrationNotifications.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698