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

Side by Side Diff: Source/modules/notifications/ServiceWorkerRegistrationNotifications.cpp

Issue 1226613002: [WIP] Implement sound attr in notification 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "modules/notifications/ServiceWorkerRegistrationNotifications.h" 6 #include "modules/notifications/ServiceWorkerRegistrationNotifications.h"
7 7
8 #include "bindings/core/v8/CallbackPromiseAdapter.h" 8 #include "bindings/core/v8/CallbackPromiseAdapter.h"
9 #include "bindings/core/v8/ExceptionState.h" 9 #include "bindings/core/v8/ExceptionState.h"
10 #include "bindings/core/v8/ScriptPromiseResolver.h" 10 #include "bindings/core/v8/ScriptPromiseResolver.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 85
86 // FIXME: Do the appropriate CORS checks on the icon URL. 86 // FIXME: Do the appropriate CORS checks on the icon URL.
87 87
88 KURL iconUrl; 88 KURL iconUrl;
89 if (options.hasIcon() && !options.icon().isEmpty()) { 89 if (options.hasIcon() && !options.icon().isEmpty()) {
90 iconUrl = executionContext->completeURL(options.icon()); 90 iconUrl = executionContext->completeURL(options.icon());
91 if (!iconUrl.isValid()) 91 if (!iconUrl.isValid())
92 iconUrl = KURL(); 92 iconUrl = KURL();
93 } 93 }
94 94
95 KURL soundUrl;
96 if (options.hasSound() && !options.sound().isEmpty()) {
97 soundUrl = executionContext->completeURL(options.sound());
98 if (!soundUrl.isValid())
99 soundUrl = KURL();
100 }
101
95 WebNotificationData::Direction dir = options.dir() == "rtl" ? WebNotificatio nData::DirectionRightToLeft : WebNotificationData::DirectionLeftToRight; 102 WebNotificationData::Direction dir = options.dir() == "rtl" ? WebNotificatio nData::DirectionRightToLeft : WebNotificationData::DirectionLeftToRight;
96 NavigatorVibration::VibrationPattern vibrate = NavigatorVibration::sanitizeV ibrationPattern(options.vibrate()); 103 NavigatorVibration::VibrationPattern vibrate = NavigatorVibration::sanitizeV ibrationPattern(options.vibrate());
97 WebNotificationData notification(title, dir, options.lang(), options.body(), options.tag(), iconUrl, vibrate, options.silent(), dataAsWireBytes); 104 WebNotificationData notification(title, dir, options.lang(), options.body(), options.tag(), iconUrl, soundUrl, vibrate, options.silent(), dataAsWireBytes);
98 WebNotificationShowCallbacks* callbacks = new CallbackPromiseAdapter<void, v oid>(resolver); 105 WebNotificationShowCallbacks* callbacks = new CallbackPromiseAdapter<void, v oid>(resolver);
99 106
100 SecurityOrigin* origin = executionContext->securityOrigin(); 107 SecurityOrigin* origin = executionContext->securityOrigin();
101 ASSERT(origin); 108 ASSERT(origin);
102 109
103 WebNotificationManager* notificationManager = Platform::current()->notificat ionManager(); 110 WebNotificationManager* notificationManager = Platform::current()->notificat ionManager();
104 ASSERT(notificationManager); 111 ASSERT(notificationManager);
105 112
106 notificationManager->showPersistent(WebSerializedOrigin(*origin), notificati on, serviceWorkerRegistration.webRegistration(), callbacks); 113 notificationManager->showPersistent(WebSerializedOrigin(*origin), notificati on, serviceWorkerRegistration.webRegistration(), callbacks);
107 return promise; 114 return promise;
108 } 115 }
109 116
110 ScriptPromise ServiceWorkerRegistrationNotifications::getNotifications(ScriptSta te* scriptState, ServiceWorkerRegistration& serviceWorkerRegistration, const Get NotificationOptions& options) 117 ScriptPromise ServiceWorkerRegistrationNotifications::getNotifications(ScriptSta te* scriptState, ServiceWorkerRegistration& serviceWorkerRegistration, const Get NotificationOptions& options)
111 { 118 {
112 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState); 119 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState);
113 ScriptPromise promise = resolver->promise(); 120 ScriptPromise promise = resolver->promise();
114 121
115 WebNotificationGetCallbacks* callbacks = new CallbackPromiseAdapter<Notifica tionArray, void>(resolver); 122 WebNotificationGetCallbacks* callbacks = new CallbackPromiseAdapter<Notifica tionArray, void>(resolver);
116 123
117 WebNotificationManager* notificationManager = Platform::current()->notificat ionManager(); 124 WebNotificationManager* notificationManager = Platform::current()->notificat ionManager();
118 ASSERT(notificationManager); 125 ASSERT(notificationManager);
119 126
120 notificationManager->getNotifications(options.tag(), serviceWorkerRegistrati on.webRegistration(), callbacks); 127 notificationManager->getNotifications(options.tag(), serviceWorkerRegistrati on.webRegistration(), callbacks);
121 return promise; 128 return promise;
122 } 129 }
123 130
124 } // namespace blink 131 } // namespace blink
OLDNEW
« 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