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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 } | 87 } |
88 | 88 |
89 RefPtr<SerializedScriptValue> data; | 89 RefPtr<SerializedScriptValue> data; |
90 if (options.hasData()) { | 90 if (options.hasData()) { |
91 data = SerializedScriptValueFactory::instance().create(options.data().is
olate(), options.data(), nullptr, exceptionState); | 91 data = SerializedScriptValueFactory::instance().create(options.data().is
olate(), options.data(), nullptr, exceptionState); |
92 if (exceptionState.hadException()) | 92 if (exceptionState.hadException()) |
93 return nullptr; | 93 return nullptr; |
94 } | 94 } |
95 | 95 |
96 for (const NotificationAction& action : options.actions()) { | 96 for (const NotificationAction& action : options.actions()) { |
| 97 if (action.action().isEmpty()) { |
| 98 exceptionState.throwTypeError("NotificationAction action must not be
empty."); |
| 99 return nullptr; |
| 100 } |
97 if (action.title().isEmpty()) { | 101 if (action.title().isEmpty()) { |
98 exceptionState.throwTypeError("Notification action titles must not b
e empty."); | 102 exceptionState.throwTypeError("NotificationAction title must not be
empty."); |
99 return nullptr; | 103 return nullptr; |
100 } | 104 } |
101 } | 105 } |
102 | 106 |
103 Notification* notification = new Notification(title, context); | 107 Notification* notification = new Notification(title, context); |
104 | 108 |
105 notification->setBody(options.body()); | 109 notification->setBody(options.body()); |
106 notification->setTag(options.tag()); | 110 notification->setTag(options.tag()); |
107 notification->setLang(options.lang()); | 111 notification->setLang(options.lang()); |
108 notification->setDir(options.dir()); | 112 notification->setDir(options.dir()); |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 size_t Notification::maxActions() | 324 size_t Notification::maxActions() |
321 { | 325 { |
322 return notificationManager()->maxActions(); | 326 return notificationManager()->maxActions(); |
323 } | 327 } |
324 | 328 |
325 void Notification::actionsToWebActions(const HeapVector<NotificationAction>& act
ions, WebVector<WebNotificationAction>* webActions) | 329 void Notification::actionsToWebActions(const HeapVector<NotificationAction>& act
ions, WebVector<WebNotificationAction>* webActions) |
326 { | 330 { |
327 size_t count = std::min(maxActions(), actions.size()); | 331 size_t count = std::min(maxActions(), actions.size()); |
328 WebVector<WebNotificationAction> clearedAndResized(count); | 332 WebVector<WebNotificationAction> clearedAndResized(count); |
329 webActions->swap(clearedAndResized); | 333 webActions->swap(clearedAndResized); |
330 for (size_t i = 0; i < count; ++i) | 334 for (size_t i = 0; i < count; ++i) { |
| 335 (*webActions)[i].action = actions[i].action(); |
331 (*webActions)[i].title = actions[i].title(); | 336 (*webActions)[i].title = actions[i].title(); |
| 337 } |
332 } | 338 } |
333 | 339 |
334 void Notification::webActionsToActions(const WebVector<WebNotificationAction>& w
ebActions, HeapVector<NotificationAction>* actions) | 340 void Notification::webActionsToActions(const WebVector<WebNotificationAction>& w
ebActions, HeapVector<NotificationAction>* actions) |
335 { | 341 { |
336 actions->clear(); | 342 actions->clear(); |
337 actions->grow(webActions.size()); | 343 actions->grow(webActions.size()); |
338 for (size_t i = 0; i < webActions.size(); ++i) | 344 for (size_t i = 0; i < webActions.size(); ++i) { |
| 345 (*actions)[i].setAction(webActions[i].action); |
339 (*actions)[i].setTitle(webActions[i].title); | 346 (*actions)[i].setTitle(webActions[i].title); |
| 347 } |
340 } | 348 } |
341 | 349 |
342 bool Notification::dispatchEventInternal(PassRefPtrWillBeRawPtr<Event> event) | 350 bool Notification::dispatchEventInternal(PassRefPtrWillBeRawPtr<Event> event) |
343 { | 351 { |
344 ASSERT(executionContext()->isContextThread()); | 352 ASSERT(executionContext()->isContextThread()); |
345 return EventTarget::dispatchEventInternal(event); | 353 return EventTarget::dispatchEventInternal(event); |
346 } | 354 } |
347 | 355 |
348 const AtomicString& Notification::interfaceName() const | 356 const AtomicString& Notification::interfaceName() const |
349 { | 357 { |
(...skipping 23 matching lines...) Expand all Loading... |
373 } | 381 } |
374 | 382 |
375 DEFINE_TRACE(Notification) | 383 DEFINE_TRACE(Notification) |
376 { | 384 { |
377 visitor->trace(m_actions); | 385 visitor->trace(m_actions); |
378 RefCountedGarbageCollectedEventTargetWithInlineData<Notification>::trace(vis
itor); | 386 RefCountedGarbageCollectedEventTargetWithInlineData<Notification>::trace(vis
itor); |
379 ActiveDOMObject::trace(visitor); | 387 ActiveDOMObject::trace(visitor); |
380 } | 388 } |
381 | 389 |
382 } // namespace blink | 390 } // namespace blink |
OLD | NEW |