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" |
| 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/common/notification_constants.h" | 17 #include "content/common/notification_constants.h" |
| 18 #include "content/public/common/notification_resources.h" | 18 #include "content/public/common/notification_resources.h" |
| 19 #include "content/public/common/platform_notification_data.h" | 19 #include "content/public/common/platform_notification_data.h" |
| 20 #include "third_party/WebKit/public/platform/URLConversion.h" | 20 #include "third_party/WebKit/public/platform/URLConversion.h" |
| 21 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 21 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
| 22 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati onDelegate.h" | 22 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati onDelegate.h" |
| 23 | 23 |
| 24 using blink::WebNotificationPermission; | |
| 25 | |
| 26 namespace content { | 24 namespace content { |
| 27 namespace { | 25 namespace { |
| 28 | 26 |
| 29 int CurrentWorkerId() { | 27 int CurrentWorkerId() { |
| 30 return WorkerThread::GetCurrentId(); | 28 return WorkerThread::GetCurrentId(); |
| 31 } | 29 } |
| 32 | 30 |
| 33 NotificationResources ToNotificationResources( | 31 NotificationResources ToNotificationResources( |
| 34 std::unique_ptr<blink::WebNotificationResources> web_resources) { | 32 std::unique_ptr<blink::WebNotificationResources> web_resources) { |
| 35 NotificationResources resources; | 33 NotificationResources resources; |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 blink::WebNotificationDelegate* delegate) { | 203 blink::WebNotificationDelegate* delegate) { |
| 206 for (auto& iter : active_page_notifications_) { | 204 for (auto& iter : active_page_notifications_) { |
| 207 if (iter.second != delegate) | 205 if (iter.second != delegate) |
| 208 continue; | 206 continue; |
| 209 | 207 |
| 210 active_page_notifications_.erase(iter.first); | 208 active_page_notifications_.erase(iter.first); |
| 211 return; | 209 return; |
| 212 } | 210 } |
| 213 } | 211 } |
| 214 | 212 |
| 215 WebNotificationPermission NotificationManager::checkPermission( | 213 blink::mojom::PermissionStatus NotificationManager::checkPermission( |
| 216 const blink::WebSecurityOrigin& origin) { | 214 const blink::WebSecurityOrigin& origin) { |
| 217 WebNotificationPermission permission = | 215 blink::mojom::PermissionStatus permission_status = |
| 218 blink::WebNotificationPermissionAllowed; | 216 blink::mojom::PermissionStatus::DENIED; |
|
Peter Beverloo
2016/04/19 14:54:02
This shouldn't make any difference since the sync
| |
| 217 | |
| 219 // TODO(mkwst): This is potentially doing the wrong thing with unique | 218 // TODO(mkwst): This is potentially doing the wrong thing with unique |
| 220 // origins. Perhaps also 'file:', 'blob:' and 'filesystem:'. See | 219 // origins. Perhaps also 'file:', 'blob:' and 'filesystem:'. See |
| 221 // https://crbug.com/490074 for detail. | 220 // https://crbug.com/490074 for detail. |
| 222 thread_safe_sender_->Send(new PlatformNotificationHostMsg_CheckPermission( | 221 thread_safe_sender_->Send(new PlatformNotificationHostMsg_CheckPermission( |
| 223 blink::WebStringToGURL(origin.toString()), &permission)); | 222 blink::WebStringToGURL(origin.toString()), &permission_status)); |
| 224 | 223 |
| 225 return permission; | 224 return permission_status; |
| 226 } | 225 } |
| 227 | 226 |
| 228 size_t NotificationManager::maxActions() { | 227 size_t NotificationManager::maxActions() { |
| 229 return kPlatformNotificationMaxActions; | 228 return kPlatformNotificationMaxActions; |
| 230 } | 229 } |
| 231 | 230 |
| 232 bool NotificationManager::OnMessageReceived(const IPC::Message& message) { | 231 bool NotificationManager::OnMessageReceived(const IPC::Message& message) { |
| 233 bool handled = true; | 232 bool handled = true; |
| 234 IPC_BEGIN_MESSAGE_MAP(NotificationManager, message) | 233 IPC_BEGIN_MESSAGE_MAP(NotificationManager, message) |
| 235 IPC_MESSAGE_HANDLER(PlatformNotificationMsg_DidShow, OnDidShow); | 234 IPC_MESSAGE_HANDLER(PlatformNotificationMsg_DidShow, OnDidShow); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 306 | 305 |
| 307 notifications[i] = web_notification_info; | 306 notifications[i] = web_notification_info; |
| 308 } | 307 } |
| 309 | 308 |
| 310 callbacks->onSuccess(notifications); | 309 callbacks->onSuccess(notifications); |
| 311 | 310 |
| 312 pending_get_notification_requests_.Remove(request_id); | 311 pending_get_notification_requests_.Remove(request_id); |
| 313 } | 312 } |
| 314 | 313 |
| 315 } // namespace content | 314 } // namespace content |
| OLD | NEW |