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

Unified Diff: Source/modules/notifications/Notification.cpp

Issue 789643003: The Service Worker notificationclick event should carry a notification. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years 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 | « Source/modules/notifications/Notification.h ('k') | Source/web/ServiceWorkerGlobalScopeProxy.cpp » ('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 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()
« no previous file with comments | « Source/modules/notifications/Notification.h ('k') | Source/web/ServiceWorkerGlobalScopeProxy.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698