diff options
author | jstritar@chromium.org <jstritar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-12 20:25:22 +0000 |
---|---|---|
committer | jstritar@chromium.org <jstritar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-12 20:25:22 +0000 |
commit | b791effd60d54492f0e7cacf4c10d286fcd76ffe (patch) | |
tree | d14aa43185a3f2c04951e1fd68c49bdf60e5ecd0 /chrome/common/extensions/url_pattern.cc | |
parent | f760afdeb4ce5e734c605719be2e66de048c5555 (diff) | |
download | chromium_src-b791effd60d54492f0e7cacf4c10d286fcd76ffe.zip chromium_src-b791effd60d54492f0e7cacf4c10d286fcd76ffe.tar.gz chromium_src-b791effd60d54492f0e7cacf4c10d286fcd76ffe.tar.bz2 |
Revert 92219 - Update URLPatternSet to contain a std::set instead of std::vector.
This updates URLPatternSet to contain a std::set instead of a std::vector, making it easier to implement the set operations in ExtensionPermissionSet.
BUG=84507
TEST=unit_tests
Review URL: http://codereview.chromium.org/7347011
TBR=jstritar@chromium.org
Review URL: http://codereview.chromium.org/7346019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92224 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions/url_pattern.cc')
-rw-r--r-- | chrome/common/extensions/url_pattern.cc | 50 |
1 files changed, 5 insertions, 45 deletions
diff --git a/chrome/common/extensions/url_pattern.cc b/chrome/common/extensions/url_pattern.cc index 6731ab8..af0fd0a 100644 --- a/chrome/common/extensions/url_pattern.cc +++ b/chrome/common/extensions/url_pattern.cc @@ -124,18 +124,8 @@ URLPattern::URLPattern(int valid_schemes, const std::string& pattern) URLPattern::~URLPattern() { } -bool URLPattern::operator<(const URLPattern& other) const { - return GetAsString() < other.GetAsString(); -} - -bool URLPattern::operator==(const URLPattern& other) const { - return GetAsString() == other.GetAsString(); -} - URLPattern::ParseResult URLPattern::Parse(const std::string& pattern, ParseOption strictness) { - spec_.clear(); - // Special case pattern to match every valid URL. if (pattern == kAllUrlsPattern) { match_all_urls_ = true; @@ -244,28 +234,7 @@ URLPattern::ParseResult URLPattern::Parse(const std::string& pattern, return PARSE_SUCCESS; } -void URLPattern::SetValidSchemes(int valid_schemes) { - spec_.clear(); - valid_schemes_ = valid_schemes; -} - -void URLPattern::SetHost(const std::string& host) { - spec_.clear(); - host_ = host; -} - -void URLPattern::SetMatchAllURLs(bool val) { - spec_.clear(); - match_all_urls_ = val; -} - -void URLPattern::SetMatchSubdomains(bool val) { - spec_.clear(); - match_subdomains_ = val; -} - bool URLPattern::SetScheme(const std::string& scheme) { - spec_.clear(); scheme_ = scheme; if (scheme_ == "*") { valid_schemes_ &= (SCHEME_HTTP | SCHEME_HTTPS); @@ -288,7 +257,6 @@ bool URLPattern::IsValidScheme(const std::string& scheme) const { } void URLPattern::SetPath(const std::string& path) { - spec_.clear(); path_ = path; path_escaped_ = path_; ReplaceSubstringsAfterOffset(&path_escaped_, 0, "\\", "\\\\"); @@ -296,7 +264,6 @@ void URLPattern::SetPath(const std::string& path) { } bool URLPattern::SetPort(const std::string& port) { - spec_.clear(); if (IsValidPortForScheme(scheme_, port)) { port_ = port; return true; @@ -384,15 +351,9 @@ bool URLPattern::MatchesPort(int port) const { return port_ == "*" || port_ == base::IntToString(port); } - -const std::string& URLPattern::GetAsString() const { - if (!spec_.empty()) - return spec_; - - if (match_all_urls_) { - spec_ = kAllUrlsPattern; - return spec_; - } +std::string URLPattern::GetAsString() const { + if (match_all_urls_) + return kAllUrlsPattern; bool standard_scheme = IsStandardScheme(scheme_); @@ -418,8 +379,7 @@ const std::string& URLPattern::GetAsString() const { if (!path_.empty()) spec += path_; - spec_ = spec; - return spec_; + return spec; } bool URLPattern::OverlapsWith(const URLPattern& other) const { @@ -485,7 +445,7 @@ std::vector<URLPattern> URLPattern::ConvertToExplicitSchemes() const { i != explicit_schemes.end(); ++i) { URLPattern temp = *this; temp.SetScheme(*i); - temp.SetMatchAllURLs(false); + temp.set_match_all_urls(false); result.push_back(temp); } |