Index: third_party/WebKit/Source/modules/notifications/Notification.h |
diff --git a/third_party/WebKit/Source/modules/notifications/Notification.h b/third_party/WebKit/Source/modules/notifications/Notification.h |
index bff947dbf62cbb5b3136c7f4ca04d78cd59f3d30..8291bdaa1e6ca1f38cabd17c5bd3eb878d41b38c 100644 |
--- a/third_party/WebKit/Source/modules/notifications/Notification.h |
+++ b/third_party/WebKit/Source/modules/notifications/Notification.h |
@@ -52,8 +52,6 @@ |
namespace blink { |
class ExecutionContext; |
-class NotificationAction; |
-class NotificationManager; |
class NotificationOptions; |
class NotificationPermissionCallback; |
class NotificationResourcesLoader; |
@@ -63,12 +61,13 @@ class MODULES_EXPORT Notification final : public EventTargetWithInlineData, publ |
USING_GARBAGE_COLLECTED_MIXIN(Notification); |
DEFINE_WRAPPERTYPEINFO(); |
public: |
- // Used for JavaScript instantiations of the Notification object. Will automatically schedule for |
- // the notification to be displayed to the user when the developer-provided data is valid. |
+ // Used for JavaScript instantiations of non-persistent notifications. Will |
+ // automatically schedule for the notification to be displayed to the user |
+ // when the developer-provided data is valid. |
static Notification* create(ExecutionContext*, const String& title, const NotificationOptions&, ExceptionState&); |
- // Used for embedder-created Notification objects. If |showing| is true, will initialize the |
- // Notification's state as showing, or as closed otherwise. |
+ // Used for embedder-created persistent notifications. Initializes the state |
+ // of the notification as either Showing or Closed based on |showing|. |
static Notification* create(ExecutionContext*, const String& notificationId, const WebNotificationData&, bool showing); |
~Notification() override; |
@@ -125,42 +124,50 @@ protected: |
DispatchEventResult dispatchEventInternal(Event*) final; |
private: |
- Notification(ExecutionContext*, const WebNotificationData&); |
+ // The type of notification this instance represents. Non-persistent |
+ // notifications will have events delivered to their instance, whereas |
+ // persistent notification will be using a Service Worker. |
+ enum class Type { |
+ NonPersistent, |
+ Persistent |
+ }; |
+ |
+ // The current phase of the notification in its lifecycle. |
+ enum class State { |
+ Loading, |
+ Showing, |
+ Closing, |
+ Closed |
+ }; |
+ |
+ Notification(ExecutionContext*, Type, const WebNotificationData&); |
+ |
+ // Sets the state of the notification in its lifecycle. |
+ void setState(State state) { m_state = state; } |
+ |
+ // Sets the notification ID to |notificationId|. This should be done once |
+ // the notification has shown for non-persistent notifications, and at |
+ // object initialisation time for persistent notifications. |
+ void setNotificationId(const String& notificationId) { m_notificationId = notificationId; } |
// Schedules an asynchronous call to |prepareShow|, allowing the constructor |
// to return so that events can be fired on the notification object. |
void schedulePrepareShow(); |
- // Checks permission and loads any necessary resources (this may be async) |
- // before showing the notification. |
+ // Verifies that permission has been granted, then asynchronously starts |
+ // loading the resources associated with this notification. |
void prepareShow(); |
- // Shows the notification, using the resources loaded by the |
- // NotificationResourcesLoader. |
+ // Shows the notification through the embedder using the loaded resources. |
void didLoadResources(NotificationResourcesLoader*); |
- void setNotificationId(const String& notificationId) { m_notificationId = notificationId; } |
+ Type m_type; |
+ State m_state; |
WebNotificationData m_data; |
- // 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_notificationId; |
- enum NotificationState { |
- NotificationStateIdle, |
- NotificationStateShowing, |
- NotificationStateClosing, |
- 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; |
- |
Member<AsyncMethodRunner<Notification>> m_prepareShowMethodRunner; |
Member<NotificationResourcesLoader> m_loader; |