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

Side by Side Diff: content/child/notifications/notification_manager.cc

Issue 2537953003: WebString: makes string16 conversions explicit (part 1: blink, content) (Closed)
Patch Set: fix Created 4 years 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 "content/child/notifications/notification_manager.h" 5 #include "content/child/notifications/notification_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 blink::WebNotificationDelegate* delegate) { 88 blink::WebNotificationDelegate* delegate) {
89 DCHECK_EQ(0u, notification_data.actions.size()); 89 DCHECK_EQ(0u, notification_data.actions.size());
90 DCHECK_EQ(0u, notification_resources->actionIcons.size()); 90 DCHECK_EQ(0u, notification_resources->actionIcons.size());
91 91
92 GURL origin_gurl = url::Origin(origin).GetURL(); 92 GURL origin_gurl = url::Origin(origin).GetURL();
93 93
94 int notification_id = 94 int notification_id =
95 notification_dispatcher_->GenerateNotificationId(CurrentWorkerId()); 95 notification_dispatcher_->GenerateNotificationId(CurrentWorkerId());
96 96
97 active_page_notifications_[notification_id] = ActiveNotificationData( 97 active_page_notifications_[notification_id] = ActiveNotificationData(
98 delegate, origin_gurl, 98 delegate, origin_gurl, notification_data.tag.utf8());
99 base::UTF16ToUTF8(base::StringPiece16(notification_data.tag)));
100 99
101 // TODO(mkwst): This is potentially doing the wrong thing with unique 100 // TODO(mkwst): This is potentially doing the wrong thing with unique
102 // origins. Perhaps also 'file:', 'blob:' and 'filesystem:'. See 101 // origins. Perhaps also 'file:', 'blob:' and 'filesystem:'. See
103 // https://crbug.com/490074 for detail. 102 // https://crbug.com/490074 for detail.
104 thread_safe_sender_->Send(new PlatformNotificationHostMsg_Show( 103 thread_safe_sender_->Send(new PlatformNotificationHostMsg_Show(
105 notification_id, origin_gurl, 104 notification_id, origin_gurl,
106 ToPlatformNotificationData(notification_data), 105 ToPlatformNotificationData(notification_data),
107 ToNotificationResources(std::move(notification_resources)))); 106 ToNotificationResources(std::move(notification_resources))));
108 } 107 }
109 108
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 172
174 // TODO(peter): GenerateNotificationId is more of a request id. Consider 173 // TODO(peter): GenerateNotificationId is more of a request id. Consider
175 // renaming the method in the NotificationDispatcher if this makes sense. 174 // renaming the method in the NotificationDispatcher if this makes sense.
176 int request_id = 175 int request_id =
177 notification_dispatcher_->GenerateNotificationId(CurrentWorkerId()); 176 notification_dispatcher_->GenerateNotificationId(CurrentWorkerId());
178 177
179 pending_get_notification_requests_.AddWithID(std::move(callbacks), 178 pending_get_notification_requests_.AddWithID(std::move(callbacks),
180 request_id); 179 request_id);
181 180
182 thread_safe_sender_->Send(new PlatformNotificationHostMsg_GetNotifications( 181 thread_safe_sender_->Send(new PlatformNotificationHostMsg_GetNotifications(
183 request_id, service_worker_registration_id, origin, 182 request_id, service_worker_registration_id, origin, filter_tag.utf8()));
184 base::UTF16ToUTF8(base::StringPiece16(filter_tag))));
185 } 183 }
186 184
187 void NotificationManager::close(blink::WebNotificationDelegate* delegate) { 185 void NotificationManager::close(blink::WebNotificationDelegate* delegate) {
188 for (auto& iter : active_page_notifications_) { 186 for (auto& iter : active_page_notifications_) {
189 if (iter.second.delegate != delegate) 187 if (iter.second.delegate != delegate)
190 continue; 188 continue;
191 189
192 thread_safe_sender_->Send(new PlatformNotificationHostMsg_Close( 190 thread_safe_sender_->Send(new PlatformNotificationHostMsg_Close(
193 iter.second.origin, iter.second.tag, iter.first)); 191 iter.second.origin, iter.second.tag, iter.first));
194 active_page_notifications_.erase(iter.first); 192 active_page_notifications_.erase(iter.first);
195 return; 193 return;
196 } 194 }
197 195
198 // It should not be possible for Blink to call close() on a Notification which 196 // It should not be possible for Blink to call close() on a Notification which
199 // does not exist in either the pending or active notification lists. 197 // does not exist in either the pending or active notification lists.
200 NOTREACHED(); 198 NOTREACHED();
201 } 199 }
202 200
203 void NotificationManager::closePersistent( 201 void NotificationManager::closePersistent(
204 const blink::WebSecurityOrigin& origin, 202 const blink::WebSecurityOrigin& origin,
205 const blink::WebString& tag, 203 const blink::WebString& tag,
206 const blink::WebString& notification_id) { 204 const blink::WebString& notification_id) {
207 thread_safe_sender_->Send(new PlatformNotificationHostMsg_ClosePersistent( 205 thread_safe_sender_->Send(new PlatformNotificationHostMsg_ClosePersistent(
208 // TODO(mkwst): This is potentially doing the wrong thing with unique 206 // TODO(mkwst): This is potentially doing the wrong thing with unique
209 // origins. Perhaps also 'file:', 'blob:' and 'filesystem:'. See 207 // origins. Perhaps also 'file:', 'blob:' and 'filesystem:'. See
210 // https://crbug.com/490074 for detail. 208 // https://crbug.com/490074 for detail.
211 url::Origin(origin).GetURL(), base::UTF16ToUTF8(base::StringPiece16(tag)), 209 url::Origin(origin).GetURL(), tag.utf8(), notification_id.utf8()));
212 base::UTF16ToUTF8(base::StringPiece16(notification_id))));
213 } 210 }
214 211
215 void NotificationManager::notifyDelegateDestroyed( 212 void NotificationManager::notifyDelegateDestroyed(
216 blink::WebNotificationDelegate* delegate) { 213 blink::WebNotificationDelegate* delegate) {
217 for (auto& iter : active_page_notifications_) { 214 for (auto& iter : active_page_notifications_) {
218 if (iter.second.delegate != delegate) 215 if (iter.second.delegate != delegate)
219 continue; 216 continue;
220 217
221 active_page_notifications_.erase(iter.first); 218 active_page_notifications_.erase(iter.first);
222 return; 219 return;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 299
303 notifications[i] = web_notification_info; 300 notifications[i] = web_notification_info;
304 } 301 }
305 302
306 callbacks->onSuccess(notifications); 303 callbacks->onSuccess(notifications);
307 304
308 pending_get_notification_requests_.Remove(request_id); 305 pending_get_notification_requests_.Remove(request_id);
309 } 306 }
310 307
311 } // namespace content 308 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698