Chromium Code Reviews| 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..c00485f3ae29291f047f76f200a4e1877bfe43d7 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 NotificationType { |
|
johnme
2016/09/16 14:14:35
Nit: s/Notification::NotificationType/Notification
Peter Beverloo
2016/09/16 14:45:37
Done.
|
| + NonPersistent, |
| + Persistent |
| + }; |
| + |
| + // The current phase of the notification in its lifetime. |
| + enum class NotificationState { |
|
johnme
2016/09/16 14:14:35
Nit: s/Notification::NotificationState/Notificatio
Peter Beverloo
2016/09/16 14:45:37
Done.
|
| + Loading, |
| + Showing, |
| + Closing, |
| + Closed |
| + }; |
| + |
| + Notification(ExecutionContext*, NotificationType, const WebNotificationData&); |
| + |
| + // Sets the state of the notification in its lifetime. |
|
johnme
2016/09/16 14:14:35
Nit: s/lifetime/lifecycle/ ?
Peter Beverloo
2016/09/16 14:45:37
Done.
|
| + void setState(NotificationState 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; } |
| + NotificationType m_type; |
| + NotificationState 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; |