Index: Source/modules/notifications/Notification.cpp |
diff --git a/Source/modules/notifications/Notification.cpp b/Source/modules/notifications/Notification.cpp |
index 72638ba4ea829c4cdff4694510ce411116331894..b278857629f2efccc95290ab9b208d808b4e2552 100644 |
--- a/Source/modules/notifications/Notification.cpp |
+++ b/Source/modules/notifications/Notification.cpp |
@@ -79,9 +79,9 @@ Notification* Notification::create(ExecutionContext* context, const String& titl |
return nullptr; |
} |
- // If options's silent is true, and options's vibrate is present, throw a TypeError exception. |
- if (options.hasVibrate() && options.silent()) { |
- exceptionState.throwTypeError("Silent notifications must not specify vibration patterns."); |
+ // If options's silent is true, and options's vibrate or sound is present, throw a TypeError exception. |
+ if ((options.hasSound() || options.hasVibrate()) && options.silent()) { |
+ exceptionState.throwTypeError("Silent notifications must not specify sound or vibration patterns."); |
return nullptr; |
} |
@@ -107,6 +107,12 @@ Notification* Notification::create(ExecutionContext* context, const String& titl |
notification->setIconUrl(iconUrl); |
} |
+ if (options.hasSound()) { |
+ KURL soundUrl = options.sound().isEmpty() ? KURL() : context->completeURL(options.sound()); |
+ if (!soundUrl.isEmpty() && soundUrl.isValid()) |
+ notification->setSoundUrl(soundUrl); |
+ } |
+ |
String insecureOriginMessage; |
UseCounter::Feature feature = context->isPrivilegedContext(insecureOriginMessage) |
? UseCounter::NotificationSecureOrigin |
@@ -132,6 +138,9 @@ Notification* Notification::create(ExecutionContext* context, int64_t persistent |
if (!data.icon.isEmpty()) |
notification->setIconUrl(data.icon); |
+ if (!data.sound.isEmpty()) |
+ notification->setSoundUrl(data.sound); |
+ |
if (!data.vibrate.isEmpty()) { |
NavigatorVibration::VibrationPattern pattern; |
pattern.appendRange(data.vibrate.begin(), data.vibrate.end()); |
@@ -191,7 +200,7 @@ void Notification::show() |
// they were created by, and thus the data doesn't have to be known to the embedder. |
Vector<char> emptyDataWireBytes; |
- WebNotificationData notificationData(m_title, dir, m_lang, m_body, m_tag, m_iconUrl, m_vibrate, m_silent, emptyDataWireBytes); |
+ WebNotificationData notificationData(m_title, dir, m_lang, m_body, m_tag, m_iconUrl, m_soundUrl, m_vibrate, m_silent, emptyDataWireBytes); |
notificationManager()->show(WebSerializedOrigin(*origin), notificationData, this); |
m_state = NotificationStateShowing; |