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 16 matching lines...) Expand all Loading... |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef Notification_h | 31 #ifndef Notification_h |
32 #define Notification_h | 32 #define Notification_h |
33 | 33 |
34 #include "bindings/core/v8/SerializedScriptValue.h" | 34 #include "bindings/core/v8/SerializedScriptValue.h" |
35 #include "core/dom/ActiveDOMObject.h" | 35 #include "core/dom/ActiveDOMObject.h" |
36 #include "modules/EventTargetModules.h" | 36 #include "modules/EventTargetModules.h" |
| 37 #include "modules/vibration/NavigatorVibration.h" |
37 #include "platform/AsyncMethodRunner.h" | 38 #include "platform/AsyncMethodRunner.h" |
38 #include "platform/heap/Handle.h" | 39 #include "platform/heap/Handle.h" |
39 #include "platform/text/TextDirection.h" | 40 #include "platform/text/TextDirection.h" |
40 #include "platform/weborigin/KURL.h" | 41 #include "platform/weborigin/KURL.h" |
41 #include "public/platform/modules/notifications/WebNotificationDelegate.h" | 42 #include "public/platform/modules/notifications/WebNotificationDelegate.h" |
42 #include "public/platform/modules/notifications/WebNotificationPermission.h" | 43 #include "public/platform/modules/notifications/WebNotificationPermission.h" |
43 #include "wtf/PassOwnPtr.h" | 44 #include "wtf/PassOwnPtr.h" |
44 #include "wtf/PassRefPtr.h" | 45 #include "wtf/PassRefPtr.h" |
45 #include "wtf/RefCounted.h" | 46 #include "wtf/RefCounted.h" |
46 #include "wtf/RefPtr.h" | 47 #include "wtf/RefPtr.h" |
47 | 48 |
48 namespace blink { | 49 namespace blink { |
49 | 50 |
50 class ExecutionContext; | 51 class ExecutionContext; |
51 class NotificationOptions; | 52 class NotificationOptions; |
52 class NotificationPermissionCallback; | 53 class NotificationPermissionCallback; |
53 class ScriptState; | 54 class ScriptState; |
54 class ScriptValue; | 55 class ScriptValue; |
| 56 class UnsignedLongOrUnsignedLongSequence; |
55 struct WebNotificationData; | 57 struct WebNotificationData; |
56 | 58 |
57 class Notification final : public RefCountedGarbageCollectedEventTargetWithInlin
eData<Notification>, public ActiveDOMObject, public WebNotificationDelegate { | 59 class Notification final : public RefCountedGarbageCollectedEventTargetWithInlin
eData<Notification>, public ActiveDOMObject, public WebNotificationDelegate { |
58 DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<N
otification>); | 60 DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<N
otification>); |
59 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Notification); | 61 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Notification); |
60 DEFINE_WRAPPERTYPEINFO(); | 62 DEFINE_WRAPPERTYPEINFO(); |
61 public: | 63 public: |
62 // 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 |
63 // the notification to be displayed to the user. | 65 // the notification to be displayed to the user. |
64 static Notification* create(ExecutionContext*, const String& title, const No
tificationOptions&, ExceptionState&); | 66 static Notification* create(ExecutionContext*, const String& title, const No
tificationOptions&, ExceptionState&); |
(...skipping 15 matching lines...) Expand all Loading... |
80 void dispatchClickEvent() override; | 82 void dispatchClickEvent() override; |
81 void dispatchErrorEvent() override; | 83 void dispatchErrorEvent() override; |
82 void dispatchCloseEvent() override; | 84 void dispatchCloseEvent() override; |
83 | 85 |
84 String title() const { return m_title; } | 86 String title() const { return m_title; } |
85 String dir() const { return m_dir; } | 87 String dir() const { return m_dir; } |
86 String lang() const { return m_lang; } | 88 String lang() const { return m_lang; } |
87 String body() const { return m_body; } | 89 String body() const { return m_body; } |
88 String tag() const { return m_tag; } | 90 String tag() const { return m_tag; } |
89 String icon() const { return m_iconUrl; } | 91 String icon() const { return m_iconUrl; } |
| 92 NavigatorVibration::VibrationPattern vibrate(bool& isNull) const; |
90 bool silent() const { return m_silent; } | 93 bool silent() const { return m_silent; } |
91 ScriptValue data(ScriptState*) const; | 94 ScriptValue data(ScriptState*) const; |
92 | 95 |
93 TextDirection direction() const; | 96 TextDirection direction() const; |
94 KURL iconURL() const { return m_iconUrl; } | 97 KURL iconURL() const { return m_iconUrl; } |
95 SerializedScriptValue* serializedData() const { return m_serializedData.get(
); } | 98 SerializedScriptValue* serializedData() const { return m_serializedData.get(
); } |
96 | 99 |
97 static String permissionString(WebNotificationPermission); | 100 static String permissionString(WebNotificationPermission); |
98 static String permission(ExecutionContext*); | 101 static String permission(ExecutionContext*); |
99 static WebNotificationPermission checkPermission(ExecutionContext*); | 102 static WebNotificationPermission checkPermission(ExecutionContext*); |
(...skipping 20 matching lines...) Expand all Loading... |
120 // collected while m_state is Showing, and so this instance stays alive | 123 // collected while m_state is Showing, and so this instance stays alive |
121 // until the operation completes. Otherwise, you need to hold a ref on this | 124 // until the operation completes. Otherwise, you need to hold a ref on this |
122 // instance until the operation completes. | 125 // instance until the operation completes. |
123 void show(); | 126 void show(); |
124 | 127 |
125 void setDir(const String& dir) { m_dir = dir; } | 128 void setDir(const String& dir) { m_dir = dir; } |
126 void setLang(const String& lang) { m_lang = lang; } | 129 void setLang(const String& lang) { m_lang = lang; } |
127 void setBody(const String& body) { m_body = body; } | 130 void setBody(const String& body) { m_body = body; } |
128 void setIconUrl(KURL iconUrl) { m_iconUrl = iconUrl; } | 131 void setIconUrl(KURL iconUrl) { m_iconUrl = iconUrl; } |
129 void setTag(const String& tag) { m_tag = tag; } | 132 void setTag(const String& tag) { m_tag = tag; } |
| 133 void setVibrate(const NavigatorVibration::VibrationPattern& vibrate) { m_vib
rate = vibrate; } |
130 void setSilent(bool silent) { m_silent = silent; } | 134 void setSilent(bool silent) { m_silent = silent; } |
131 void setSerializedData(PassRefPtr<SerializedScriptValue> data) { m_serialize
dData = data; } | 135 void setSerializedData(PassRefPtr<SerializedScriptValue> data) { m_serialize
dData = data; } |
132 | 136 |
133 void setPersistentId(const String& persistentId) { m_persistentId = persiste
ntId; } | 137 void setPersistentId(const String& persistentId) { m_persistentId = persiste
ntId; } |
134 | 138 |
135 private: | 139 private: |
136 String m_title; | 140 String m_title; |
137 String m_dir; | 141 String m_dir; |
138 String m_lang; | 142 String m_lang; |
139 String m_body; | 143 String m_body; |
140 String m_tag; | 144 String m_tag; |
| 145 NavigatorVibration::VibrationPattern m_vibrate; |
141 bool m_silent; | 146 bool m_silent; |
142 RefPtr<SerializedScriptValue> m_serializedData; | 147 RefPtr<SerializedScriptValue> m_serializedData; |
143 | 148 |
144 KURL m_iconUrl; | 149 KURL m_iconUrl; |
145 | 150 |
146 // Notifications can either be bound to the page, which means they're identi
fied by | 151 // 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 | 152 // 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. | 153 // given to us by the embedder. This influences how we close the notificatio
n. |
149 String m_persistentId; | 154 String m_persistentId; |
150 | 155 |
151 enum NotificationState { | 156 enum NotificationState { |
152 NotificationStateIdle, | 157 NotificationStateIdle, |
153 NotificationStateShowing, | 158 NotificationStateShowing, |
154 NotificationStateClosing, | 159 NotificationStateClosing, |
155 NotificationStateClosed | 160 NotificationStateClosed |
156 }; | 161 }; |
157 | 162 |
158 // Only to be used by the Notification::create() method when notifications w
ere created | 163 // Only to be used by the Notification::create() method when notifications w
ere created |
159 // by the embedder rather than by Blink. | 164 // by the embedder rather than by Blink. |
160 void setState(NotificationState state) { m_state = state; } | 165 void setState(NotificationState state) { m_state = state; } |
161 | 166 |
162 NotificationState m_state; | 167 NotificationState m_state; |
163 | 168 |
164 AsyncMethodRunner<Notification> m_asyncRunner; | 169 AsyncMethodRunner<Notification> m_asyncRunner; |
165 }; | 170 }; |
166 | 171 |
167 } // namespace blink | 172 } // namespace blink |
168 | 173 |
169 #endif // Notification_h | 174 #endif // Notification_h |
OLD | NEW |