| 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 "content/public/common/url_constants.h" | 13 #include "content/public/common/url_constants.h" |
| 12 #include "extensions/common/constants.h" | 14 #include "extensions/common/constants.h" |
| 13 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 14 #include "url/url_util.h" | 16 #include "url/url_util.h" |
| 15 | 17 |
| 16 const char URLPattern::kAllUrlsPattern[] = "<all_urls>"; | 18 const char URLPattern::kAllUrlsPattern[] = "<all_urls>"; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 } | 143 } |
| 142 | 144 |
| 143 bool URLPattern::operator>(const URLPattern& other) const { | 145 bool URLPattern::operator>(const URLPattern& other) const { |
| 144 return GetAsString() > other.GetAsString(); | 146 return GetAsString() > other.GetAsString(); |
| 145 } | 147 } |
| 146 | 148 |
| 147 bool URLPattern::operator==(const URLPattern& other) const { | 149 bool URLPattern::operator==(const URLPattern& other) const { |
| 148 return GetAsString() == other.GetAsString(); | 150 return GetAsString() == other.GetAsString(); |
| 149 } | 151 } |
| 150 | 152 |
| 153 std::ostream& operator<<(std::ostream& out, const URLPattern& url_pattern) { |
| 154 return out << '"' << url_pattern.GetAsString() << '"'; |
| 155 } |
| 156 |
| 151 URLPattern::ParseResult URLPattern::Parse(const std::string& pattern) { | 157 URLPattern::ParseResult URLPattern::Parse(const std::string& pattern) { |
| 152 spec_.clear(); | 158 spec_.clear(); |
| 153 SetMatchAllURLs(false); | 159 SetMatchAllURLs(false); |
| 154 SetMatchSubdomains(false); | 160 SetMatchSubdomains(false); |
| 155 SetPort("*"); | 161 SetPort("*"); |
| 156 | 162 |
| 157 // Special case pattern to match every valid URL. | 163 // Special case pattern to match every valid URL. |
| 158 if (pattern == kAllUrlsPattern) { | 164 if (pattern == kAllUrlsPattern) { |
| 159 SetMatchAllURLs(true); | 165 SetMatchAllURLs(true); |
| 160 return PARSE_SUCCESS; | 166 return PARSE_SUCCESS; |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 } | 542 } |
| 537 | 543 |
| 538 return result; | 544 return result; |
| 539 } | 545 } |
| 540 | 546 |
| 541 // static | 547 // static |
| 542 const char* URLPattern::GetParseResultString( | 548 const char* URLPattern::GetParseResultString( |
| 543 URLPattern::ParseResult parse_result) { | 549 URLPattern::ParseResult parse_result) { |
| 544 return kParseResultMessages[parse_result]; | 550 return kParseResultMessages[parse_result]; |
| 545 } | 551 } |
| OLD | NEW |