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

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

Issue 1110223002: Use and add layout tests for BCP 47 language tag syntax validation. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « Source/modules/notifications/Notification.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 String lang = Platform::current()->isValidLocaleSyntax(options.lang()) ? opt ions.lang() : "";
96
95 WebNotificationData::Direction dir = options.dir() == "rtl" ? WebNotificatio nData::DirectionRightToLeft : WebNotificationData::DirectionLeftToRight; 97 WebNotificationData::Direction dir = options.dir() == "rtl" ? WebNotificatio nData::DirectionRightToLeft : WebNotificationData::DirectionLeftToRight;
96 NavigatorVibration::VibrationPattern vibrate = NavigatorVibration::sanitizeV ibrationPattern(options.vibrate()); 98 NavigatorVibration::VibrationPattern vibrate = NavigatorVibration::sanitizeV ibrationPattern(options.vibrate());
97 WebNotificationData notification(title, dir, options.lang(), options.body(), options.tag(), iconUrl, vibrate, options.silent(), dataAsWireBytes); 99 WebNotificationData notification(title, dir, lang, options.body(), options.t ag(), iconUrl, vibrate, options.silent(), dataAsWireBytes);
98 WebNotificationShowCallbacks* callbacks = new CallbackPromiseAdapter<void, v oid>(resolver); 100 WebNotificationShowCallbacks* callbacks = new CallbackPromiseAdapter<void, v oid>(resolver);
99 101
100 SecurityOrigin* origin = executionContext->securityOrigin(); 102 SecurityOrigin* origin = executionContext->securityOrigin();
101 ASSERT(origin); 103 ASSERT(origin);
102 104
103 WebNotificationManager* notificationManager = Platform::current()->notificat ionManager(); 105 WebNotificationManager* notificationManager = Platform::current()->notificat ionManager();
104 ASSERT(notificationManager); 106 ASSERT(notificationManager);
105 107
106 notificationManager->showPersistent(WebSerializedOrigin(*origin), notificati on, serviceWorkerRegistration.webRegistration(), callbacks); 108 notificationManager->showPersistent(WebSerializedOrigin(*origin), notificati on, serviceWorkerRegistration.webRegistration(), callbacks);
107 return promise; 109 return promise;
108 } 110 }
109 111
110 ScriptPromise ServiceWorkerRegistrationNotifications::getNotifications(ScriptSta te* scriptState, ServiceWorkerRegistration& serviceWorkerRegistration, const Get NotificationOptions& options) 112 ScriptPromise ServiceWorkerRegistrationNotifications::getNotifications(ScriptSta te* scriptState, ServiceWorkerRegistration& serviceWorkerRegistration, const Get NotificationOptions& options)
111 { 113 {
112 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState); 114 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState);
113 ScriptPromise promise = resolver->promise(); 115 ScriptPromise promise = resolver->promise();
114 116
115 WebNotificationGetCallbacks* callbacks = new CallbackPromiseAdapter<Notifica tionArray, void>(resolver); 117 WebNotificationGetCallbacks* callbacks = new CallbackPromiseAdapter<Notifica tionArray, void>(resolver);
116 118
117 WebNotificationManager* notificationManager = Platform::current()->notificat ionManager(); 119 WebNotificationManager* notificationManager = Platform::current()->notificat ionManager();
118 ASSERT(notificationManager); 120 ASSERT(notificationManager);
119 121
120 notificationManager->getNotifications(options.tag(), serviceWorkerRegistrati on.webRegistration(), callbacks); 122 notificationManager->getNotifications(options.tag(), serviceWorkerRegistrati on.webRegistration(), callbacks);
121 return promise; 123 return promise;
122 } 124 }
123 125
124 } // namespace blink 126 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/notifications/Notification.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698