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

Unified Diff: Source/modules/notifications/Notification.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
« no previous file with comments | « Source/modules/notifications/Notification.h ('k') | Source/modules/notifications/Notification.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « Source/modules/notifications/Notification.h ('k') | Source/modules/notifications/Notification.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698