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

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

Issue 8885022: Move URLPattern::ParseOption into a field. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more minor sprucing Created 9 years 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/url_pattern.h ('k') | chrome/common/extensions/url_pattern_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/url_pattern.cc
diff --git a/chrome/common/extensions/url_pattern.cc b/chrome/common/extensions/url_pattern.cc
index 91664f5dbebc8d52e5b614b76a1cbf7414048f22..8e831a42dbaf53c2395d8be69f8bea06af093750 100644
--- a/chrome/common/extensions/url_pattern.cc
+++ b/chrome/common/extensions/url_pattern.cc
@@ -98,26 +98,28 @@ bool IsValidPortForScheme(const std::string scheme, const std::string& port) {
} // namespace
URLPattern::URLPattern()
- : valid_schemes_(SCHEME_NONE),
+ : parse_option_(ERROR_ON_PORTS),
+ valid_schemes_(SCHEME_NONE),
match_all_urls_(false),
match_subdomains_(false),
port_("*") {}
-URLPattern::URLPattern(int valid_schemes)
- : valid_schemes_(valid_schemes),
+URLPattern::URLPattern(URLPattern::ParseOption parse_option, int valid_schemes)
+ : parse_option_(parse_option),
+ valid_schemes_(valid_schemes),
match_all_urls_(false),
match_subdomains_(false),
port_("*") {}
URLPattern::URLPattern(int valid_schemes, const std::string& pattern)
- : valid_schemes_(valid_schemes),
+ // Strict error checking is used, because this constructor is only
+ // appropriate when we know |pattern| is valid.
+ : parse_option_(ERROR_ON_PORTS),
+ valid_schemes_(valid_schemes),
match_all_urls_(false),
match_subdomains_(false),
port_("*") {
-
- // Strict error checking is used, because this constructor is only
- // appropriate when we know |pattern| is valid.
- if (PARSE_SUCCESS != Parse(pattern, ERROR_ON_PORTS))
+ if (PARSE_SUCCESS != Parse(pattern))
NOTREACHED() << "URLPattern is invalid: " << pattern;
}
@@ -132,8 +134,7 @@ bool URLPattern::operator==(const URLPattern& other) const {
return GetAsString() == other.GetAsString();
}
-URLPattern::ParseResult URLPattern::Parse(const std::string& pattern,
- ParseOption strictness) {
+URLPattern::ParseResult URLPattern::Parse(const std::string& pattern) {
spec_.clear();
// Special case pattern to match every valid URL.
@@ -215,7 +216,7 @@ URLPattern::ParseResult URLPattern::Parse(const std::string& pattern,
size_t port_pos = host_.find(':');
if (port_pos != std::string::npos) {
- switch (strictness) {
+ switch (parse_option_) {
case USE_PORTS: {
if (!SetPort(host_.substr(port_pos + 1)))
return PARSE_ERROR_INVALID_PORT;
@@ -245,6 +246,11 @@ void URLPattern::SetValidSchemes(int valid_schemes) {
valid_schemes_ = valid_schemes;
}
+void URLPattern::SetParseOption(URLPattern::ParseOption parse_option) {
+ spec_.clear();
+ parse_option_ = parse_option;
+}
+
void URLPattern::SetHost(const std::string& host) {
spec_.clear();
host_ = host;
« no previous file with comments | « chrome/common/extensions/url_pattern.h ('k') | chrome/common/extensions/url_pattern_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698