| Index: Source/modules/notifications/Notification.cpp
|
| diff --git a/Source/modules/notifications/Notification.cpp b/Source/modules/notifications/Notification.cpp
|
| index 4822a20c94ea8521ccb12068a90dbcb1ff8198d6..867e438265d8171fc5c7cefd73b3a477a9b5f150 100644
|
| --- a/Source/modules/notifications/Notification.cpp
|
| +++ b/Source/modules/notifications/Notification.cpp
|
| @@ -55,6 +55,8 @@
|
| namespace blink {
|
| namespace {
|
|
|
| +const int64_t kInvalidPersistentId = -1;
|
| +
|
| WebNotificationManager* notificationManager()
|
| {
|
| return Platform::current()->notificationManager();
|
| @@ -108,7 +110,7 @@ Notification* Notification::create(ExecutionContext* context, const String& titl
|
| return notification;
|
| }
|
|
|
| -Notification* Notification::create(ExecutionContext* context, const String& persistentId, const WebNotificationData& data)
|
| +Notification* Notification::create(ExecutionContext* context, int64_t persistentId, const WebNotificationData& data)
|
| {
|
| Notification* notification = new Notification(data.title, context);
|
|
|
| @@ -133,11 +135,37 @@ Notification* Notification::create(ExecutionContext* context, const String& pers
|
| return notification;
|
| }
|
|
|
| +Notification* Notification::create(ExecutionContext* context, const String& persistentId, const WebNotificationData& data)
|
| +{
|
| + Notification* notification = new Notification(data.title, context);
|
| +
|
| + notification->setPersistentIdString(persistentId);
|
| + notification->setDir(data.direction == WebNotificationData::DirectionLeftToRight ? "ltr" : "rtl");
|
| + notification->setLang(data.lang);
|
| + notification->setBody(data.body);
|
| + notification->setTag(data.tag);
|
| + notification->setSilent(data.silent);
|
| +
|
| + if (!data.icon.isEmpty())
|
| + notification->setIconUrl(data.icon);
|
| +
|
| + const WebVector<char>& dataBytes = data.data;
|
| + if (!dataBytes.isEmpty()) {
|
| + notification->setSerializedData(SerializedScriptValueFactory::instance().createFromWireBytes(dataBytes.data(), dataBytes.size()));
|
| + notification->serializedData()->registerMemoryAllocatedWithCurrentScriptContext();
|
| + }
|
| +
|
| + notification->setState(NotificationStateShowing);
|
| + notification->suspendIfNeeded();
|
| + return notification;
|
| +}
|
| +
|
| Notification::Notification(const String& title, ExecutionContext* context)
|
| : ActiveDOMObject(context)
|
| , m_title(title)
|
| , m_dir("auto")
|
| , m_silent(false)
|
| + , m_persistentId(kInvalidPersistentId)
|
| , m_state(NotificationStateIdle)
|
| , m_asyncRunner(this, &Notification::show)
|
| {
|
| @@ -185,7 +213,7 @@ void Notification::close()
|
| if (m_state != NotificationStateShowing)
|
| return;
|
|
|
| - if (m_persistentId.isEmpty()) {
|
| + if (m_persistentIdString.isEmpty() && m_persistentId == kInvalidPersistentId) {
|
| // Fire the close event asynchronously.
|
| executionContext()->postTask(FROM_HERE, createSameThreadTask(&Notification::dispatchCloseEvent, this));
|
|
|
| @@ -197,7 +225,10 @@ void Notification::close()
|
| SecurityOrigin* origin = executionContext()->securityOrigin();
|
| ASSERT(origin);
|
|
|
| - notificationManager()->closePersistent(WebSerializedOrigin(*origin), m_persistentId);
|
| + if (!m_persistentIdString.isEmpty())
|
| + notificationManager()->closePersistent(WebSerializedOrigin(*origin), m_persistentIdString);
|
| + else
|
| + notificationManager()->closePersistent(WebSerializedOrigin(*origin), m_persistentId);
|
| }
|
| }
|
|
|
|
|