| 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 "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "base/thread_task_runner_handle.h" |
| 9 #include "base/threading/thread_local.h" | 10 #include "base/threading/thread_local.h" |
| 10 #include "content/child/notifications/notification_data_conversions.h" | 11 #include "content/child/notifications/notification_data_conversions.h" |
| 11 #include "content/child/notifications/notification_dispatcher.h" | 12 #include "content/child/notifications/notification_dispatcher.h" |
| 12 #include "content/child/notifications/notification_image_loader.h" | 13 #include "content/child/notifications/notification_image_loader.h" |
| 13 #include "content/child/service_worker/web_service_worker_registration_impl.h" | 14 #include "content/child/service_worker/web_service_worker_registration_impl.h" |
| 14 #include "content/child/thread_safe_sender.h" | 15 #include "content/child/thread_safe_sender.h" |
| 15 #include "content/child/worker_task_runner.h" | 16 #include "content/child/worker_task_runner.h" |
| 16 #include "content/common/platform_notification_messages.h" | 17 #include "content/common/platform_notification_messages.h" |
| 17 #include "content/public/common/platform_notification_data.h" | 18 #include "content/public/common/platform_notification_data.h" |
| 18 #include "third_party/WebKit/public/platform/WebNotificationData.h" | 19 #include "third_party/WebKit/public/platform/WebNotificationData.h" |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 iter->second->dispatchClickEvent(); | 206 iter->second->dispatchClickEvent(); |
| 206 } | 207 } |
| 207 | 208 |
| 208 scoped_refptr<NotificationImageLoader> NotificationManager::CreateImageLoader( | 209 scoped_refptr<NotificationImageLoader> NotificationManager::CreateImageLoader( |
| 209 const blink::WebURL& image_url, | 210 const blink::WebURL& image_url, |
| 210 const NotificationImageLoadedCallback& callback) const { | 211 const NotificationImageLoadedCallback& callback) const { |
| 211 scoped_refptr<NotificationImageLoader> pending_notification( | 212 scoped_refptr<NotificationImageLoader> pending_notification( |
| 212 new NotificationImageLoader(callback)); | 213 new NotificationImageLoader(callback)); |
| 213 | 214 |
| 214 main_thread_task_runner_->PostTask( | 215 main_thread_task_runner_->PostTask( |
| 215 FROM_HERE, | 216 FROM_HERE, base::Bind(&NotificationImageLoader::StartOnMainThread, |
| 216 base::Bind(&NotificationImageLoader::StartOnMainThread, | 217 pending_notification, image_url, |
| 217 pending_notification, | 218 base::ThreadTaskRunnerHandle::Get())); |
| 218 image_url, | |
| 219 CurrentWorkerId())); | |
| 220 | 219 |
| 221 return pending_notification; | 220 return pending_notification; |
| 222 } | 221 } |
| 223 | 222 |
| 224 void NotificationManager::DisplayNotification( | 223 void NotificationManager::DisplayNotification( |
| 225 const blink::WebSerializedOrigin& origin, | 224 const blink::WebSerializedOrigin& origin, |
| 226 const blink::WebNotificationData& notification_data, | 225 const blink::WebNotificationData& notification_data, |
| 227 blink::WebNotificationDelegate* delegate, | 226 blink::WebNotificationDelegate* delegate, |
| 228 scoped_refptr<NotificationImageLoader> image_loader) { | 227 scoped_refptr<NotificationImageLoader> image_loader) { |
| 229 int notification_id = | 228 int notification_id = |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 blink::WebNotificationDelegate* delegate) { | 279 blink::WebNotificationDelegate* delegate) { |
| 281 const auto& iter = pending_page_notifications_.find(delegate); | 280 const auto& iter = pending_page_notifications_.find(delegate); |
| 282 if (iter == pending_page_notifications_.end()) | 281 if (iter == pending_page_notifications_.end()) |
| 283 return false; | 282 return false; |
| 284 | 283 |
| 285 pending_page_notifications_.erase(iter); | 284 pending_page_notifications_.erase(iter); |
| 286 return true; | 285 return true; |
| 287 } | 286 } |
| 288 | 287 |
| 289 } // namespace content | 288 } // namespace content |
| OLD | NEW |