| Index: chrome/common/extensions/user_script.cc
|
| diff --git a/chrome/common/extensions/user_script.cc b/chrome/common/extensions/user_script.cc
|
| index a73b65b0641c04b510894be3a0b5877f53fd5c54..1dd9f27511c75db95b578cffdec5cc2b2959b522 100644
|
| --- a/chrome/common/extensions/user_script.cc
|
| +++ b/chrome/common/extensions/user_script.cc
|
| @@ -1,4 +1,4 @@
|
| -// Copyright (c) 2010 The Chromium Authors. All rights reserved.
|
| +// Copyright (c) 2011 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.
|
|
|
| @@ -38,8 +38,7 @@ const char UserScript::kFileExtension[] = ".user.js";
|
|
|
| // static
|
| const int UserScript::kValidUserScriptSchemes =
|
| - URLPattern::SCHEME_HTTP | URLPattern::SCHEME_HTTPS |
|
| - URLPattern::SCHEME_FILE | URLPattern::SCHEME_FTP;
|
| + URLPattern::SCHEME_HTTP | URLPattern::SCHEME_HTTPS | URLPattern::SCHEME_FTP;
|
|
|
| bool UserScript::IsURLUserScript(const GURL& url,
|
| const std::string& mime_type) {
|
| @@ -61,8 +60,7 @@ UserScript::File::~File() {}
|
|
|
| UserScript::UserScript()
|
| : run_location_(DOCUMENT_IDLE), emulate_greasemonkey_(false),
|
| - match_all_frames_(false), incognito_enabled_(false),
|
| - allow_file_access_(false) {
|
| + match_all_frames_(false), incognito_enabled_(false) {
|
| }
|
|
|
| UserScript::~UserScript() {
|
| @@ -72,25 +70,24 @@ void UserScript::add_url_pattern(const URLPattern& pattern) {
|
| url_patterns_.push_back(pattern);
|
| }
|
|
|
| -void UserScript::clear_url_patterns() { url_patterns_.clear(); }
|
| -
|
| bool UserScript::MatchesUrl(const GURL& url) const {
|
| - if (!url_patterns_.empty()) {
|
| - if (!UrlMatchesPatterns(&url_patterns_, url))
|
| - return false;
|
| - }
|
| + // If both URL patterns and globs are provided, require that we match both
|
| + // sets.
|
| + if ((!url_patterns_.empty() && !globs_.empty()) &&
|
| + (!UrlMatchesPatterns(&url_patterns_, url) ||
|
| + !UrlMatchesGlobs(&globs_, url)))
|
| + return false;
|
|
|
| - if (!globs_.empty()) {
|
| - if (!UrlMatchesGlobs(&globs_, url))
|
| - return false;
|
| - }
|
| + if (UrlMatchesPatterns(&url_patterns_, url))
|
| + return true;
|
|
|
| - if (!exclude_globs_.empty()) {
|
| - if (UrlMatchesGlobs(&exclude_globs_, url))
|
| - return false;
|
| - }
|
| + if (UrlMatchesGlobs(&exclude_globs_, url))
|
| + return false;
|
| +
|
| + if (UrlMatchesGlobs(&globs_, url))
|
| + return true;
|
|
|
| - return true;
|
| + return false;
|
| }
|
|
|
| void UserScript::File::Pickle(::Pickle* pickle) const {
|
| @@ -113,7 +110,6 @@ void UserScript::Pickle(::Pickle* pickle) const {
|
| pickle->WriteBool(emulate_greasemonkey());
|
| pickle->WriteBool(match_all_frames());
|
| pickle->WriteBool(is_incognito_enabled());
|
| - pickle->WriteBool(allow_file_access());
|
|
|
| // Write globs.
|
| std::vector<std::string>::const_iterator glob;
|
| @@ -160,7 +156,6 @@ void UserScript::Unpickle(const ::Pickle& pickle, void** iter) {
|
| CHECK(pickle.ReadBool(iter, &emulate_greasemonkey_));
|
| CHECK(pickle.ReadBool(iter, &match_all_frames_));
|
| CHECK(pickle.ReadBool(iter, &incognito_enabled_));
|
| - CHECK(pickle.ReadBool(iter, &allow_file_access_));
|
|
|
| // Read globs.
|
| size_t num_globs = 0;
|
|
|