OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "extensions/common/url_pattern.h" | 5 #include "extensions/common/url_pattern.h" |
6 | 6 |
| 7 #include <ostream> |
| 8 |
7 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
8 #include "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
9 #include "base/strings/string_split.h" | 11 #include "base/strings/string_split.h" |
10 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
11 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
12 #include "content/public/common/url_constants.h" | 14 #include "content/public/common/url_constants.h" |
13 #include "extensions/common/constants.h" | 15 #include "extensions/common/constants.h" |
14 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 16 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
15 #include "url/gurl.h" | 17 #include "url/gurl.h" |
16 #include "url/url_util.h" | 18 #include "url/url_util.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 } | 154 } |
153 | 155 |
154 bool URLPattern::operator>(const URLPattern& other) const { | 156 bool URLPattern::operator>(const URLPattern& other) const { |
155 return GetAsString() > other.GetAsString(); | 157 return GetAsString() > other.GetAsString(); |
156 } | 158 } |
157 | 159 |
158 bool URLPattern::operator==(const URLPattern& other) const { | 160 bool URLPattern::operator==(const URLPattern& other) const { |
159 return GetAsString() == other.GetAsString(); | 161 return GetAsString() == other.GetAsString(); |
160 } | 162 } |
161 | 163 |
| 164 std::ostream& operator<<(std::ostream& out, const URLPattern& url_pattern) { |
| 165 return out << '"' << url_pattern.GetAsString() << '"'; |
| 166 } |
| 167 |
162 URLPattern::ParseResult URLPattern::Parse(const std::string& pattern) { | 168 URLPattern::ParseResult URLPattern::Parse(const std::string& pattern) { |
163 spec_.clear(); | 169 spec_.clear(); |
164 SetMatchAllURLs(false); | 170 SetMatchAllURLs(false); |
165 SetMatchSubdomains(false); | 171 SetMatchSubdomains(false); |
166 SetPort("*"); | 172 SetPort("*"); |
167 | 173 |
168 // Special case pattern to match every valid URL. | 174 // Special case pattern to match every valid URL. |
169 if (pattern == kAllUrlsPattern) { | 175 if (pattern == kAllUrlsPattern) { |
170 SetMatchAllURLs(true); | 176 SetMatchAllURLs(true); |
171 return PARSE_SUCCESS; | 177 return PARSE_SUCCESS; |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 } | 593 } |
588 | 594 |
589 return result; | 595 return result; |
590 } | 596 } |
591 | 597 |
592 // static | 598 // static |
593 const char* URLPattern::GetParseResultString( | 599 const char* URLPattern::GetParseResultString( |
594 URLPattern::ParseResult parse_result) { | 600 URLPattern::ParseResult parse_result) { |
595 return kParseResultMessages[parse_result]; | 601 return kParseResultMessages[parse_result]; |
596 } | 602 } |
OLD | NEW |