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

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

Issue 2382973002: Convert WebSecurityOrigin -> GURL without re-parsing the url (Closed)
Patch Set: rebase on #427122 Created 4 years, 1 month 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
« no previous file with comments | « content/child/notifications/notification_manager.h ('k') | content/child/storage_util.cc » ('j') | 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 "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"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "base/threading/thread_local.h" 12 #include "base/threading/thread_local.h"
13 #include "content/child/notifications/notification_data_conversions.h" 13 #include "content/child/notifications/notification_data_conversions.h"
14 #include "content/child/notifications/notification_dispatcher.h" 14 #include "content/child/notifications/notification_dispatcher.h"
15 #include "content/child/service_worker/web_service_worker_registration_impl.h" 15 #include "content/child/service_worker/web_service_worker_registration_impl.h"
16 #include "content/child/thread_safe_sender.h" 16 #include "content/child/thread_safe_sender.h"
17 #include "content/public/common/notification_resources.h" 17 #include "content/public/common/notification_resources.h"
18 #include "content/public/common/platform_notification_data.h" 18 #include "content/public/common/platform_notification_data.h"
19 #include "third_party/WebKit/public/platform/URLConversion.h" 19 #include "third_party/WebKit/public/platform/URLConversion.h"
20 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" 20 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
21 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati onDelegate.h" 21 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati onDelegate.h"
22 #include "url/origin.h"
22 23
23 namespace content { 24 namespace content {
24 namespace { 25 namespace {
25 26
26 int CurrentWorkerId() { 27 int CurrentWorkerId() {
27 return WorkerThread::GetCurrentId(); 28 return WorkerThread::GetCurrentId();
28 } 29 }
29 30
30 NotificationResources ToNotificationResources( 31 NotificationResources ToNotificationResources(
31 std::unique_ptr<blink::WebNotificationResources> web_resources) { 32 std::unique_ptr<blink::WebNotificationResources> web_resources) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 } 82 }
82 83
83 void NotificationManager::show( 84 void NotificationManager::show(
84 const blink::WebSecurityOrigin& origin, 85 const blink::WebSecurityOrigin& origin,
85 const blink::WebNotificationData& notification_data, 86 const blink::WebNotificationData& notification_data,
86 std::unique_ptr<blink::WebNotificationResources> notification_resources, 87 std::unique_ptr<blink::WebNotificationResources> notification_resources,
87 blink::WebNotificationDelegate* delegate) { 88 blink::WebNotificationDelegate* delegate) {
88 DCHECK_EQ(0u, notification_data.actions.size()); 89 DCHECK_EQ(0u, notification_data.actions.size());
89 DCHECK_EQ(0u, notification_resources->actionIcons.size()); 90 DCHECK_EQ(0u, notification_resources->actionIcons.size());
90 91
91 GURL origin_gurl = blink::WebStringToGURL(origin.toString()); 92 GURL origin_gurl = url::Origin(origin).GetURL();
92 93
93 int notification_id = 94 int notification_id =
94 notification_dispatcher_->GenerateNotificationId(CurrentWorkerId()); 95 notification_dispatcher_->GenerateNotificationId(CurrentWorkerId());
95 96
96 active_page_notifications_[notification_id] = ActiveNotificationData( 97 active_page_notifications_[notification_id] = ActiveNotificationData(
97 delegate, origin_gurl, 98 delegate, origin_gurl,
98 base::UTF16ToUTF8(base::StringPiece16(notification_data.tag))); 99 base::UTF16ToUTF8(base::StringPiece16(notification_data.tag)));
99 100
100 // TODO(mkwst): This is potentially doing the wrong thing with unique 101 // TODO(mkwst): This is potentially doing the wrong thing with unique
101 // origins. Perhaps also 'file:', 'blob:' and 'filesystem:'. See 102 // origins. Perhaps also 'file:', 'blob:' and 'filesystem:'. See
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 int request_id = 147 int request_id =
147 notification_dispatcher_->GenerateNotificationId(CurrentWorkerId()); 148 notification_dispatcher_->GenerateNotificationId(CurrentWorkerId());
148 149
149 pending_show_notification_requests_.AddWithID(owned_callbacks.release(), 150 pending_show_notification_requests_.AddWithID(owned_callbacks.release(),
150 request_id); 151 request_id);
151 152
152 // TODO(mkwst): This is potentially doing the wrong thing with unique 153 // TODO(mkwst): This is potentially doing the wrong thing with unique
153 // origins. Perhaps also 'file:', 'blob:' and 'filesystem:'. See 154 // origins. Perhaps also 'file:', 'blob:' and 'filesystem:'. See
154 // https://crbug.com/490074 for detail. 155 // https://crbug.com/490074 for detail.
155 thread_safe_sender_->Send(new PlatformNotificationHostMsg_ShowPersistent( 156 thread_safe_sender_->Send(new PlatformNotificationHostMsg_ShowPersistent(
156 request_id, service_worker_registration_id, 157 request_id, service_worker_registration_id, url::Origin(origin).GetURL(),
157 blink::WebStringToGURL(origin.toString()),
158 ToPlatformNotificationData(notification_data), 158 ToPlatformNotificationData(notification_data),
159 ToNotificationResources(std::move(notification_resources)))); 159 ToNotificationResources(std::move(notification_resources))));
160 } 160 }
161 161
162 void NotificationManager::getNotifications( 162 void NotificationManager::getNotifications(
163 const blink::WebString& filter_tag, 163 const blink::WebString& filter_tag,
164 blink::WebServiceWorkerRegistration* service_worker_registration, 164 blink::WebServiceWorkerRegistration* service_worker_registration,
165 blink::WebNotificationGetCallbacks* callbacks) { 165 blink::WebNotificationGetCallbacks* callbacks) {
166 DCHECK(service_worker_registration); 166 DCHECK(service_worker_registration);
167 DCHECK(callbacks); 167 DCHECK(callbacks);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 } 203 }
204 204
205 void NotificationManager::closePersistent( 205 void NotificationManager::closePersistent(
206 const blink::WebSecurityOrigin& origin, 206 const blink::WebSecurityOrigin& origin,
207 const blink::WebString& tag, 207 const blink::WebString& tag,
208 const blink::WebString& notification_id) { 208 const blink::WebString& notification_id) {
209 thread_safe_sender_->Send(new PlatformNotificationHostMsg_ClosePersistent( 209 thread_safe_sender_->Send(new PlatformNotificationHostMsg_ClosePersistent(
210 // TODO(mkwst): This is potentially doing the wrong thing with unique 210 // TODO(mkwst): This is potentially doing the wrong thing with unique
211 // origins. Perhaps also 'file:', 'blob:' and 'filesystem:'. See 211 // origins. Perhaps also 'file:', 'blob:' and 'filesystem:'. See
212 // https://crbug.com/490074 for detail. 212 // https://crbug.com/490074 for detail.
213 blink::WebStringToGURL(origin.toString()), 213 url::Origin(origin).GetURL(), base::UTF16ToUTF8(base::StringPiece16(tag)),
214 base::UTF16ToUTF8(base::StringPiece16(tag)),
215 base::UTF16ToUTF8(base::StringPiece16(notification_id)))); 214 base::UTF16ToUTF8(base::StringPiece16(notification_id))));
216 } 215 }
217 216
218 void NotificationManager::notifyDelegateDestroyed( 217 void NotificationManager::notifyDelegateDestroyed(
219 blink::WebNotificationDelegate* delegate) { 218 blink::WebNotificationDelegate* delegate) {
220 for (auto& iter : active_page_notifications_) { 219 for (auto& iter : active_page_notifications_) {
221 if (iter.second.delegate != delegate) 220 if (iter.second.delegate != delegate)
222 continue; 221 continue;
223 222
224 active_page_notifications_.erase(iter.first); 223 active_page_notifications_.erase(iter.first);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 304
306 notifications[i] = web_notification_info; 305 notifications[i] = web_notification_info;
307 } 306 }
308 307
309 callbacks->onSuccess(notifications); 308 callbacks->onSuccess(notifications);
310 309
311 pending_get_notification_requests_.Remove(request_id); 310 pending_get_notification_requests_.Remove(request_id);
312 } 311 }
313 312
314 } // namespace content 313 } // namespace content
OLDNEW
« no previous file with comments | « content/child/notifications/notification_manager.h ('k') | content/child/storage_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698