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

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

Issue 2338483004: Clean up the Notification class in advance of merging the Close methods (Closed)
Patch Set: Clean up the Notification class in advance of merging the Close methods Created 4 years, 3 months 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 | « no previous file | third_party/WebKit/Source/modules/notifications/Notification.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/notifications/Notification.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698