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

Unified Diff: chrome/common/extensions/extension.cc

Issue 6242010: Refactor away most of ExtensionRendererInfo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 9 years, 11 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 | « chrome/common/extensions/extension.h ('k') | chrome/common/render_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/extension.cc
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index 2ce4d5939ef96f4a02fafc9493c8cc568627c22e..a73210f907ffef202e7940eaca5a3494f3e0c9c5 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -2250,21 +2250,16 @@ bool Extension::HasMultipleUISurfaces() const {
return num_surfaces > 1;
}
-// static
-bool Extension::CanExecuteScriptOnPage(
- const GURL& page_url, bool can_execute_script_everywhere,
- const std::vector<URLPattern>* host_permissions,
- UserScript* script,
- std::string* error) {
- DCHECK(!(host_permissions && script)) << "Shouldn't specify both";
-
+bool Extension::CanExecuteScriptOnPage(const GURL& page_url,
+ UserScript* script,
+ std::string* error) const {
// The gallery is special-cased as a restricted URL for scripting to prevent
// access to special JS bindings we expose to the gallery (and avoid things
// like extensions removing the "report abuse" link).
// TODO(erikkay): This seems like the wrong test. Shouldn't we we testing
// against the store app extent?
if ((page_url.host() == GURL(Extension::ChromeStoreLaunchURL()).host()) &&
- !can_execute_script_everywhere &&
+ !CanExecuteScriptEverywhere() &&
!CommandLine::ForCurrentProcess()->HasSwitch(
switches::kAllowScriptingGallery)) {
if (error)
@@ -2272,17 +2267,19 @@ bool Extension::CanExecuteScriptOnPage(
return false;
}
- if (host_permissions) {
- for (size_t i = 0; i < host_permissions->size(); ++i) {
- if ((*host_permissions)[i].MatchesUrl(page_url))
- return true;
- }
- }
+ // If a script is specified, use its matches.
if (script) {
if (script->MatchesUrl(page_url))
return true;
}
+ // Otherwise, see if this extension has permission to execute script
+ // programmatically on pages.
+ for (size_t i = 0; i < host_permissions_.size(); ++i) {
+ if (host_permissions_[i].MatchesUrl(page_url))
+ return true;
+ }
+
if (error) {
*error = ExtensionErrorUtils::FormatErrorMessage(errors::kCannotAccessPage,
page_url.spec());
« no previous file with comments | « chrome/common/extensions/extension.h ('k') | chrome/common/render_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698