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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
45 #include "wtf/RefCounted.h" | 45 #include "wtf/RefCounted.h" |
46 #include "wtf/RefPtr.h" | 46 #include "wtf/RefPtr.h" |
47 | 47 |
48 namespace blink { | 48 namespace blink { |
49 | 49 |
50 class ExecutionContext; | 50 class ExecutionContext; |
51 class NotificationOptions; | 51 class NotificationOptions; |
52 class NotificationPermissionCallback; | 52 class NotificationPermissionCallback; |
53 class ScriptState; | 53 class ScriptState; |
54 class ScriptValue; | 54 class ScriptValue; |
55 class UnsignedLongOrUnsignedLongSequence; | |
55 struct WebNotificationData; | 56 struct WebNotificationData; |
56 | 57 |
57 class Notification final : public RefCountedGarbageCollectedEventTargetWithInlin eData<Notification>, public ActiveDOMObject, public WebNotificationDelegate { | 58 class Notification final : public RefCountedGarbageCollectedEventTargetWithInlin eData<Notification>, public ActiveDOMObject, public WebNotificationDelegate { |
58 DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<N otification>); | 59 DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<N otification>); |
59 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Notification); | 60 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Notification); |
60 DEFINE_WRAPPERTYPEINFO(); | 61 DEFINE_WRAPPERTYPEINFO(); |
61 public: | 62 public: |
62 // Used for JavaScript instantiations of the Notification object. Will autom atically schedule for | 63 // Used for JavaScript instantiations of the Notification object. Will autom atically schedule for |
63 // the notification to be displayed to the user. | 64 // the notification to be displayed to the user. |
64 static Notification* create(ExecutionContext*, const String& title, const No tificationOptions&, ExceptionState&); | 65 static Notification* create(ExecutionContext*, const String& title, const No tificationOptions&, ExceptionState&); |
(...skipping 15 matching lines...) Expand all Loading... | |
80 void dispatchClickEvent() override; | 81 void dispatchClickEvent() override; |
81 void dispatchErrorEvent() override; | 82 void dispatchErrorEvent() override; |
82 void dispatchCloseEvent() override; | 83 void dispatchCloseEvent() override; |
83 | 84 |
84 String title() const { return m_title; } | 85 String title() const { return m_title; } |
85 String dir() const { return m_dir; } | 86 String dir() const { return m_dir; } |
86 String lang() const { return m_lang; } | 87 String lang() const { return m_lang; } |
87 String body() const { return m_body; } | 88 String body() const { return m_body; } |
88 String tag() const { return m_tag; } | 89 String tag() const { return m_tag; } |
89 String icon() const { return m_iconUrl; } | 90 String icon() const { return m_iconUrl; } |
91 Vector<unsigned> vibrate(bool& isNull) const; | |
90 bool silent() const { return m_silent; } | 92 bool silent() const { return m_silent; } |
91 ScriptValue data(ScriptState*) const; | 93 ScriptValue data(ScriptState*) const; |
92 | 94 |
93 TextDirection direction() const; | 95 TextDirection direction() const; |
94 KURL iconURL() const { return m_iconUrl; } | 96 KURL iconURL() const { return m_iconUrl; } |
95 SerializedScriptValue* serializedData() const { return m_serializedData.get( ); } | 97 SerializedScriptValue* serializedData() const { return m_serializedData.get( ); } |
96 | 98 |
97 static String permissionString(WebNotificationPermission); | 99 static String permissionString(WebNotificationPermission); |
98 static String permission(ExecutionContext*); | 100 static String permission(ExecutionContext*); |
99 static WebNotificationPermission checkPermission(ExecutionContext*); | 101 static WebNotificationPermission checkPermission(ExecutionContext*); |
100 static void requestPermission(ExecutionContext*, NotificationPermissionCallb ack* = nullptr); | 102 static void requestPermission(ExecutionContext*, NotificationPermissionCallb ack* = nullptr); |
103 static Vector<unsigned> sanitizeVibrationPattern(const UnsignedLongOrUnsigne dLongSequence&); | |
Peter Beverloo
2015/04/09 13:03:17
I don't think this should be the responsibility of
Sanghyun Park
2015/04/09 13:48:05
If we use sanitation algorithm in Vibration API, w
Peter Beverloo
2015/04/09 13:53:07
Yes, and that's exactly the point :-). We don't ha
Sanghyun Park
2015/04/09 16:26:11
Thanks for letting me know about this, too. :)
| |
101 | 104 |
102 // EventTarget interface. | 105 // EventTarget interface. |
103 virtual ExecutionContext* executionContext() const override final { return A ctiveDOMObject::executionContext(); } | 106 virtual ExecutionContext* executionContext() const override final { return A ctiveDOMObject::executionContext(); } |
104 virtual bool dispatchEvent(PassRefPtrWillBeRawPtr<Event>) override final; | 107 virtual bool dispatchEvent(PassRefPtrWillBeRawPtr<Event>) override final; |
105 virtual const AtomicString& interfaceName() const override; | 108 virtual const AtomicString& interfaceName() const override; |
106 | 109 |
107 // ActiveDOMObject interface. | 110 // ActiveDOMObject interface. |
108 virtual void stop() override; | 111 virtual void stop() override; |
109 virtual bool hasPendingActivity() const override; | 112 virtual bool hasPendingActivity() const override; |
110 | 113 |
111 DECLARE_VIRTUAL_TRACE(); | 114 DECLARE_VIRTUAL_TRACE(); |
112 | 115 |
113 private: | 116 private: |
114 Notification(const String& title, ExecutionContext*); | 117 Notification(const String& title, ExecutionContext*); |
115 | 118 |
116 void scheduleShow(); | 119 void scheduleShow(); |
117 | 120 |
118 // Calling show() may start asynchronous operation. If this object has | 121 // Calling show() may start asynchronous operation. If this object has |
119 // a V8 wrapper, hasPendingActivity() prevents the wrapper from being | 122 // a V8 wrapper, hasPendingActivity() prevents the wrapper from being |
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 Vector<unsigned>& vibrate) { m_vibrate = 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 Vector<unsigned> 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 |