Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 if (author_data_size > PlatformNotificationData::kMaximumDeveloperDataSize) { | 140 if (author_data_size > PlatformNotificationData::kMaximumDeveloperDataSize) { |
| 141 owned_callbacks->onError(); | 141 owned_callbacks->onError(); |
| 142 return; | 142 return; |
| 143 } | 143 } |
| 144 | 144 |
| 145 // TODO(peter): GenerateNotificationId is more of a request id. Consider | 145 // TODO(peter): GenerateNotificationId is more of a request id. Consider |
| 146 // renaming the method in the NotificationDispatcher if this makes sense. | 146 // renaming the method in the NotificationDispatcher if this makes sense. |
| 147 int request_id = | 147 int request_id = |
| 148 notification_dispatcher_->GenerateNotificationId(CurrentWorkerId()); | 148 notification_dispatcher_->GenerateNotificationId(CurrentWorkerId()); |
| 149 | 149 |
| 150 pending_show_notification_requests_.AddWithID(owned_callbacks.release(), | 150 pending_show_notification_requests_.AddWithID(std::move(owned_callbacks), |
| 151 request_id); | 151 request_id); |
| 152 | 152 |
| 153 // TODO(mkwst): This is potentially doing the wrong thing with unique | 153 // TODO(mkwst): This is potentially doing the wrong thing with unique |
| 154 // origins. Perhaps also 'file:', 'blob:' and 'filesystem:'. See | 154 // origins. Perhaps also 'file:', 'blob:' and 'filesystem:'. See |
| 155 // https://crbug.com/490074 for detail. | 155 // https://crbug.com/490074 for detail. |
| 156 thread_safe_sender_->Send(new PlatformNotificationHostMsg_ShowPersistent( | 156 thread_safe_sender_->Send(new PlatformNotificationHostMsg_ShowPersistent( |
| 157 request_id, service_worker_registration_id, url::Origin(origin).GetURL(), | 157 request_id, service_worker_registration_id, url::Origin(origin).GetURL(), |
| 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) { |
|
danakj
2016/11/18 00:15:33
and this?
| |
| 166 DCHECK(service_worker_registration); | 166 DCHECK(service_worker_registration); |
| 167 DCHECK(callbacks); | 167 DCHECK(callbacks); |
| 168 | 168 |
| 169 WebServiceWorkerRegistrationImpl* service_worker_registration_impl = | 169 WebServiceWorkerRegistrationImpl* service_worker_registration_impl = |
| 170 static_cast<WebServiceWorkerRegistrationImpl*>( | 170 static_cast<WebServiceWorkerRegistrationImpl*>( |
| 171 service_worker_registration); | 171 service_worker_registration); |
| 172 | 172 |
| 173 GURL origin = GURL(service_worker_registration_impl->scope()).GetOrigin(); | 173 GURL origin = GURL(service_worker_registration_impl->scope()).GetOrigin(); |
| 174 int64_t service_worker_registration_id = | 174 int64_t service_worker_registration_id = |
| 175 service_worker_registration_impl->registration_id(); | 175 service_worker_registration_impl->registration_id(); |
| 176 | 176 |
| 177 // TODO(peter): GenerateNotificationId is more of a request id. Consider | 177 // TODO(peter): GenerateNotificationId is more of a request id. Consider |
| 178 // renaming the method in the NotificationDispatcher if this makes sense. | 178 // renaming the method in the NotificationDispatcher if this makes sense. |
| 179 int request_id = | 179 int request_id = |
| 180 notification_dispatcher_->GenerateNotificationId(CurrentWorkerId()); | 180 notification_dispatcher_->GenerateNotificationId(CurrentWorkerId()); |
| 181 | 181 |
| 182 pending_get_notification_requests_.AddWithID(callbacks, request_id); | 182 pending_get_notification_requests_.AddWithID( |
| 183 std::unique_ptr<blink::WebNotificationGetCallbacks>(callbacks), | |
| 184 request_id); | |
| 183 | 185 |
| 184 thread_safe_sender_->Send(new PlatformNotificationHostMsg_GetNotifications( | 186 thread_safe_sender_->Send(new PlatformNotificationHostMsg_GetNotifications( |
| 185 request_id, service_worker_registration_id, origin, | 187 request_id, service_worker_registration_id, origin, |
| 186 base::UTF16ToUTF8(base::StringPiece16(filter_tag)))); | 188 base::UTF16ToUTF8(base::StringPiece16(filter_tag)))); |
| 187 } | 189 } |
| 188 | 190 |
| 189 void NotificationManager::close(blink::WebNotificationDelegate* delegate) { | 191 void NotificationManager::close(blink::WebNotificationDelegate* delegate) { |
| 190 for (auto& iter : active_page_notifications_) { | 192 for (auto& iter : active_page_notifications_) { |
| 191 if (iter.second.delegate != delegate) | 193 if (iter.second.delegate != delegate) |
| 192 continue; | 194 continue; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 304 | 306 |
| 305 notifications[i] = web_notification_info; | 307 notifications[i] = web_notification_info; |
| 306 } | 308 } |
| 307 | 309 |
| 308 callbacks->onSuccess(notifications); | 310 callbacks->onSuccess(notifications); |
| 309 | 311 |
| 310 pending_get_notification_requests_.Remove(request_id); | 312 pending_get_notification_requests_.Remove(request_id); |
| 311 } | 313 } |
| 312 | 314 |
| 313 } // namespace content | 315 } // namespace content |
| OLD | NEW |