| 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/browser/permissions/permission_service_impl.h" | 5 #include "content/browser/permissions/permission_service_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "content/public/browser/browser_context.h" | 11 #include "content/public/browser/browser_context.h" |
| 12 #include "content/public/browser/permission_manager.h" | 12 #include "content/public/browser/permission_manager.h" |
| 13 #include "content/public/browser/permission_type.h" | 13 #include "content/public/browser/permission_type.h" |
| 14 | 14 |
| 15 using blink::mojom::PermissionName; | 15 using permission::mojom::PermissionName; |
| 16 using blink::mojom::PermissionStatus; | 16 using permission::mojom::PermissionStatus; |
| 17 | 17 |
| 18 namespace content { | 18 namespace content { |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 PermissionType PermissionNameToPermissionType(PermissionName name) { | 22 PermissionType PermissionNameToPermissionType(PermissionName name) { |
| 23 switch(name) { | 23 switch(name) { |
| 24 case PermissionName::GEOLOCATION: | 24 case PermissionName::GEOLOCATION: |
| 25 return PermissionType::GEOLOCATION; | 25 return PermissionType::GEOLOCATION; |
| 26 case PermissionName::NOTIFICATIONS: | 26 case PermissionName::NOTIFICATIONS: |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 callback(callback) { | 86 callback(callback) { |
| 87 } | 87 } |
| 88 | 88 |
| 89 PermissionServiceImpl::PendingSubscription::~PendingSubscription() { | 89 PermissionServiceImpl::PendingSubscription::~PendingSubscription() { |
| 90 if (!callback.is_null()) | 90 if (!callback.is_null()) |
| 91 callback.Run(PermissionStatus::ASK); | 91 callback.Run(PermissionStatus::ASK); |
| 92 } | 92 } |
| 93 | 93 |
| 94 PermissionServiceImpl::PermissionServiceImpl( | 94 PermissionServiceImpl::PermissionServiceImpl( |
| 95 PermissionServiceContext* context, | 95 PermissionServiceContext* context, |
| 96 mojo::InterfaceRequest<blink::mojom::PermissionService> request) | 96 mojo::InterfaceRequest<permission::mojom::PermissionService> request) |
| 97 : context_(context), | 97 : context_(context), |
| 98 binding_(this, std::move(request)), | 98 binding_(this, std::move(request)), |
| 99 weak_factory_(this) { | 99 weak_factory_(this) { |
| 100 binding_.set_connection_error_handler( | 100 binding_.set_connection_error_handler( |
| 101 base::Bind(&PermissionServiceImpl::OnConnectionError, | 101 base::Bind(&PermissionServiceImpl::OnConnectionError, |
| 102 base::Unretained(this))); | 102 base::Unretained(this))); |
| 103 } | 103 } |
| 104 | 104 |
| 105 PermissionServiceImpl::~PermissionServiceImpl() { | 105 PermissionServiceImpl::~PermissionServiceImpl() { |
| 106 DCHECK(pending_requests_.IsEmpty()); | 106 DCHECK(pending_requests_.IsEmpty()); |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 | 364 |
| 365 PermissionStatusCallback callback = subscription->callback; | 365 PermissionStatusCallback callback = subscription->callback; |
| 366 | 366 |
| 367 subscription->callback.reset(); | 367 subscription->callback.reset(); |
| 368 pending_subscriptions_.Remove(pending_subscription_id); | 368 pending_subscriptions_.Remove(pending_subscription_id); |
| 369 | 369 |
| 370 callback.Run(status); | 370 callback.Run(status); |
| 371 } | 371 } |
| 372 | 372 |
| 373 } // namespace content | 373 } // namespace content |
| OLD | NEW |