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

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

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
Index: Source/modules/notifications/Notification.h
diff --git a/Source/modules/notifications/Notification.h b/Source/modules/notifications/Notification.h
index 54b0ae4f9e75c543bfc57d819f2884f7f60208fa..3942dcc356fe87711780d3ef2813519663f3da24 100644
--- a/Source/modules/notifications/Notification.h
+++ b/Source/modules/notifications/Notification.h
@@ -47,14 +47,20 @@ namespace blink {
class ExecutionContext;
class NotificationOptions;
class NotificationPermissionCallback;
+struct WebNotificationData;
class Notification : public RefCountedGarbageCollectedWillBeGarbageCollectedFinalized<Notification>, public ActiveDOMObject, public EventTargetWithInlineData, public WebNotificationDelegate {
DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<Notification>);
DEFINE_WRAPPERTYPEINFO();
WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Notification);
public:
+ // Used for JavaScript instantiations of the Notification object. Will automatically schedule for
+ // the notification to be displayed to the user.
static Notification* create(ExecutionContext*, const String& title, const NotificationOptions&);
+ // Used for embedder-created Notification objects. Will initialize the Notification's state as showing.
+ static Notification* create(ExecutionContext*, const String& persistentId, const WebNotificationData&);
+
virtual ~Notification();
void close();
@@ -97,6 +103,8 @@ public:
private:
Notification(const String& title, ExecutionContext*);
+ void scheduleShow();
+
// Calling show() may start asynchronous operation. If this object has
// a V8 wrapper, hasPendingActivity() prevents the wrapper from being
// collected while m_state is Showing, and so this instance stays alive
@@ -110,6 +118,8 @@ private:
void setIconUrl(KURL iconUrl) { m_iconUrl = iconUrl; }
void setTag(const String& tag) { m_tag = tag; }
+ void setPersistentId(const String& persistentId) { m_persistentId = persistentId; }
+
private:
String m_title;
String m_dir;
@@ -119,12 +129,21 @@ private:
KURL m_iconUrl;
+ // Notifications can either be bound to the page, which means they're identified by
+ // their delegate, or persistent, which means they're identified by a persistent Id
+ // given to us by the embedder. This influences how we close the notification.
+ String m_persistentId;
+
enum NotificationState {
NotificationStateIdle,
NotificationStateShowing,
NotificationStateClosed
};
+ // Only to be used by the Notification::create() method when notifications were created
+ // by the embedder rather than by Blink.
+ void setState(NotificationState state) { m_state = state; }
+
NotificationState m_state;
AsyncMethodRunner<Notification> m_asyncRunner;

Powered by Google App Engine
This is Rietveld 408576698