OLD | NEW |
---|---|
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
47 #include "public/platform/modules/notifications/WebNotificationData.h" | 47 #include "public/platform/modules/notifications/WebNotificationData.h" |
48 #include "public/platform/modules/notifications/WebNotificationDelegate.h" | 48 #include "public/platform/modules/notifications/WebNotificationDelegate.h" |
49 #include "public/platform/modules/notifications/WebNotificationPermission.h" | 49 #include "public/platform/modules/notifications/WebNotificationPermission.h" |
50 | 50 |
51 namespace blink { | 51 namespace blink { |
52 | 52 |
53 class ExecutionContext; | 53 class ExecutionContext; |
54 class NotificationAction; | 54 class NotificationAction; |
55 class NotificationOptions; | 55 class NotificationOptions; |
56 class NotificationPermissionCallback; | 56 class NotificationPermissionCallback; |
57 class NotificationResourcesLoader; | |
57 class ScriptState; | 58 class ScriptState; |
58 | 59 |
59 class MODULES_EXPORT Notification final : public EventTargetWithInlineData, publ ic ActiveScriptWrappable, public ActiveDOMObject, public WebNotificationDelegate { | 60 class MODULES_EXPORT Notification final : public EventTargetWithInlineData, publ ic ActiveScriptWrappable, public ActiveDOMObject, public WebNotificationDelegate { |
60 USING_GARBAGE_COLLECTED_MIXIN(Notification); | 61 USING_GARBAGE_COLLECTED_MIXIN(Notification); |
61 DEFINE_WRAPPERTYPEINFO(); | 62 DEFINE_WRAPPERTYPEINFO(); |
62 public: | 63 public: |
63 // Used for JavaScript instantiations of the Notification object. Will autom atically schedule for | 64 // Used for JavaScript instantiations of the Notification object. Will autom atically schedule for |
64 // the notification to be displayed to the user when the developer-provided data is valid. | 65 // the notification to be displayed to the user when the developer-provided data is valid. |
65 static Notification* create(ExecutionContext*, const String& title, const No tificationOptions&, ExceptionState&); | 66 static Notification* create(ExecutionContext*, const String& title, const No tificationOptions&, ExceptionState&); |
66 | 67 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 | 118 |
118 DECLARE_VIRTUAL_TRACE(); | 119 DECLARE_VIRTUAL_TRACE(); |
119 | 120 |
120 protected: | 121 protected: |
121 // EventTarget interface. | 122 // EventTarget interface. |
122 DispatchEventResult dispatchEventInternal(Event*) final; | 123 DispatchEventResult dispatchEventInternal(Event*) final; |
123 | 124 |
124 private: | 125 private: |
125 Notification(ExecutionContext*, const WebNotificationData&); | 126 Notification(ExecutionContext*, const WebNotificationData&); |
126 | 127 |
127 void scheduleShow(); | 128 void schedulePrepareShow(); |
128 | 129 |
129 // Calling show() may start asynchronous operation. If this object has | 130 // Calling prepareShow() may start asynchronous operation. If this object ha s |
130 // a V8 wrapper, hasPendingActivity() prevents the wrapper from being | 131 // a V8 wrapper, hasPendingActivity() prevents the wrapper from being |
131 // collected while m_state is Showing, and so this instance stays alive | 132 // collected while m_state is Showing, and so this instance stays alive |
132 // until the operation completes. Otherwise, you need to hold a ref on this | 133 // until the operation completes. Otherwise, you need to hold a ref on this |
133 // instance until the operation completes. | 134 // instance until the operation completes. |
Peter Beverloo
2016/04/13 18:32:27
Out of interest, do you think this comment is stil
Michael van Ouwerkerk
2016/04/14 13:42:11
It appears to be an antique. I've moved it to a sp
Peter Beverloo
2016/04/15 11:07:29
I am fond of left-hand-side redness as well.
| |
134 void show(); | 135 void prepareShow(); |
136 | |
137 void didLoadResources(NotificationResourcesLoader*); | |
135 | 138 |
136 void setPersistentId(int64_t persistentId) { m_persistentId = persistentId; } | 139 void setPersistentId(int64_t persistentId) { m_persistentId = persistentId; } |
137 | 140 |
138 WebNotificationData m_data; | 141 WebNotificationData m_data; |
139 | 142 |
140 // ScriptValue representations of the developer-associated data. Initialized lazily on first access. | 143 // ScriptValue representations of the developer-associated data. Initialized lazily on first access. |
141 ScriptValue m_developerData; | 144 ScriptValue m_developerData; |
142 | 145 |
143 // 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 |
144 // 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 |
145 // 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. |
146 int64_t m_persistentId; | 149 int64_t m_persistentId; |
147 | 150 |
148 enum NotificationState { | 151 enum NotificationState { |
149 NotificationStateIdle, | 152 NotificationStateIdle, |
150 NotificationStateShowing, | 153 NotificationStateShowing, |
151 NotificationStateClosing, | 154 NotificationStateClosing, |
152 NotificationStateClosed | 155 NotificationStateClosed |
153 }; | 156 }; |
154 | 157 |
155 // 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 |
156 // by the embedder rather than by Blink. | 159 // by the embedder rather than by Blink. |
157 void setState(NotificationState state) { m_state = state; } | 160 void setState(NotificationState state) { m_state = state; } |
158 | 161 |
159 NotificationState m_state; | 162 NotificationState m_state; |
160 | 163 |
161 Member<AsyncMethodRunner<Notification>> m_asyncRunner; | 164 Member<AsyncMethodRunner<Notification>> m_prepareShowMethodRunner; |
165 | |
166 Member<NotificationResourcesLoader> m_loader; | |
162 }; | 167 }; |
163 | 168 |
164 } // namespace blink | 169 } // namespace blink |
165 | 170 |
166 #endif // Notification_h | 171 #endif // Notification_h |
OLD | NEW |