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 15 matching lines...) Expand all Loading... |
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 #include "modules/notifications/Notification.h" | 31 #include "modules/notifications/Notification.h" |
32 | 32 |
33 #include "bindings/core/v8/ExceptionState.h" | 33 #include "bindings/core/v8/ExceptionState.h" |
34 #include "bindings/core/v8/ScriptState.h" | 34 #include "bindings/core/v8/ScriptState.h" |
35 #include "bindings/core/v8/SerializedScriptValueFactory.h" | 35 #include "bindings/core/v8/SerializedScriptValueFactory.h" |
| 36 #include "bindings/modules/v8/V8NotificationAction.h" |
36 #include "core/dom/Document.h" | 37 #include "core/dom/Document.h" |
37 #include "core/dom/ExecutionContext.h" | 38 #include "core/dom/ExecutionContext.h" |
38 #include "core/dom/ExecutionContextTask.h" | 39 #include "core/dom/ExecutionContextTask.h" |
39 #include "core/dom/ScopedWindowFocusAllowedIndicator.h" | 40 #include "core/dom/ScopedWindowFocusAllowedIndicator.h" |
40 #include "core/events/Event.h" | 41 #include "core/events/Event.h" |
41 #include "core/frame/UseCounter.h" | 42 #include "core/frame/UseCounter.h" |
42 #include "modules/notifications/NotificationAction.h" | 43 #include "modules/notifications/NotificationAction.h" |
43 #include "modules/notifications/NotificationData.h" | 44 #include "modules/notifications/NotificationData.h" |
44 #include "modules/notifications/NotificationManager.h" | 45 #include "modules/notifications/NotificationManager.h" |
45 #include "modules/notifications/NotificationOptions.h" | 46 #include "modules/notifications/NotificationOptions.h" |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 String Notification::icon() const | 257 String Notification::icon() const |
257 { | 258 { |
258 return m_data.icon.string(); | 259 return m_data.icon.string(); |
259 } | 260 } |
260 | 261 |
261 String Notification::badge() const | 262 String Notification::badge() const |
262 { | 263 { |
263 return m_data.badge.string(); | 264 return m_data.badge.string(); |
264 } | 265 } |
265 | 266 |
266 NavigatorVibration::VibrationPattern Notification::vibrate(bool& isNull) const | 267 NavigatorVibration::VibrationPattern Notification::vibrate() const |
267 { | 268 { |
268 NavigatorVibration::VibrationPattern pattern; | 269 NavigatorVibration::VibrationPattern pattern; |
269 pattern.appendRange(m_data.vibrate.begin(), m_data.vibrate.end()); | 270 pattern.appendRange(m_data.vibrate.begin(), m_data.vibrate.end()); |
270 | 271 |
271 if (!pattern.size()) | |
272 isNull = true; | |
273 | |
274 return pattern; | 272 return pattern; |
275 } | 273 } |
276 | 274 |
277 DOMTimeStamp Notification::timestamp() const | 275 DOMTimeStamp Notification::timestamp() const |
278 { | 276 { |
279 return m_data.timestamp; | 277 return m_data.timestamp; |
280 } | 278 } |
281 | 279 |
282 bool Notification::renotify() const | 280 bool Notification::renotify() const |
283 { | 281 { |
(...skipping 14 matching lines...) Expand all Loading... |
298 { | 296 { |
299 if (m_developerData.isEmpty()) { | 297 if (m_developerData.isEmpty()) { |
300 const WebVector<char>& serializedData = m_data.data; | 298 const WebVector<char>& serializedData = m_data.data; |
301 RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::c
reate(serializedData.data(), serializedData.size()); | 299 RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::c
reate(serializedData.data(), serializedData.size()); |
302 m_developerData = ScriptValue(scriptState, serializedValue->deserialize(
scriptState->isolate())); | 300 m_developerData = ScriptValue(scriptState, serializedValue->deserialize(
scriptState->isolate())); |
303 } | 301 } |
304 | 302 |
305 return m_developerData; | 303 return m_developerData; |
306 } | 304 } |
307 | 305 |
308 HeapVector<NotificationAction> Notification::actions() const | 306 Vector<v8::Local<v8::Value>> Notification::actions(ScriptState* scriptState) con
st |
309 { | 307 { |
310 HeapVector<NotificationAction> actions; | 308 Vector<v8::Local<v8::Value>> actions; |
311 actions.grow(m_data.actions.size()); | 309 actions.grow(m_data.actions.size()); |
312 | 310 |
313 for (size_t i = 0; i < m_data.actions.size(); ++i) { | 311 for (size_t i = 0; i < m_data.actions.size(); ++i) { |
| 312 NotificationAction action; |
| 313 |
314 switch (m_data.actions[i].type) { | 314 switch (m_data.actions[i].type) { |
315 case WebNotificationAction::Button: | 315 case WebNotificationAction::Button: |
316 actions[i].setType("button"); | 316 action.setType("button"); |
317 break; | 317 break; |
318 case WebNotificationAction::Text: | 318 case WebNotificationAction::Text: |
319 actions[i].setType("text"); | 319 action.setType("text"); |
320 break; | 320 break; |
321 default: | 321 default: |
322 NOTREACHED() << "Unknown action type: " << m_data.actions[i].type; | 322 NOTREACHED() << "Unknown action type: " << m_data.actions[i].type; |
323 } | 323 } |
324 actions[i].setAction(m_data.actions[i].action); | 324 |
325 actions[i].setTitle(m_data.actions[i].title); | 325 action.setAction(m_data.actions[i].action); |
326 actions[i].setIcon(m_data.actions[i].icon.string()); | 326 action.setTitle(m_data.actions[i].title); |
327 actions[i].setPlaceholder(m_data.actions[i].placeholder); | 327 action.setIcon(m_data.actions[i].icon.string()); |
| 328 action.setPlaceholder(m_data.actions[i].placeholder); |
| 329 |
| 330 // Not just the sequence of actions itself, but also the actions contain
ed within the |
| 331 // sequence should be frozen per the Web Notification specification. |
| 332 actions[i] = freezeV8Object(toV8(action, scriptState), scriptState->isol
ate()); |
328 } | 333 } |
329 | 334 |
330 return actions; | 335 return actions; |
331 } | 336 } |
332 | 337 |
333 String Notification::permissionString(mojom::blink::PermissionStatus permission) | 338 String Notification::permissionString(mojom::blink::PermissionStatus permission) |
334 { | 339 { |
335 switch (permission) { | 340 switch (permission) { |
336 case mojom::blink::PermissionStatus::GRANTED: | 341 case mojom::blink::PermissionStatus::GRANTED: |
337 return "granted"; | 342 return "granted"; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 | 402 |
398 DEFINE_TRACE(Notification) | 403 DEFINE_TRACE(Notification) |
399 { | 404 { |
400 visitor->trace(m_prepareShowMethodRunner); | 405 visitor->trace(m_prepareShowMethodRunner); |
401 visitor->trace(m_loader); | 406 visitor->trace(m_loader); |
402 EventTargetWithInlineData::trace(visitor); | 407 EventTargetWithInlineData::trace(visitor); |
403 ActiveDOMObject::trace(visitor); | 408 ActiveDOMObject::trace(visitor); |
404 } | 409 } |
405 | 410 |
406 } // namespace blink | 411 } // namespace blink |
OLD | NEW |