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 26 matching lines...) Expand all Loading... | |
37 #include "modules/EventTargetModules.h" | 37 #include "modules/EventTargetModules.h" |
38 #include "modules/ModulesExport.h" | 38 #include "modules/ModulesExport.h" |
39 #include "modules/notifications/NotificationAction.h" | 39 #include "modules/notifications/NotificationAction.h" |
40 #include "modules/vibration/NavigatorVibration.h" | 40 #include "modules/vibration/NavigatorVibration.h" |
41 #include "platform/AsyncMethodRunner.h" | 41 #include "platform/AsyncMethodRunner.h" |
42 #include "platform/heap/Handle.h" | 42 #include "platform/heap/Handle.h" |
43 #include "platform/text/TextDirection.h" | 43 #include "platform/text/TextDirection.h" |
44 #include "platform/weborigin/KURL.h" | 44 #include "platform/weborigin/KURL.h" |
45 #include "public/platform/WebVector.h" | 45 #include "public/platform/WebVector.h" |
46 #include "public/platform/modules/notifications/WebNotificationAction.h" | 46 #include "public/platform/modules/notifications/WebNotificationAction.h" |
47 #include "public/platform/modules/notifications/WebNotificationData.h" | |
47 #include "public/platform/modules/notifications/WebNotificationDelegate.h" | 48 #include "public/platform/modules/notifications/WebNotificationDelegate.h" |
48 #include "public/platform/modules/notifications/WebNotificationPermission.h" | 49 #include "public/platform/modules/notifications/WebNotificationPermission.h" |
49 #include "wtf/PassOwnPtr.h" | 50 #include "wtf/PassOwnPtr.h" |
50 #include "wtf/PassRefPtr.h" | 51 #include "wtf/PassRefPtr.h" |
51 #include "wtf/RefCounted.h" | 52 #include "wtf/RefCounted.h" |
52 #include "wtf/RefPtr.h" | 53 #include "wtf/RefPtr.h" |
53 | 54 |
54 namespace blink { | 55 namespace blink { |
55 | 56 |
56 class ExecutionContext; | 57 class ExecutionContext; |
(...skipping 29 matching lines...) Expand all Loading... | |
86 void dispatchShowEvent() override; | 87 void dispatchShowEvent() override; |
87 void dispatchClickEvent() override; | 88 void dispatchClickEvent() override; |
88 void dispatchErrorEvent() override; | 89 void dispatchErrorEvent() override; |
89 void dispatchCloseEvent() override; | 90 void dispatchCloseEvent() override; |
90 | 91 |
91 String title() const { return m_title; } | 92 String title() const { return m_title; } |
92 String dir() const { return m_dir; } | 93 String dir() const { return m_dir; } |
93 String lang() const { return m_lang; } | 94 String lang() const { return m_lang; } |
94 String body() const { return m_body; } | 95 String body() const { return m_body; } |
95 String tag() const { return m_tag; } | 96 String tag() const { return m_tag; } |
97 String priority() const { return m_priority; } | |
96 String icon() const { return m_iconUrl; } | 98 String icon() const { return m_iconUrl; } |
97 const NavigatorVibration::VibrationPattern& vibrate(bool& isNull) const; | 99 const NavigatorVibration::VibrationPattern& vibrate(bool& isNull) const; |
98 bool silent() const { return m_silent; } | 100 bool silent() const { return m_silent; } |
99 ScriptValue data(ScriptState*) const; | 101 ScriptValue data(ScriptState*) const; |
100 const HeapVector<NotificationAction>& actions() const { return m_actions; } | 102 const HeapVector<NotificationAction>& actions() const { return m_actions; } |
101 | 103 |
102 TextDirection direction() const; | 104 TextDirection direction() const; |
103 KURL iconURL() const { return m_iconUrl; } | 105 KURL iconURL() const { return m_iconUrl; } |
104 SerializedScriptValue* serializedData() const { return m_serializedData.get( ); } | 106 SerializedScriptValue* serializedData() const { return m_serializedData.get( ); } |
105 | 107 |
106 static String permissionString(WebNotificationPermission); | 108 static String permissionString(WebNotificationPermission); |
107 static String permission(ExecutionContext*); | 109 static String permission(ExecutionContext*); |
108 static WebNotificationPermission checkPermission(ExecutionContext*); | 110 static WebNotificationPermission checkPermission(ExecutionContext*); |
109 static ScriptPromise requestPermission(ScriptState*, NotificationPermissionC allback*); | 111 static ScriptPromise requestPermission(ScriptState*, NotificationPermissionC allback*); |
110 | 112 |
113 static WebNotificationData::Priority priorityEnum(const String& priority); | |
114 | |
111 static size_t maxActions(); | 115 static size_t maxActions(); |
112 | 116 |
113 static void actionsToWebActions(const HeapVector<NotificationAction>& action s, WebVector<WebNotificationAction>* webActions); | 117 static void actionsToWebActions(const HeapVector<NotificationAction>& action s, WebVector<WebNotificationAction>* webActions); |
114 | 118 |
115 // EventTarget interface. | 119 // EventTarget interface. |
116 ExecutionContext* executionContext() const final { return ActiveDOMObject::e xecutionContext(); } | 120 ExecutionContext* executionContext() const final { return ActiveDOMObject::e xecutionContext(); } |
117 const AtomicString& interfaceName() const override; | 121 const AtomicString& interfaceName() const override; |
118 | 122 |
119 // ActiveDOMObject interface. | 123 // ActiveDOMObject interface. |
120 void stop() override; | 124 void stop() override; |
121 bool hasPendingActivity() const override; | 125 bool hasPendingActivity() const override; |
122 | 126 |
123 DECLARE_VIRTUAL_TRACE(); | 127 DECLARE_VIRTUAL_TRACE(); |
124 | 128 |
125 protected: | 129 protected: |
126 // EventTarget interface. | 130 // EventTarget interface. |
127 bool dispatchEventInternal(PassRefPtrWillBeRawPtr<Event>) final; | 131 bool dispatchEventInternal(PassRefPtrWillBeRawPtr<Event>) final; |
128 | 132 |
129 private: | 133 private: |
134 static String priorityString(WebNotificationData::Priority); | |
135 | |
130 static void webActionsToActions(const WebVector<WebNotificationAction>& webA ctions, HeapVector<NotificationAction>* actions); | 136 static void webActionsToActions(const WebVector<WebNotificationAction>& webA ctions, HeapVector<NotificationAction>* actions); |
131 | 137 |
132 Notification(const String& title, ExecutionContext*); | 138 Notification(const String& title, ExecutionContext*); |
133 | 139 |
134 void scheduleShow(); | 140 void scheduleShow(); |
135 | 141 |
136 // Calling show() may start asynchronous operation. If this object has | 142 // Calling show() may start asynchronous operation. If this object has |
137 // a V8 wrapper, hasPendingActivity() prevents the wrapper from being | 143 // a V8 wrapper, hasPendingActivity() prevents the wrapper from being |
138 // collected while m_state is Showing, and so this instance stays alive | 144 // collected while m_state is Showing, and so this instance stays alive |
139 // until the operation completes. Otherwise, you need to hold a ref on this | 145 // until the operation completes. Otherwise, you need to hold a ref on this |
140 // instance until the operation completes. | 146 // instance until the operation completes. |
141 void show(); | 147 void show(); |
142 | 148 |
143 void setDir(const String& dir) { m_dir = dir; } | 149 void setDir(const String& dir) { m_dir = dir; } |
144 void setLang(const String& lang) { m_lang = lang; } | 150 void setLang(const String& lang) { m_lang = lang; } |
145 void setBody(const String& body) { m_body = body; } | 151 void setBody(const String& body) { m_body = body; } |
146 void setIconUrl(KURL iconUrl) { m_iconUrl = iconUrl; } | 152 void setIconUrl(KURL iconUrl) { m_iconUrl = iconUrl; } |
147 void setTag(const String& tag) { m_tag = tag; } | 153 void setTag(const String& tag) { m_tag = tag; } |
154 void setPriority(const String& priority) { m_priority = priority; } | |
148 void setVibrate(const NavigatorVibration::VibrationPattern& vibrate) { m_vib rate = vibrate; } | 155 void setVibrate(const NavigatorVibration::VibrationPattern& vibrate) { m_vib rate = vibrate; } |
149 void setSilent(bool silent) { m_silent = silent; } | 156 void setSilent(bool silent) { m_silent = silent; } |
150 void setSerializedData(PassRefPtr<SerializedScriptValue> data) { m_serialize dData = data; } | 157 void setSerializedData(PassRefPtr<SerializedScriptValue> data) { m_serialize dData = data; } |
151 void setActions(const HeapVector<NotificationAction>& actions) { m_actions = actions; } | 158 void setActions(const HeapVector<NotificationAction>& actions) { m_actions = actions; } |
152 | 159 |
153 void setPersistentId(int64_t persistentId) { m_persistentId = persistentId; } | 160 void setPersistentId(int64_t persistentId) { m_persistentId = persistentId; } |
154 | 161 |
155 String m_title; | 162 String m_title; |
156 String m_dir; | 163 String m_dir; |
157 String m_lang; | 164 String m_lang; |
158 String m_body; | 165 String m_body; |
159 String m_tag; | 166 String m_tag; |
167 String m_priority; | |
Peter Beverloo
2015/08/03 16:41:59
I don't like having enum values stored as strings.
johnme
2015/08/03 16:58:48
Acknowledged.
| |
160 NavigatorVibration::VibrationPattern m_vibrate; | 168 NavigatorVibration::VibrationPattern m_vibrate; |
161 bool m_silent; | 169 bool m_silent; |
162 RefPtr<SerializedScriptValue> m_serializedData; | 170 RefPtr<SerializedScriptValue> m_serializedData; |
163 HeapVector<NotificationAction> m_actions; | 171 HeapVector<NotificationAction> m_actions; |
164 | 172 |
165 KURL m_iconUrl; | 173 KURL m_iconUrl; |
166 | 174 |
167 // Notifications can either be bound to the page, which means they're identi fied by | 175 // Notifications can either be bound to the page, which means they're identi fied by |
168 // their delegate, or persistent, which means they're identified by a persis tent Id | 176 // their delegate, or persistent, which means they're identified by a persis tent Id |
169 // given to us by the embedder. This influences how we close the notificatio n. | 177 // given to us by the embedder. This influences how we close the notificatio n. |
(...skipping 11 matching lines...) Expand all Loading... | |
181 void setState(NotificationState state) { m_state = state; } | 189 void setState(NotificationState state) { m_state = state; } |
182 | 190 |
183 NotificationState m_state; | 191 NotificationState m_state; |
184 | 192 |
185 AsyncMethodRunner<Notification> m_asyncRunner; | 193 AsyncMethodRunner<Notification> m_asyncRunner; |
186 }; | 194 }; |
187 | 195 |
188 } // namespace blink | 196 } // namespace blink |
189 | 197 |
190 #endif // Notification_h | 198 #endif // Notification_h |
OLD | NEW |