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 13 matching lines...) Expand all Loading... |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
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 "core/dom/ActiveDOMObject.h" | 35 #include "core/dom/ActiveDOMObject.h" |
35 #include "modules/EventTargetModules.h" | 36 #include "modules/EventTargetModules.h" |
36 #include "platform/AsyncMethodRunner.h" | 37 #include "platform/AsyncMethodRunner.h" |
37 #include "platform/heap/Handle.h" | 38 #include "platform/heap/Handle.h" |
38 #include "platform/text/TextDirection.h" | 39 #include "platform/text/TextDirection.h" |
39 #include "platform/weborigin/KURL.h" | 40 #include "platform/weborigin/KURL.h" |
40 #include "public/platform/modules/notifications/WebNotificationDelegate.h" | 41 #include "public/platform/modules/notifications/WebNotificationDelegate.h" |
41 #include "public/platform/modules/notifications/WebNotificationPermission.h" | 42 #include "public/platform/modules/notifications/WebNotificationPermission.h" |
42 #include "wtf/PassOwnPtr.h" | 43 #include "wtf/PassOwnPtr.h" |
| 44 #include "wtf/PassRefPtr.h" |
43 #include "wtf/RefCounted.h" | 45 #include "wtf/RefCounted.h" |
| 46 #include "wtf/RefPtr.h" |
44 | 47 |
45 namespace blink { | 48 namespace blink { |
46 | 49 |
47 class ExecutionContext; | 50 class ExecutionContext; |
48 class NotificationOptions; | 51 class NotificationOptions; |
49 class NotificationPermissionCallback; | 52 class NotificationPermissionCallback; |
| 53 class ScriptState; |
| 54 class ScriptValue; |
50 struct WebNotificationData; | 55 struct WebNotificationData; |
51 | 56 |
52 class Notification final : public RefCountedGarbageCollectedEventTargetWithInlin
eData<Notification>, public ActiveDOMObject, public WebNotificationDelegate { | 57 class Notification final : public RefCountedGarbageCollectedEventTargetWithInlin
eData<Notification>, public ActiveDOMObject, public WebNotificationDelegate { |
53 DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<N
otification>); | 58 DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<N
otification>); |
54 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Notification); | 59 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Notification); |
55 DEFINE_WRAPPERTYPEINFO(); | 60 DEFINE_WRAPPERTYPEINFO(); |
56 public: | 61 public: |
57 // Used for JavaScript instantiations of the Notification object. Will autom
atically schedule for | 62 // Used for JavaScript instantiations of the Notification object. Will autom
atically schedule for |
58 // the notification to be displayed to the user. | 63 // the notification to be displayed to the user. |
59 static Notification* create(ExecutionContext*, const String& title, const No
tificationOptions&, ExceptionState&); | 64 static Notification* create(ExecutionContext*, const String& title, const No
tificationOptions&, ExceptionState&); |
(...skipping 16 matching lines...) Expand all Loading... |
76 void dispatchErrorEvent() override; | 81 void dispatchErrorEvent() override; |
77 void dispatchCloseEvent() override; | 82 void dispatchCloseEvent() override; |
78 | 83 |
79 String title() const { return m_title; } | 84 String title() const { return m_title; } |
80 String dir() const { return m_dir; } | 85 String dir() const { return m_dir; } |
81 String lang() const { return m_lang; } | 86 String lang() const { return m_lang; } |
82 String body() const { return m_body; } | 87 String body() const { return m_body; } |
83 String tag() const { return m_tag; } | 88 String tag() const { return m_tag; } |
84 String icon() const { return m_iconUrl; } | 89 String icon() const { return m_iconUrl; } |
85 bool silent() const { return m_silent; } | 90 bool silent() const { return m_silent; } |
| 91 ScriptValue data(ScriptState*) const; |
86 | 92 |
87 TextDirection direction() const; | 93 TextDirection direction() const; |
88 KURL iconURL() const { return m_iconUrl; } | 94 KURL iconURL() const { return m_iconUrl; } |
| 95 SerializedScriptValue* serializedData() const { return m_serializedData.get(
); } |
89 | 96 |
90 static String permissionString(WebNotificationPermission); | 97 static String permissionString(WebNotificationPermission); |
91 static String permission(ExecutionContext*); | 98 static String permission(ExecutionContext*); |
92 static WebNotificationPermission checkPermission(ExecutionContext*); | 99 static WebNotificationPermission checkPermission(ExecutionContext*); |
93 static void requestPermission(ExecutionContext*, NotificationPermissionCallb
ack* = nullptr); | 100 static void requestPermission(ExecutionContext*, NotificationPermissionCallb
ack* = nullptr); |
94 | 101 |
95 // EventTarget interface. | 102 // EventTarget interface. |
96 virtual ExecutionContext* executionContext() const override final { return A
ctiveDOMObject::executionContext(); } | 103 virtual ExecutionContext* executionContext() const override final { return A
ctiveDOMObject::executionContext(); } |
97 virtual bool dispatchEvent(PassRefPtrWillBeRawPtr<Event>) override final; | 104 virtual bool dispatchEvent(PassRefPtrWillBeRawPtr<Event>) override final; |
98 virtual const AtomicString& interfaceName() const override; | 105 virtual const AtomicString& interfaceName() const override; |
(...skipping 15 matching lines...) Expand all Loading... |
114 // until the operation completes. Otherwise, you need to hold a ref on this | 121 // until the operation completes. Otherwise, you need to hold a ref on this |
115 // instance until the operation completes. | 122 // instance until the operation completes. |
116 void show(); | 123 void show(); |
117 | 124 |
118 void setDir(const String& dir) { m_dir = dir; } | 125 void setDir(const String& dir) { m_dir = dir; } |
119 void setLang(const String& lang) { m_lang = lang; } | 126 void setLang(const String& lang) { m_lang = lang; } |
120 void setBody(const String& body) { m_body = body; } | 127 void setBody(const String& body) { m_body = body; } |
121 void setIconUrl(KURL iconUrl) { m_iconUrl = iconUrl; } | 128 void setIconUrl(KURL iconUrl) { m_iconUrl = iconUrl; } |
122 void setTag(const String& tag) { m_tag = tag; } | 129 void setTag(const String& tag) { m_tag = tag; } |
123 void setSilent(bool silent) { m_silent = silent; } | 130 void setSilent(bool silent) { m_silent = silent; } |
| 131 void setSerializedData(PassRefPtr<SerializedScriptValue> data) { m_serialize
dData = data; } |
124 | 132 |
125 void setPersistentId(const String& persistentId) { m_persistentId = persiste
ntId; } | 133 void setPersistentId(const String& persistentId) { m_persistentId = persiste
ntId; } |
126 | 134 |
127 private: | 135 private: |
128 String m_title; | 136 String m_title; |
129 String m_dir; | 137 String m_dir; |
130 String m_lang; | 138 String m_lang; |
131 String m_body; | 139 String m_body; |
132 String m_tag; | 140 String m_tag; |
133 bool m_silent; | 141 bool m_silent; |
| 142 RefPtr<SerializedScriptValue> m_serializedData; |
134 | 143 |
135 KURL m_iconUrl; | 144 KURL m_iconUrl; |
136 | 145 |
137 // 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 |
138 // 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 |
139 // 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. |
140 String m_persistentId; | 149 String m_persistentId; |
141 | 150 |
142 enum NotificationState { | 151 enum NotificationState { |
143 NotificationStateIdle, | 152 NotificationStateIdle, |
144 NotificationStateShowing, | 153 NotificationStateShowing, |
145 NotificationStateClosing, | 154 NotificationStateClosing, |
146 NotificationStateClosed | 155 NotificationStateClosed |
147 }; | 156 }; |
148 | 157 |
149 // 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 |
150 // by the embedder rather than by Blink. | 159 // by the embedder rather than by Blink. |
151 void setState(NotificationState state) { m_state = state; } | 160 void setState(NotificationState state) { m_state = state; } |
152 | 161 |
153 NotificationState m_state; | 162 NotificationState m_state; |
154 | 163 |
155 AsyncMethodRunner<Notification> m_asyncRunner; | 164 AsyncMethodRunner<Notification> m_asyncRunner; |
156 }; | 165 }; |
157 | 166 |
158 } // namespace blink | 167 } // namespace blink |
159 | 168 |
160 #endif // Notification_h | 169 #endif // Notification_h |
OLD | NEW |