Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Unified Diff: content/browser/permissions/permission_service_impl.cc

Issue 750633003: Implement HasPermission() method in PermissionService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698