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 "content/public/browser/content_browser_client.h" | 7 #include "content/public/browser/content_browser_client.h" |
8 | 8 |
9 namespace content { | 9 namespace content { |
10 | 10 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 107 |
108 pending_requests_.Clear(); | 108 pending_requests_.Clear(); |
109 } | 109 } |
110 | 110 |
111 void PermissionServiceImpl::HasPermission( | 111 void PermissionServiceImpl::HasPermission( |
112 PermissionName permission, | 112 PermissionName permission, |
113 const mojo::String& origin, | 113 const mojo::String& origin, |
114 const mojo::Callback<void(PermissionStatus)>& callback) { | 114 const mojo::Callback<void(PermissionStatus)>& callback) { |
115 DCHECK(context_->GetBrowserContext()); | 115 DCHECK(context_->GetBrowserContext()); |
116 | 116 |
| 117 callback.Run(GetPermissionStatus(PermissionNameToPermissionType(permission), |
| 118 GURL(origin))); |
| 119 } |
| 120 |
| 121 void PermissionServiceImpl::RevokePermission( |
| 122 PermissionName permission, |
| 123 const mojo::String& origin, |
| 124 const mojo::Callback<void(PermissionStatus)>& callback) { |
| 125 GURL origin_url(origin); |
| 126 PermissionType permission_type = PermissionNameToPermissionType(permission); |
| 127 PermissionStatus status = GetPermissionStatus(permission_type, origin_url); |
| 128 |
| 129 if (status != PERMISSION_STATUS_GRANTED) |
| 130 callback.Run(status); |
| 131 |
| 132 ResetPermissionStatus(permission_type, origin_url); |
| 133 |
| 134 callback.Run(GetPermissionStatus(permission_type, origin_url)); |
| 135 } |
| 136 |
| 137 PermissionStatus PermissionServiceImpl::GetPermissionStatus(PermissionType type, |
| 138 GURL origin) { |
117 // If the embedding_origin is empty we'll use |origin| instead. | 139 // If the embedding_origin is empty we'll use |origin| instead. |
118 GURL embedding_origin = context_->GetEmbeddingOrigin(); | 140 GURL embedding_origin = context_->GetEmbeddingOrigin(); |
| 141 return GetContentClient()->browser()->GetPermissionStatus( |
| 142 type, context_->GetBrowserContext(), origin, |
| 143 embedding_origin.is_empty() ? origin : embedding_origin); |
| 144 } |
119 | 145 |
120 callback.Run(GetContentClient()->browser()->GetPermissionStatus( | 146 void PermissionServiceImpl::ResetPermissionStatus(PermissionType type, |
121 PermissionNameToPermissionType(permission), | 147 GURL origin) { |
122 context_->GetBrowserContext(), | 148 // If the embedding_origin is empty we'll use |origin| instead. |
123 GURL(origin), | 149 GURL embedding_origin = context_->GetEmbeddingOrigin(); |
124 embedding_origin.is_empty() ? GURL(origin) : embedding_origin)); | 150 GetContentClient()->browser()->ResetPermission( |
| 151 type, context_->GetBrowserContext(), origin, |
| 152 embedding_origin.is_empty() ? origin : embedding_origin); |
125 } | 153 } |
126 | 154 |
127 } // namespace content | 155 } // namespace content |
OLD | NEW |