Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(662)

Side by Side Diff: Source/modules/notifications/Notification.cpp

Issue 1263043003: Add NotificationAction.action member (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@actions
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 } 86 }
87 87
88 RefPtr<SerializedScriptValue> data; 88 RefPtr<SerializedScriptValue> data;
89 if (options.hasData()) { 89 if (options.hasData()) {
90 data = SerializedScriptValueFactory::instance().create(options.data().is olate(), options.data(), nullptr, exceptionState); 90 data = SerializedScriptValueFactory::instance().create(options.data().is olate(), options.data(), nullptr, exceptionState);
91 if (exceptionState.hadException()) 91 if (exceptionState.hadException())
92 return nullptr; 92 return nullptr;
93 } 93 }
94 94
95 for (NotificationAction action : options.actions()) { 95 for (NotificationAction action : options.actions()) {
96 if (action.action().isEmpty()) {
97 exceptionState.throwTypeError("NotificationAction action must not be empty.");
98 return nullptr;
99 }
96 if (action.title().isEmpty()) { 100 if (action.title().isEmpty()) {
97 exceptionState.throwTypeError("Notification action titles must not b e empty."); 101 exceptionState.throwTypeError("NotificationAction title must not be empty.");
98 return nullptr; 102 return nullptr;
99 } 103 }
100 } 104 }
101 105
102 Notification* notification = new Notification(title, context); 106 Notification* notification = new Notification(title, context);
103 107
104 notification->setBody(options.body()); 108 notification->setBody(options.body());
105 notification->setTag(options.tag()); 109 notification->setTag(options.tag());
106 notification->setLang(options.lang()); 110 notification->setLang(options.lang());
107 notification->setDir(options.dir()); 111 notification->setDir(options.dir());
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 // when Blink supports [Exposed] annotations on class members in IDL definit ions. 306 // when Blink supports [Exposed] annotations on class members in IDL definit ions.
303 if (NotificationPermissionClient* permissionClient = NotificationPermissionC lient::from(context)) 307 if (NotificationPermissionClient* permissionClient = NotificationPermissionC lient::from(context))
304 permissionClient->requestPermission(context, callback); 308 permissionClient->requestPermission(context, callback);
305 } 309 }
306 310
307 void Notification::webActionsToActions(const WebVector<WebNotificationAction>& w ebActions, Vector<NotificationAction>& actions) 311 void Notification::webActionsToActions(const WebVector<WebNotificationAction>& w ebActions, Vector<NotificationAction>& actions)
308 { 312 {
309 actions.clear(); 313 actions.clear();
310 actions.grow(webActions.size()); 314 actions.grow(webActions.size());
311 for (size_t i = 0; i < webActions.size(); ++i) { 315 for (size_t i = 0; i < webActions.size(); ++i) {
316 actions[i].setAction(webActions[i].action);
312 actions[i].setTitle(webActions[i].title); 317 actions[i].setTitle(webActions[i].title);
313 } 318 }
314 } 319 }
315 320
316 bool Notification::dispatchEventInternal(PassRefPtrWillBeRawPtr<Event> event) 321 bool Notification::dispatchEventInternal(PassRefPtrWillBeRawPtr<Event> event)
317 { 322 {
318 ASSERT(executionContext()->isContextThread()); 323 ASSERT(executionContext()->isContextThread());
319 return EventTarget::dispatchEventInternal(event); 324 return EventTarget::dispatchEventInternal(event);
320 } 325 }
321 326
(...skipping 24 matching lines...) Expand all
346 return ScriptValue(scriptState, m_serializedData->deserialize(scriptState->i solate())); 351 return ScriptValue(scriptState, m_serializedData->deserialize(scriptState->i solate()));
347 } 352 }
348 353
349 DEFINE_TRACE(Notification) 354 DEFINE_TRACE(Notification)
350 { 355 {
351 RefCountedGarbageCollectedEventTargetWithInlineData<Notification>::trace(vis itor); 356 RefCountedGarbageCollectedEventTargetWithInlineData<Notification>::trace(vis itor);
352 ActiveDOMObject::trace(visitor); 357 ActiveDOMObject::trace(visitor);
353 } 358 }
354 359
355 } // namespace blink 360 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698