Chromium Code Reviews| Index: content/browser/permissions/permission_service_impl.cc |
| diff --git a/content/browser/permissions/permission_service_impl.cc b/content/browser/permissions/permission_service_impl.cc |
| index a5f66bf2f54790a6b89d835636d2cffe7a5eb759..37184ecddc8b8a204beafbcf70083b4b3bc40f7a 100644 |
| --- a/content/browser/permissions/permission_service_impl.cc |
| +++ b/content/browser/permissions/permission_service_impl.cc |
| @@ -57,7 +57,9 @@ void PermissionServiceImpl::RequestPermission( |
| if (!context_->web_contents()) { |
| // There is no way to show a UI so the call will simply return the current |
| // permission. |
| - HasPermission(permission, origin, callback); |
| + // Cannot use HasPermission() because it also needs context_->web_contents() |
| + // to obtain the profile. |
|
qsr
2014/11/24 11:51:11
The previous comment is wrong. Could you remove it
mlamouri (slow - plz ping)
2014/11/24 16:01:19
We must implement HasPermission() to work in a non
timvolodine
2014/11/24 18:54:22
Done.
timvolodine
2014/11/24 18:54:22
Done.
permission_context has an additional constru
|
| + callback.Run(PERMISSION_STATUS_ASK); |
| return; |
| } |
| @@ -114,7 +116,21 @@ void PermissionServiceImpl::HasPermission( |
| PermissionName permission, |
| const mojo::String& origin, |
| const mojo::Callback<void(PermissionStatus)>& callback) { |
| - NOTIMPLEMENTED(); |
| + DCHECK(context_->web_contents()); |
| + |
| + GetContentClient()->browser()->HasPermission( |
| + PermissionNameToPermissionType(permission), |
| + context_->web_contents(), |
| + GURL(origin), |
| + base::Bind(&PermissionServiceImpl::OnHasPermissionResponse, |
| + weak_factory_.GetWeakPtr(), |
| + callback)); |
| +} |
| + |
| +void PermissionServiceImpl::OnHasPermissionResponse( |
| + const mojo::Callback<void(PermissionStatus)>& callback, |
| + bool allowed) { |
| + callback.Run(allowed ? PERMISSION_STATUS_GRANTED : PERMISSION_STATUS_ASK); |
| } |
| } // namespace content |