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

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

Issue 1226613002: [WIP] Implement sound attr in notification Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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..345859154ad543319483f292ff7e54277418d6d8 100644
--- a/Source/modules/notifications/Notification.cpp
+++ b/Source/modules/notifications/Notification.cpp
@@ -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