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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 30 matching lines...) Expand all
41 #include "core/dom/ExecutionContextTask.h" 41 #include "core/dom/ExecutionContextTask.h"
42 #include "core/dom/ScopedWindowFocusAllowedIndicator.h" 42 #include "core/dom/ScopedWindowFocusAllowedIndicator.h"
43 #include "core/events/Event.h" 43 #include "core/events/Event.h"
44 #include "core/frame/UseCounter.h" 44 #include "core/frame/UseCounter.h"
45 #include "modules/notifications/NotificationOptions.h" 45 #include "modules/notifications/NotificationOptions.h"
46 #include "modules/notifications/NotificationPermissionClient.h" 46 #include "modules/notifications/NotificationPermissionClient.h"
47 #include "platform/RuntimeEnabledFeatures.h" 47 #include "platform/RuntimeEnabledFeatures.h"
48 #include "platform/UserGestureIndicator.h" 48 #include "platform/UserGestureIndicator.h"
49 #include "public/platform/Platform.h" 49 #include "public/platform/Platform.h"
50 #include "public/platform/WebSerializedOrigin.h" 50 #include "public/platform/WebSerializedOrigin.h"
51 #include "public/platform/WebString.h"
51 #include "public/platform/modules/notifications/WebNotificationData.h" 52 #include "public/platform/modules/notifications/WebNotificationData.h"
52 #include "public/platform/modules/notifications/WebNotificationManager.h" 53 #include "public/platform/modules/notifications/WebNotificationManager.h"
53 54
54 namespace blink { 55 namespace blink {
55 namespace { 56 namespace {
56 57
57 WebNotificationManager* notificationManager() 58 WebNotificationManager* notificationManager()
58 { 59 {
59 return Platform::current()->notificationManager(); 60 return Platform::current()->notificationManager();
60 } 61 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 notification->setPersistentId(persistentId); 115 notification->setPersistentId(persistentId);
115 notification->setDir(data.direction == WebNotificationData::DirectionLeftToR ight ? "ltr" : "rtl"); 116 notification->setDir(data.direction == WebNotificationData::DirectionLeftToR ight ? "ltr" : "rtl");
116 notification->setLang(data.lang); 117 notification->setLang(data.lang);
117 notification->setBody(data.body); 118 notification->setBody(data.body);
118 notification->setTag(data.tag); 119 notification->setTag(data.tag);
119 notification->setSilent(data.silent); 120 notification->setSilent(data.silent);
120 121
121 if (!data.icon.isEmpty()) 122 if (!data.icon.isEmpty())
122 notification->setIconUrl(data.icon); 123 notification->setIconUrl(data.icon);
123 124
125 if (!data.data.isEmpty()) {
126 notification->setSerializedData(SerializedScriptValueFactory::instance() .createFromWire(data.data));
127 notification->serializedData()->registerMemoryAllocatedWithCurrentScript Context();
128 }
129
124 notification->setState(NotificationStateShowing); 130 notification->setState(NotificationStateShowing);
125 notification->suspendIfNeeded(); 131 notification->suspendIfNeeded();
126 return notification; 132 return notification;
127 } 133 }
128 134
129 Notification::Notification(const String& title, ExecutionContext* context) 135 Notification::Notification(const String& title, ExecutionContext* context)
130 : ActiveDOMObject(context) 136 : ActiveDOMObject(context)
131 , m_title(title) 137 , m_title(title)
132 , m_dir("auto") 138 , m_dir("auto")
133 , m_silent(false) 139 , m_silent(false)
(...skipping 21 matching lines...) Expand all
155 if (Notification::checkPermission(executionContext()) != WebNotificationPerm issionAllowed) { 161 if (Notification::checkPermission(executionContext()) != WebNotificationPerm issionAllowed) {
156 dispatchErrorEvent(); 162 dispatchErrorEvent();
157 return; 163 return;
158 } 164 }
159 165
160 SecurityOrigin* origin = executionContext()->securityOrigin(); 166 SecurityOrigin* origin = executionContext()->securityOrigin();
161 ASSERT(origin); 167 ASSERT(origin);
162 168
163 // FIXME: Do CSP checks on the associated notification icon. 169 // FIXME: Do CSP checks on the associated notification icon.
164 WebNotificationData::Direction dir = m_dir == "rtl" ? WebNotificationData::D irectionRightToLeft : WebNotificationData::DirectionLeftToRight; 170 WebNotificationData::Direction dir = m_dir == "rtl" ? WebNotificationData::D irectionRightToLeft : WebNotificationData::DirectionLeftToRight;
165 WebNotificationData notificationData(m_title, dir, m_lang, m_body, m_tag, m_ iconUrl, m_silent); 171
172 // 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
173 // The lifetime and availability of non-persistent notifications
174 // is tied to the page they were created by, and thus the data
175 // doesn't have to be known to the embedder.
176 String emptyDataAsWireString;
177 WebNotificationData notificationData(m_title, dir, m_lang, m_body, m_tag, m_ iconUrl, m_silent, emptyDataAsWireString);
166 notificationManager()->show(WebSerializedOrigin(*origin), notificationData, this); 178 notificationManager()->show(WebSerializedOrigin(*origin), notificationData, this);
167 179
168 m_state = NotificationStateShowing; 180 m_state = NotificationStateShowing;
169 } 181 }
170 182
171 void Notification::close() 183 void Notification::close()
172 { 184 {
173 if (m_state != NotificationStateShowing) 185 if (m_state != NotificationStateShowing)
174 return; 186 return;
175 187
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 return ScriptValue(scriptState, m_serializedData->deserialize(scriptState->i solate())); 304 return ScriptValue(scriptState, m_serializedData->deserialize(scriptState->i solate()));
293 } 305 }
294 306
295 DEFINE_TRACE(Notification) 307 DEFINE_TRACE(Notification)
296 { 308 {
297 RefCountedGarbageCollectedEventTargetWithInlineData<Notification>::trace(vis itor); 309 RefCountedGarbageCollectedEventTargetWithInlineData<Notification>::trace(vis itor);
298 ActiveDOMObject::trace(visitor); 310 ActiveDOMObject::trace(visitor);
299 } 311 }
300 312
301 } // namespace blink 313 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698