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

Unified Diff: extensions/renderer/extension_injection_host.cc

Issue 885493007: Refactoring: de-couple Extensions from "script injection System" [render side] : 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months 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
« no previous file with comments | « extensions/renderer/extension_injection_host.h ('k') | extensions/renderer/injection_host.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/extension_injection_host.cc
diff --git a/extensions/renderer/extension_injection_host.cc b/extensions/renderer/extension_injection_host.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a3783d94f20e0d4ebd83eb7f64be9f0b440cb6a1
--- /dev/null
+++ b/extensions/renderer/extension_injection_host.cc
@@ -0,0 +1,58 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "extensions/common/manifest_handlers/csp_info.h"
+#include "extensions/renderer/extension_injection_host.h"
+
+namespace extensions {
+
+ExtensionInjectionHost::ExtensionInjectionHost(
+ const scoped_refptr<const Extension>& extension)
+ : InjectionHost(HostID(HostID::EXTENSIONS, extension->id())),
+ extension_(extension) {
+}
+
+ExtensionInjectionHost::~ExtensionInjectionHost() {
+}
+
+const std::string& ExtensionInjectionHost::GetContentSecurityPolicy() const {
+ return CSPInfo::GetContentSecurityPolicy(extension_.get());
+}
+
+const GURL& ExtensionInjectionHost::url() const {
+ return extension_->url();
+}
+
+const std::string& ExtensionInjectionHost::name() const {
+ return extension_->name();
+}
+
+PermissionsData::AccessType ExtensionInjectionHost::CanExecuteOnFrame(
+ const GURL& document_url,
+ const GURL& top_frame_url,
+ int tab_id,
+ bool is_declarative) const {
+ // Declarative user scripts use "page access" (from "permissions" section in
+ // manifest) whereas non-declarative user scripts use custom
+ // "content script access" logic.
+ if (is_declarative) {
+ return extension_->permissions_data()->GetPageAccess(
+ extension_.get(),
+ document_url,
+ top_frame_url,
+ tab_id,
+ -1, // no process id
+ nullptr /* ignore error */);
+ } else {
+ return extension_->permissions_data()->GetContentScriptAccess(
+ extension_.get(),
+ document_url,
+ top_frame_url,
+ tab_id,
+ -1, // no process id
+ nullptr /* ignore error */);
+ }
+}
+
+} // namespace extensions
« no previous file with comments | « extensions/renderer/extension_injection_host.h ('k') | extensions/renderer/injection_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698