| 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());
|
|
|