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 <cmath> | 7 #include <cmath> |
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/thread_task_runner_handle.h" | 12 #include "base/thread_task_runner_handle.h" |
13 #include "base/threading/thread_local.h" | 13 #include "base/threading/thread_local.h" |
14 #include "content/child/notifications/notification_data_conversions.h" | 14 #include "content/child/notifications/notification_data_conversions.h" |
15 #include "content/child/notifications/notification_dispatcher.h" | 15 #include "content/child/notifications/notification_dispatcher.h" |
16 #include "content/child/service_worker/web_service_worker_registration_impl.h" | 16 #include "content/child/service_worker/web_service_worker_registration_impl.h" |
17 #include "content/child/thread_safe_sender.h" | 17 #include "content/child/thread_safe_sender.h" |
18 #include "content/child/worker_task_runner.h" | 18 #include "content/child/worker_task_runner.h" |
| 19 #include "content/common/notification_constants.h" |
19 #include "content/public/common/platform_notification_data.h" | 20 #include "content/public/common/platform_notification_data.h" |
20 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 21 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
21 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati
onDelegate.h" | 22 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati
onDelegate.h" |
22 #include "third_party/skia/include/core/SkBitmap.h" | 23 #include "third_party/skia/include/core/SkBitmap.h" |
23 | 24 |
24 using blink::WebNotificationPermission; | 25 using blink::WebNotificationPermission; |
25 | 26 |
26 namespace content { | 27 namespace content { |
27 namespace { | 28 namespace { |
28 | 29 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 blink::WebNotificationPermissionAllowed; | 214 blink::WebNotificationPermissionAllowed; |
214 // TODO(mkwst): This is potentially doing the wrong thing with unique | 215 // TODO(mkwst): This is potentially doing the wrong thing with unique |
215 // origins. Perhaps also 'file:', 'blob:' and 'filesystem:'. See | 216 // origins. Perhaps also 'file:', 'blob:' and 'filesystem:'. See |
216 // https://crbug.com/490074 for detail. | 217 // https://crbug.com/490074 for detail. |
217 thread_safe_sender_->Send(new PlatformNotificationHostMsg_CheckPermission( | 218 thread_safe_sender_->Send(new PlatformNotificationHostMsg_CheckPermission( |
218 GURL(origin.toString()), &permission)); | 219 GURL(origin.toString()), &permission)); |
219 | 220 |
220 return permission; | 221 return permission; |
221 } | 222 } |
222 | 223 |
| 224 size_t NotificationManager::maxActions() { |
| 225 return kPlatformNotificationMaxActions; |
| 226 } |
| 227 |
223 bool NotificationManager::OnMessageReceived(const IPC::Message& message) { | 228 bool NotificationManager::OnMessageReceived(const IPC::Message& message) { |
224 bool handled = true; | 229 bool handled = true; |
225 IPC_BEGIN_MESSAGE_MAP(NotificationManager, message) | 230 IPC_BEGIN_MESSAGE_MAP(NotificationManager, message) |
226 IPC_MESSAGE_HANDLER(PlatformNotificationMsg_DidShow, OnDidShow); | 231 IPC_MESSAGE_HANDLER(PlatformNotificationMsg_DidShow, OnDidShow); |
227 IPC_MESSAGE_HANDLER(PlatformNotificationMsg_DidShowPersistent, | 232 IPC_MESSAGE_HANDLER(PlatformNotificationMsg_DidShowPersistent, |
228 OnDidShowPersistent) | 233 OnDidShowPersistent) |
229 IPC_MESSAGE_HANDLER(PlatformNotificationMsg_DidClose, OnDidClose); | 234 IPC_MESSAGE_HANDLER(PlatformNotificationMsg_DidClose, OnDidClose); |
230 IPC_MESSAGE_HANDLER(PlatformNotificationMsg_DidClick, OnDidClick); | 235 IPC_MESSAGE_HANDLER(PlatformNotificationMsg_DidClick, OnDidClick); |
231 IPC_MESSAGE_HANDLER(PlatformNotificationMsg_DidGetNotifications, | 236 IPC_MESSAGE_HANDLER(PlatformNotificationMsg_DidGetNotifications, |
232 OnDidGetNotifications) | 237 OnDidGetNotifications) |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 | 342 |
338 // TODO(mkwst): This is potentially doing the wrong thing with unique | 343 // TODO(mkwst): This is potentially doing the wrong thing with unique |
339 // origins. Perhaps also 'file:', 'blob:' and 'filesystem:'. See | 344 // origins. Perhaps also 'file:', 'blob:' and 'filesystem:'. See |
340 // https://crbug.com/490074 for detail. | 345 // https://crbug.com/490074 for detail. |
341 thread_safe_sender_->Send(new PlatformNotificationHostMsg_ShowPersistent( | 346 thread_safe_sender_->Send(new PlatformNotificationHostMsg_ShowPersistent( |
342 request_id, service_worker_registration_id, GURL(origin.toString()), icon, | 347 request_id, service_worker_registration_id, GURL(origin.toString()), icon, |
343 ToPlatformNotificationData(notification_data))); | 348 ToPlatformNotificationData(notification_data))); |
344 } | 349 } |
345 | 350 |
346 } // namespace content | 351 } // namespace content |
OLD | NEW |