diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-15 04:30:12 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-15 04:30:12 +0000 |
commit | 919ddc8c4928d69c3db02c68c0dbf573ebc54899 (patch) | |
tree | 74d8d509008427576fddfcf01282b897df23d261 /chrome/common | |
parent | 6f317586c5b00ab2196d9f3dbff571bad34b8352 (diff) | |
download | chromium_src-919ddc8c4928d69c3db02c68c0dbf573ebc54899.zip chromium_src-919ddc8c4928d69c3db02c68c0dbf573ebc54899.tar.gz chromium_src-919ddc8c4928d69c3db02c68c0dbf573ebc54899.tar.bz2 |
Various minor fixes:
* --load-extension no longer requires --enable-extensions
* No longer support chrome:// URLs for user scripts
* Remove old unused Greasemonkey test
* Enable Greasemonkey API emulation in linux/mac
BUG=16720,16007,4476
TEST=Added several unit tests
Original review:
http://codereview.chromium.org/149619
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20719 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r-- | chrome/common/extensions/url_pattern.cc | 4 | ||||
-rw-r--r-- | chrome/common/extensions/url_pattern.h | 9 | ||||
-rw-r--r-- | chrome/common/extensions/url_pattern_unittest.cc | 14 |
3 files changed, 9 insertions, 18 deletions
diff --git a/chrome/common/extensions/url_pattern.cc b/chrome/common/extensions/url_pattern.cc index 2fc6f56..7a4f853 100644 --- a/chrome/common/extensions/url_pattern.cc +++ b/chrome/common/extensions/url_pattern.cc @@ -15,12 +15,12 @@ static const char* kValidSchemes[] = { chrome::kHttpsScheme, chrome::kFileScheme, chrome::kFtpScheme, - chrome::kChromeUIScheme, }; static const char kPathSeparator[] = "/"; -static bool IsValidScheme(const std::string& scheme) { +// static +bool URLPattern::IsValidScheme(const std::string& scheme) { for (size_t i = 0; i < arraysize(kValidSchemes); ++i) { if (scheme == kValidSchemes[i]) return true; diff --git a/chrome/common/extensions/url_pattern.h b/chrome/common/extensions/url_pattern.h index 08d76b0..f69cd7a 100644 --- a/chrome/common/extensions/url_pattern.h +++ b/chrome/common/extensions/url_pattern.h @@ -23,7 +23,6 @@ // - http://*/* // - http://*/foo* // - https://*.google.com/foo*bar -// - chrome://foo/bar // - file://monkey* // - http://127.0.0.1/* // @@ -33,6 +32,7 @@ // - http://foo.*.bar/baz -- * must be first component // - http:/bar -- scheme separator not found // - foo://* -- invalid scheme +// - chrome:// -- we don't support chrome internal URLs // // Design rationale: // * We need to be able to tell users what 'sites' a given URLPattern will @@ -42,8 +42,7 @@ // patterns to URLPatterns as possible. Greasemonkey @include patterns are // simple globs, so this won't be perfect. // * Although we would like to support any scheme, it isn't clear what to tell -// users about URLPatterns that affect data or javascript URLs, and saying -// something useful about chrome-extension URLs is more work, so those are +// users about URLPatterns that affect data or javascript URLs, so those are // left out for now. // // From a 2008-ish crawl of userscripts.org, the following patterns were found @@ -70,6 +69,10 @@ // than the original glob, which is probably better than nothing. class URLPattern { public: + // Returns true if the specified scheme can be used in URL patterns, and false + // otherwise. + static bool IsValidScheme(const std::string& scheme); + URLPattern() : match_subdomains_(false) {} // Initializes this instance by parsing the provided string. On failure, the diff --git a/chrome/common/extensions/url_pattern_unittest.cc b/chrome/common/extensions/url_pattern_unittest.cc index 3db623f..f3fec47 100644 --- a/chrome/common/extensions/url_pattern_unittest.cc +++ b/chrome/common/extensions/url_pattern_unittest.cc @@ -16,6 +16,7 @@ TEST(URLPatternTest, ParseInvalid) { "http://foo.*.bar/baz", // must be first component "http:/bar", // scheme separator not found "foo://*", // invalid scheme + "chrome://*/*", // we don't support internal chrome URLs }; for (size_t i = 0; i < arraysize(kInvalidPatterns); ++i) { @@ -67,19 +68,6 @@ TEST(URLPatternTest, Match3) { EXPECT_FALSE(pattern.MatchesUrl(GURL("http://yahoo.com/foobar"))); } -// odd schemes and normalization -TEST(URLPatternTest, Match4) { - URLPattern pattern; - EXPECT_TRUE(pattern.Parse("chrome://thinger/*")); - EXPECT_EQ("chrome", pattern.scheme()); - EXPECT_EQ("thinger", pattern.host()); - EXPECT_FALSE(pattern.match_subdomains()); - EXPECT_EQ("/*", pattern.path()); - EXPECT_TRUE(pattern.MatchesUrl(GURL("chrome://thinger/foobar"))); - EXPECT_TRUE(pattern.MatchesUrl(GURL("CHROME://thinger/"))); - EXPECT_FALSE(pattern.MatchesUrl(GURL("http://thinger/"))); -} - // glob escaping TEST(URLPatternTest, Match5) { URLPattern pattern; |