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

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

Issue 750633003: Implement HasPermission() method in PermissionService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add dependencies to content_app, content_child and content_ppapi_plugin Created 6 years 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_context.cc
diff --git a/content/browser/permissions/permission_service_context.cc b/content/browser/permissions/permission_service_context.cc
index 2c7e91b968458265036ccae92049e97481b99138..50c73a92e382a46af2805b9bab29a6c4238c878c 100644
--- a/content/browser/permissions/permission_service_context.cc
+++ b/content/browser/permissions/permission_service_context.cc
@@ -7,6 +7,7 @@
#include "content/browser/permissions/permission_service_impl.h"
#include "content/public/browser/navigation_details.h"
#include "content/public/browser/render_frame_host.h"
+#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
namespace content {
@@ -14,7 +15,15 @@ namespace content {
PermissionServiceContext::PermissionServiceContext(
RenderFrameHost* render_frame_host)
: WebContentsObserver(WebContents::FromRenderFrameHost(render_frame_host)),
- render_frame_host_(render_frame_host) {
+ render_frame_host_(render_frame_host),
+ render_process_host_(nullptr) {
+}
+
+PermissionServiceContext::PermissionServiceContext(
+ RenderProcessHost* render_process_host)
+ : WebContentsObserver(nullptr),
+ render_frame_host_(nullptr),
+ render_process_host_(render_process_host) {
}
PermissionServiceContext::~PermissionServiceContext() {
@@ -60,4 +69,17 @@ void PermissionServiceContext::CancelPendingRequests(
service->CancelPendingRequests();
}
+BrowserContext* PermissionServiceContext::GetBrowserContext() const {
+ if (!web_contents()) {
+ DCHECK(render_process_host_);
+ return render_process_host_->GetBrowserContext();
+ }
+ return web_contents()->GetBrowserContext();
+}
+
+GURL PermissionServiceContext::GetEmbeddingOrigin() const {
+ return web_contents() ? web_contents()->GetLastCommittedURL().GetOrigin()
+ : GURL();
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698