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

Side by Side Diff: third_party/WebKit/Source/modules/notifications/Notification.h

Issue 2300093002: Make //content responsible for generating notification Ids (Closed)
Patch Set: comments 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 class MODULES_EXPORT Notification final : public EventTargetWithInlineData, publ ic ActiveScriptWrappable, public ActiveDOMObject, public WebNotificationDelegate { 62 class MODULES_EXPORT Notification final : public EventTargetWithInlineData, publ ic ActiveScriptWrappable, public ActiveDOMObject, public WebNotificationDelegate {
63 USING_GARBAGE_COLLECTED_MIXIN(Notification); 63 USING_GARBAGE_COLLECTED_MIXIN(Notification);
64 DEFINE_WRAPPERTYPEINFO(); 64 DEFINE_WRAPPERTYPEINFO();
65 public: 65 public:
66 // Used for JavaScript instantiations of the Notification object. Will autom atically schedule for 66 // Used for JavaScript instantiations of the Notification object. Will autom atically schedule for
67 // the notification to be displayed to the user when the developer-provided data is valid. 67 // the notification to be displayed to the user when the developer-provided data is valid.
68 static Notification* create(ExecutionContext*, const String& title, const No tificationOptions&, ExceptionState&); 68 static Notification* create(ExecutionContext*, const String& title, const No tificationOptions&, ExceptionState&);
69 69
70 // Used for embedder-created Notification objects. If |showing| is true, wil l initialize the 70 // Used for embedder-created Notification objects. If |showing| is true, wil l initialize the
71 // Notification's state as showing, or as closed otherwise. 71 // Notification's state as showing, or as closed otherwise.
72 static Notification* create(ExecutionContext*, int64_t persistentId, const W ebNotificationData&, bool showing); 72 static Notification* create(ExecutionContext*, const String& notificationId, const WebNotificationData&, bool showing);
73 73
74 ~Notification() override; 74 ~Notification() override;
75 75
76 void close(); 76 void close();
77 77
78 DEFINE_ATTRIBUTE_EVENT_LISTENER(click); 78 DEFINE_ATTRIBUTE_EVENT_LISTENER(click);
79 DEFINE_ATTRIBUTE_EVENT_LISTENER(show); 79 DEFINE_ATTRIBUTE_EVENT_LISTENER(show);
80 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); 80 DEFINE_ATTRIBUTE_EVENT_LISTENER(error);
81 DEFINE_ATTRIBUTE_EVENT_LISTENER(close); 81 DEFINE_ATTRIBUTE_EVENT_LISTENER(close);
82 82
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 void schedulePrepareShow(); 132 void schedulePrepareShow();
133 133
134 // Checks permission and loads any necessary resources (this may be async) 134 // Checks permission and loads any necessary resources (this may be async)
135 // before showing the notification. 135 // before showing the notification.
136 void prepareShow(); 136 void prepareShow();
137 137
138 // Shows the notification, using the resources loaded by the 138 // Shows the notification, using the resources loaded by the
139 // NotificationResourcesLoader. 139 // NotificationResourcesLoader.
140 void didLoadResources(NotificationResourcesLoader*); 140 void didLoadResources(NotificationResourcesLoader*);
141 141
142 void setPersistentId(int64_t persistentId) { m_persistentId = persistentId; } 142 void setNotificationId(const String& notificationId) { m_notificationId = no tificationId; }
143 143
144 WebNotificationData m_data; 144 WebNotificationData m_data;
145 145
146 // Notifications can either be bound to the page, which means they're identi fied by 146 // Notifications can either be bound to the page, which means they're identi fied by
147 // their delegate, or persistent, which means they're identified by a persis tent Id 147 // their delegate, or persistent, which means they're identified by a persis tent Id
148 // given to us by the embedder. This influences how we close the notificatio n. 148 // given to us by the embedder. This influences how we close the notificatio n.
149 int64_t m_persistentId; 149 String m_notificationId;
150 150
151 enum NotificationState { 151 enum NotificationState {
152 NotificationStateIdle, 152 NotificationStateIdle,
153 NotificationStateShowing, 153 NotificationStateShowing,
154 NotificationStateClosing, 154 NotificationStateClosing,
155 NotificationStateClosed 155 NotificationStateClosed
156 }; 156 };
157 157
158 // Only to be used by the Notification::create() method when notifications w ere created 158 // Only to be used by the Notification::create() method when notifications w ere created
159 // by the embedder rather than by Blink. 159 // by the embedder rather than by Blink.
160 void setState(NotificationState state) { m_state = state; } 160 void setState(NotificationState state) { m_state = state; }
161 161
162 NotificationState m_state; 162 NotificationState m_state;
163 163
164 Member<AsyncMethodRunner<Notification>> m_prepareShowMethodRunner; 164 Member<AsyncMethodRunner<Notification>> m_prepareShowMethodRunner;
165 165
166 Member<NotificationResourcesLoader> m_loader; 166 Member<NotificationResourcesLoader> m_loader;
167 }; 167 };
168 168
169 } // namespace blink 169 } // namespace blink
170 170
171 #endif // Notification_h 171 #endif // Notification_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698