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/NotificationOptions.h" | 45 #include "modules/notifications/NotificationOptions.h" |
45 #include "modules/notifications/NotificationPermissionClient.h" | 46 #include "modules/notifications/NotificationPermissionClient.h" |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
253 String Notification::icon() const | 254 String Notification::icon() const |
254 { | 255 { |
255 return m_data.icon.string(); | 256 return m_data.icon.string(); |
256 } | 257 } |
257 | 258 |
258 String Notification::badge() const | 259 String Notification::badge() const |
259 { | 260 { |
260 return m_data.badge.string(); | 261 return m_data.badge.string(); |
261 } | 262 } |
262 | 263 |
263 NavigatorVibration::VibrationPattern Notification::vibrate(bool& isNull) const | 264 NavigatorVibration::VibrationPattern Notification::vibrate() const |
264 { | 265 { |
265 NavigatorVibration::VibrationPattern pattern; | 266 NavigatorVibration::VibrationPattern pattern; |
266 pattern.appendRange(m_data.vibrate.begin(), m_data.vibrate.end()); | 267 pattern.appendRange(m_data.vibrate.begin(), m_data.vibrate.end()); |
267 | 268 |
268 if (!pattern.size()) | |
269 isNull = true; | |
270 | |
271 return pattern; | 269 return pattern; |
272 } | 270 } |
273 | 271 |
274 DOMTimeStamp Notification::timestamp() const | 272 DOMTimeStamp Notification::timestamp() const |
275 { | 273 { |
276 return m_data.timestamp; | 274 return m_data.timestamp; |
277 } | 275 } |
278 | 276 |
279 bool Notification::renotify() const | 277 bool Notification::renotify() const |
280 { | 278 { |
(...skipping 14 matching lines...) Expand all Loading... | |
295 { | 293 { |
296 if (m_developerData.isEmpty()) { | 294 if (m_developerData.isEmpty()) { |
297 RefPtr<SerializedScriptValue> serializedValue; | 295 RefPtr<SerializedScriptValue> serializedValue; |
298 | 296 |
299 const WebVector<char>& serializedData = m_data.data; | 297 const WebVector<char>& serializedData = m_data.data; |
300 if (serializedData.size()) | 298 if (serializedData.size()) |
301 serializedValue = SerializedScriptValueFactory::instance().createFro mWireBytes(serializedData.data(), serializedData.size()); | 299 serializedValue = SerializedScriptValueFactory::instance().createFro mWireBytes(serializedData.data(), serializedData.size()); |
302 else | 300 else |
303 serializedValue = SerializedScriptValueFactory::instance().create(); | 301 serializedValue = SerializedScriptValueFactory::instance().create(); |
304 | 302 |
305 m_developerData = ScriptValue(scriptState, serializedValue->deserialize( scriptState->isolate())); | 303 m_developerData = ScriptValue::from(scriptState, serializedValue->deseri alize(scriptState->isolate())); |
306 } | 304 } |
307 | 305 |
308 return m_developerData; | 306 return m_developerData; |
309 } | 307 } |
310 | 308 |
311 HeapVector<NotificationAction> Notification::actions() const | 309 Vector<v8::Local<v8::Value>> Notification::actions(ScriptState* scriptState) con st |
312 { | 310 { |
313 HeapVector<NotificationAction> actions; | 311 Vector<v8::Local<v8::Value>> actions; |
314 actions.grow(m_data.actions.size()); | 312 actions.grow(m_data.actions.size()); |
315 | 313 |
316 for (size_t i = 0; i < m_data.actions.size(); ++i) { | 314 for (size_t i = 0; i < m_data.actions.size(); ++i) { |
315 NotificationAction action; | |
316 | |
317 switch (m_data.actions[i].type) { | 317 switch (m_data.actions[i].type) { |
318 case WebNotificationAction::Button: | 318 case WebNotificationAction::Button: |
319 actions[i].setType("button"); | 319 action.setType("button"); |
320 break; | 320 break; |
321 case WebNotificationAction::Text: | 321 case WebNotificationAction::Text: |
322 actions[i].setType("text"); | 322 action.setType("text"); |
323 break; | 323 break; |
324 default: | 324 default: |
325 NOTREACHED() << "Unknown action type: " << m_data.actions[i].type; | 325 NOTREACHED() << "Unknown action type: " << m_data.actions[i].type; |
326 } | 326 } |
327 actions[i].setAction(m_data.actions[i].action); | 327 action.setAction(m_data.actions[i].action); |
328 actions[i].setTitle(m_data.actions[i].title); | 328 action.setTitle(m_data.actions[i].title); |
329 actions[i].setIcon(m_data.actions[i].icon.string()); | 329 action.setIcon(m_data.actions[i].icon.string()); |
330 actions[i].setPlaceholder(m_data.actions[i].placeholder); | 330 action.setPlaceholder(m_data.actions[i].placeholder); |
331 | |
332 // Not just the sequence of actions itself, but also the actions contain ed within the | |
333 // sequence should be frozen per the Web Notification specification. | |
334 actions[i] = freezeV8Object(toV8(action, scriptState), scriptState->isol ate()); | |
bashi
2016/05/17 02:42:12
Not directly related to this CL but it seems that
| |
331 } | 335 } |
332 | 336 |
333 return actions; | 337 return actions; |
334 } | 338 } |
335 | 339 |
336 String Notification::permissionString(mojom::PermissionStatus permission) | 340 String Notification::permissionString(mojom::PermissionStatus permission) |
337 { | 341 { |
338 switch (permission) { | 342 switch (permission) { |
339 case mojom::PermissionStatus::GRANTED: | 343 case mojom::PermissionStatus::GRANTED: |
340 return "granted"; | 344 return "granted"; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
407 | 411 |
408 DEFINE_TRACE(Notification) | 412 DEFINE_TRACE(Notification) |
409 { | 413 { |
410 visitor->trace(m_prepareShowMethodRunner); | 414 visitor->trace(m_prepareShowMethodRunner); |
411 visitor->trace(m_loader); | 415 visitor->trace(m_loader); |
412 EventTargetWithInlineData::trace(visitor); | 416 EventTargetWithInlineData::trace(visitor); |
413 ActiveDOMObject::trace(visitor); | 417 ActiveDOMObject::trace(visitor); |
414 } | 418 } |
415 | 419 |
416 } // namespace blink | 420 } // namespace blink |
OLD | NEW |