| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 user_gesture, // TODO(mlamouri): should be removed (crbug.com/423770) | 78 user_gesture, // TODO(mlamouri): should be removed (crbug.com/423770) |
| 79 base::Bind(&PermissionServiceImpl::OnRequestPermissionResponse, | 79 base::Bind(&PermissionServiceImpl::OnRequestPermissionResponse, |
| 80 weak_factory_.GetWeakPtr(), | 80 weak_factory_.GetWeakPtr(), |
| 81 callback, | 81 callback, |
| 82 request_id)); | 82 request_id)); |
| 83 } | 83 } |
| 84 | 84 |
| 85 void PermissionServiceImpl::OnRequestPermissionResponse( | 85 void PermissionServiceImpl::OnRequestPermissionResponse( |
| 86 const mojo::Callback<void(PermissionStatus)>& callback, | 86 const mojo::Callback<void(PermissionStatus)>& callback, |
| 87 int request_id, | 87 int request_id, |
| 88 bool allowed) { | 88 PermissionStatus status) { |
| 89 pending_requests_.Remove(request_id); | 89 pending_requests_.Remove(request_id); |
| 90 | 90 |
| 91 // TODO(mlamouri): for now, we only get a boolean back, but we would ideally | 91 // TODO(mlamouri): this is not yet returning a tri-state value because it will |
| 92 // need a ContentSetting, see http://crbug.com/432978 | 92 // require some further changes that will be dealt with in |
| 93 callback.Run(allowed ? PERMISSION_STATUS_GRANTED : PERMISSION_STATUS_ASK); | 93 // https://crrev.com/794203004/ |
| 94 status = status == PERMISSION_STATUS_DENIED ? PERMISSION_STATUS_ASK : status; |
| 95 callback.Run(status); |
| 94 } | 96 } |
| 95 | 97 |
| 96 void PermissionServiceImpl::CancelPendingRequests() { | 98 void PermissionServiceImpl::CancelPendingRequests() { |
| 97 DCHECK(context_->web_contents()); | 99 DCHECK(context_->web_contents()); |
| 98 | 100 |
| 99 for (RequestsMap::Iterator<PendingRequest> it(&pending_requests_); | 101 for (RequestsMap::Iterator<PendingRequest> it(&pending_requests_); |
| 100 !it.IsAtEnd(); it.Advance()) { | 102 !it.IsAtEnd(); it.Advance()) { |
| 101 GetContentClient()->browser()->CancelPermissionRequest( | 103 GetContentClient()->browser()->CancelPermissionRequest( |
| 102 it.GetCurrentValue()->permission, | 104 it.GetCurrentValue()->permission, |
| 103 context_->web_contents(), | 105 context_->web_contents(), |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 void PermissionServiceImpl::ResetPermissionStatus(PermissionType type, | 152 void PermissionServiceImpl::ResetPermissionStatus(PermissionType type, |
| 151 GURL origin) { | 153 GURL origin) { |
| 152 // If the embedding_origin is empty we'll use |origin| instead. | 154 // If the embedding_origin is empty we'll use |origin| instead. |
| 153 GURL embedding_origin = context_->GetEmbeddingOrigin(); | 155 GURL embedding_origin = context_->GetEmbeddingOrigin(); |
| 154 GetContentClient()->browser()->ResetPermission( | 156 GetContentClient()->browser()->ResetPermission( |
| 155 type, context_->GetBrowserContext(), origin, | 157 type, context_->GetBrowserContext(), origin, |
| 156 embedding_origin.is_empty() ? origin : embedding_origin); | 158 embedding_origin.is_empty() ? origin : embedding_origin); |
| 157 } | 159 } |
| 158 | 160 |
| 159 } // namespace content | 161 } // namespace content |
| OLD | NEW |