| Index: Source/modules/notifications/Notification.cpp
|
| diff --git a/Source/modules/notifications/Notification.cpp b/Source/modules/notifications/Notification.cpp
|
| index 6c0587fff8cb74e626169073a0388e791b290785..51d0a27fd02f575102b0366fd09e2ae9c1d81511 100644
|
| --- a/Source/modules/notifications/Notification.cpp
|
| +++ b/Source/modules/notifications/Notification.cpp
|
| @@ -72,6 +72,25 @@ Notification* Notification::create(ExecutionContext* context, const String& titl
|
| ? UseCounter::NotificationSecureOrigin : UseCounter::NotificationInsecureOrigin;
|
| UseCounter::count(context, feature);
|
|
|
| + notification->scheduleShow();
|
| + notification->suspendIfNeeded();
|
| + return notification;
|
| +}
|
| +
|
| +Notification* Notification::create(ExecutionContext* context, const String& persistentId, const WebNotificationData& data)
|
| +{
|
| + Notification* notification = new Notification(data.title, context);
|
| +
|
| + notification->setPersistentId(persistentId);
|
| + notification->setDir(data.direction == WebNotificationData::DirectionLeftToRight ? "ltr" : "rtl");
|
| + notification->setLang(data.lang);
|
| + notification->setBody(data.body);
|
| + notification->setTag(data.tag);
|
| +
|
| + if (!data.icon.isEmpty())
|
| + notification->setIconUrl(data.icon);
|
| +
|
| + notification->setState(NotificationStateShowing);
|
| notification->suspendIfNeeded();
|
| return notification;
|
| }
|
| @@ -84,14 +103,20 @@ Notification::Notification(const String& title, ExecutionContext* context)
|
| , m_asyncRunner(this, &Notification::show)
|
| {
|
| ASSERT(notificationManager());
|
| -
|
| - m_asyncRunner.runAsync();
|
| }
|
|
|
| Notification::~Notification()
|
| {
|
| }
|
|
|
| +void Notification::scheduleShow()
|
| +{
|
| + ASSERT(m_state == NotificationStateIdle);
|
| + ASSERT(!m_asyncRunner.isActive());
|
| +
|
| + m_asyncRunner.runAsync();
|
| +}
|
| +
|
| void Notification::show()
|
| {
|
| ASSERT(m_state == NotificationStateIdle);
|
| @@ -117,7 +142,10 @@ void Notification::close()
|
| return;
|
|
|
| m_state = NotificationStateClosed;
|
| - notificationManager()->close(this);
|
| + if (!m_persistentId.isEmpty())
|
| + notificationManager()->closePersistent(m_persistentId);
|
| + else
|
| + notificationManager()->close(this);
|
| }
|
|
|
| void Notification::dispatchShowEvent()
|
|
|