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

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: fixed comments, switched to use BrowserContext, passing PermissionStatus in callback 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..1b1b3d4af3cb49aba7a518ef4b4d5d46e5b2fc31 100644
--- a/content/browser/permissions/permission_service_impl.cc
+++ b/content/browser/permissions/permission_service_impl.cc
@@ -7,6 +7,7 @@
#include "content/browser/geolocation/geolocation_provider_impl.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/render_process_host.h"
+#include "content/public/browser/web_contents.h"
namespace content {
@@ -114,7 +115,27 @@ void PermissionServiceImpl::HasPermission(
PermissionName permission,
const mojo::String& origin,
const mojo::Callback<void(PermissionStatus)>& callback) {
- NOTIMPLEMENTED();
+ DCHECK(context_->GetBrowserContext());
+
+ // If there is no web_contents() we use |origin| as the embedding_origin.
+ GURL embedding_origin = context_->web_contents()
+ ? context_->web_contents()->GetLastCommittedURL().GetOrigin()
+ : GURL(origin);
mlamouri (slow - plz ping) 2014/11/24 19:06:01 I think it would be better to have a PermissionSer
timvolodine 2014/11/27 17:53:42 done. but we still need the |origin| so cannot mov
+
+ GetContentClient()->browser()->HasPermission(
+ PermissionNameToPermissionType(permission),
+ context_->GetBrowserContext(),
+ GURL(origin),
+ embedding_origin,
+ base::Bind(&PermissionServiceImpl::OnHasPermissionResponse,
+ weak_factory_.GetWeakPtr(),
+ callback));
+}
+
+void PermissionServiceImpl::OnHasPermissionResponse(
+ const mojo::Callback<void(PermissionStatus)>& callback,
+ PermissionStatus content_setting) {
+ callback.Run(content_setting);
mlamouri (slow - plz ping) 2014/11/24 19:06:01 nit: s/content_setting/permission_status/
timvolodine 2014/11/27 17:53:42 Done.
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698