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

Unified Diff: Source/modules/notifications/ServiceWorkerRegistrationNotifications.cpp

Issue 1263043002: Add NotificationOptions.actions so websites can provide buttons (blink) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 5 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/ServiceWorkerRegistrationNotifications.cpp
diff --git a/Source/modules/notifications/ServiceWorkerRegistrationNotifications.cpp b/Source/modules/notifications/ServiceWorkerRegistrationNotifications.cpp
index 9d689190d02ecd4f52d676f1ddfacd701867bc88..ebf0c2d220a871ecc15624c2ac2fbc534c95770a 100644
--- a/Source/modules/notifications/ServiceWorkerRegistrationNotifications.cpp
+++ b/Source/modules/notifications/ServiceWorkerRegistrationNotifications.cpp
@@ -73,6 +73,11 @@ ScriptPromise ServiceWorkerRegistrationNotifications::showNotification(ScriptSta
data->toWireBytes(dataAsWireBytes);
}
+ for (NotificationAction action : options.actions()) {
+ if (action.title().isEmpty())
+ return ScriptPromise::reject(scriptState, V8ThrowException::createTypeError(scriptState->isolate(), "Notification action titles must not be empty."));
+ }
+
RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scriptState);
ScriptPromise promise = resolver->promise();
@@ -87,7 +92,9 @@ ScriptPromise ServiceWorkerRegistrationNotifications::showNotification(ScriptSta
WebNotificationData::Direction dir = options.dir() == "rtl" ? WebNotificationData::DirectionRightToLeft : WebNotificationData::DirectionLeftToRight;
NavigatorVibration::VibrationPattern vibrate = NavigatorVibration::sanitizeVibrationPattern(options.vibrate());
- WebNotificationData notification(title, dir, options.lang(), options.body(), options.tag(), iconUrl, vibrate, options.silent(), dataAsWireBytes);
+ WebVector<WebNotificationAction> webActions;
+ Notification::actionsToWebActions(options.actions(), webActions);
+ WebNotificationData notification(title, dir, options.lang(), options.body(), options.tag(), iconUrl, vibrate, options.silent(), dataAsWireBytes, webActions);
WebNotificationShowCallbacks* callbacks = new CallbackPromiseAdapter<void, void>(resolver);
SecurityOrigin* origin = executionContext->securityOrigin();

Powered by Google App Engine
This is Rietveld 408576698