Chromium Code Reviews| Index: Source/modules/notifications/Notification.cpp |
| diff --git a/Source/modules/notifications/Notification.cpp b/Source/modules/notifications/Notification.cpp |
| index 0a8cf69dae08118ca53c7ea87a16e0f59bf85c07..e5a0915ad931860328073e33f5efb0214263f8f9 100644 |
| --- a/Source/modules/notifications/Notification.cpp |
| +++ b/Source/modules/notifications/Notification.cpp |
| @@ -31,7 +31,10 @@ |
| #include "config.h" |
| #include "modules/notifications/Notification.h" |
| +#include "bindings/core/v8/ExceptionState.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 +75,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 +89,7 @@ Notification* Notification::create(ExecutionContext* context, const String& titl |
| notification->setLang(options.lang()); |
| notification->setDir(options.dir()); |
| notification->setSilent(options.silent()); |
| + notification->setData(data.release()); |
| if (options.hasIcon()) { |
| KURL iconUrl = options.icon().isEmpty() ? KURL() : context->completeURL(options.icon()); |
| if (!iconUrl.isEmpty() && iconUrl.isValid()) |
| @@ -109,6 +120,11 @@ Notification* Notification::create(ExecutionContext* context, const String& pers |
| if (!data.icon.isEmpty()) |
| notification->setIconUrl(data.icon); |
| + if (!data.data.isNull()) { |
| + notification->setData(data.data); |
| + notification->data()->registerMemoryAllocatedWithCurrentScriptContext(); |
| + } |
| + |
| notification->setState(NotificationStateShowing); |
| notification->suspendIfNeeded(); |
| return notification; |
| @@ -150,7 +166,7 @@ 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); |
| + WebNotificationData notificationData(m_title, dir, m_lang, m_body, m_tag, m_iconUrl, m_silent, m_data.get()); |
|
Peter Beverloo
2015/03/12 01:16:26
Why does the embedder have to know about the data
Sanghyun Park
2015/03/12 02:58:47
I understand about your meant.
non-persistent do n
Sanghyun Park
2015/03/12 11:52:58
When I think of that, above suggested way is not g
Sanghyun Park
2015/03/12 12:39:36
Oops. I was wrong. we can use PassRefPtr<Serialize
|
| notificationManager()->show(WebSerializedOrigin(*origin), notificationData, this); |
| m_state = NotificationStateShowing; |