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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
115 // If the embedding_origin is empty we'll use |origin| instead. | 115 // If the embedding_origin is empty we'll use |origin| instead. |
116 GURL embedding_origin = context_->GetEmbeddingOrigin(); | 116 GURL embedding_origin = context_->GetEmbeddingOrigin(); |
117 | 117 |
118 callback.Run(GetContentClient()->browser()->GetPermissionStatus( | 118 callback.Run(GetContentClient()->browser()->GetPermissionStatus( |
119 PermissionNameToPermissionType(permission), | 119 PermissionNameToPermissionType(permission), |
120 context_->GetBrowserContext(), | 120 context_->GetBrowserContext(), |
121 GURL(origin), | 121 GURL(origin), |
122 embedding_origin.is_empty() ? GURL(origin) : embedding_origin)); | 122 embedding_origin.is_empty() ? GURL(origin) : embedding_origin)); |
123 } | 123 } |
124 | 124 |
125 void PermissionServiceImpl::RevokePermission( | |
126 PermissionName permission, | |
127 const mojo::String& origin, | |
128 const mojo::Callback<void(PermissionStatus)>& callback) { | |
129 GURL origin_url(origin); | |
130 PermissionType permission_type = PermissionNameToPermissionType(permission); | |
131 PermissionStatus status = GetPermissionStatus(permission_type, origin_url); | |
132 | |
133 if (status != PERMISSION_STATUS_GRANTED) | |
134 callback.Run(status); | |
135 | |
136 ResetPermissionStatus(permission_type, origin_url); | |
137 | |
138 callback.Run(GetPermissionStatus(permission_type, origin_url)); | |
139 } | |
140 | |
141 PermissionStatus PermissionServiceImpl::GetPermissionStatus(PermissionType type, | |
142 GURL origin) { | |
mlamouri (slow - plz ping)
2015/01/26 10:38:17
Should you re-use that method in ::HasPermission()
timvolodine
2015/01/30 14:07:47
Yes. done.
| |
143 // If the embedding_origin is empty we'll use |origin| instead. | |
144 GURL embedding_origin = context_->GetEmbeddingOrigin(); | |
145 return GetContentClient()->browser()->GetPermissionStatus( | |
146 type, context_->GetBrowserContext(), origin, | |
147 embedding_origin.is_empty() ? origin : embedding_origin); | |
148 } | |
149 | |
150 void PermissionServiceImpl::ResetPermissionStatus(PermissionType type, | |
151 GURL origin) { | |
152 // If the embedding_origin is empty we'll use |origin| instead. | |
153 GURL embedding_origin = context_->GetEmbeddingOrigin(); | |
154 GetContentClient()->browser()->ResetPermission( | |
155 type, context_->GetBrowserContext(), origin, | |
156 embedding_origin.is_empty() ? origin : embedding_origin); | |
157 } | |
158 | |
125 } // namespace content | 159 } // namespace content |
OLD | NEW |