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

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

Issue 1234553003: Supports the sound attribute to the Notification object Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: [WIP] 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 f902a7aa3534d3a84e8774574f02148d590bd773..c2d2301fce6ec0d3632bac1d7d2502eb2aed80b7 100644
--- a/Source/modules/notifications/ServiceWorkerRegistrationNotifications.cpp
+++ b/Source/modules/notifications/ServiceWorkerRegistrationNotifications.cpp
@@ -60,8 +60,8 @@ ScriptPromise ServiceWorkerRegistrationNotifications::showNotification(ScriptSta
if (Notification::checkPermission(executionContext) != WebNotificationPermissionAllowed)
return ScriptPromise::reject(scriptState, V8ThrowException::createTypeError(scriptState->isolate(), "No notification permission has been granted for this origin."));
- if (options.hasVibrate() && options.silent())
- return ScriptPromise::reject(scriptState, V8ThrowException::createTypeError(scriptState->isolate(), "Silent notifications must not specify vibration patterns."));
+ if ((options.hasSound() || options.hasVibrate()) && options.silent())
+ return ScriptPromise::reject(scriptState, V8ThrowException::createTypeError(scriptState->isolate(), "Silent notifications must not specify sound or vibration patterns."));
// FIXME: Unify the code path here with the Notification.create() function.
Vector<char> dataAsWireBytes;
@@ -85,9 +85,16 @@ ScriptPromise ServiceWorkerRegistrationNotifications::showNotification(ScriptSta
iconUrl = KURL();
}
+ KURL soundUrl;
+ if (options.hasSound() && !options.sound().isEmpty()) {
+ soundUrl = executionContext->completeURL(options.sound());
+ if (!soundUrl.isValid())
+ soundUrl = KURL();
+ }
+
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);
+ WebNotificationData notification(title, dir, options.lang(), options.body(), options.tag(), iconUrl, soundUrl, vibrate, options.silent(), dataAsWireBytes);
WebNotificationShowCallbacks* callbacks = new CallbackPromiseAdapter<void, void>(resolver);
SecurityOrigin* origin = executionContext->securityOrigin();
« no previous file with comments | « Source/modules/notifications/NotificationOptions.idl ('k') | public/platform/modules/notifications/WebNotificationData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698