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

Unified 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: Fix rebase 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 side-by-side diff with in-line comments
Download patch
Index: Source/modules/notifications/Notification.cpp
diff --git a/Source/modules/notifications/Notification.cpp b/Source/modules/notifications/Notification.cpp
index e11876a229e2dc3dcfaf38e0dc10e15f8a5d1ece..cb95b15625b0b8f6661ed312321f923e6d905d7f 100644
--- a/Source/modules/notifications/Notification.cpp
+++ b/Source/modules/notifications/Notification.cpp
@@ -94,8 +94,12 @@ Notification* Notification::create(ExecutionContext* context, const String& titl
}
for (const NotificationAction& action : options.actions()) {
+ if (action.action().isEmpty()) {
+ exceptionState.throwTypeError("NotificationAction action must not be empty.");
+ return nullptr;
+ }
if (action.title().isEmpty()) {
- exceptionState.throwTypeError("Notification action titles must not be empty.");
+ exceptionState.throwTypeError("NotificationAction title must not be empty.");
return nullptr;
}
}
@@ -327,16 +331,20 @@ void Notification::actionsToWebActions(const HeapVector<NotificationAction>& act
size_t count = std::min(maxActions(), actions.size());
WebVector<WebNotificationAction> clearedAndResized(count);
webActions->swap(clearedAndResized);
- for (size_t i = 0; i < count; ++i)
+ for (size_t i = 0; i < count; ++i) {
+ (*webActions)[i].action = actions[i].action();
(*webActions)[i].title = actions[i].title();
+ }
}
void Notification::webActionsToActions(const WebVector<WebNotificationAction>& webActions, HeapVector<NotificationAction>* actions)
{
actions->clear();
actions->grow(webActions.size());
- for (size_t i = 0; i < webActions.size(); ++i)
+ for (size_t i = 0; i < webActions.size(); ++i) {
+ (*actions)[i].setAction(webActions[i].action);
(*actions)[i].setTitle(webActions[i].title);
+ }
}
bool Notification::dispatchEventInternal(PassRefPtrWillBeRawPtr<Event> event)

Powered by Google App Engine
This is Rietveld 408576698