| 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> | 7 #include <ostream> |
| 8 | 8 |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 // unrecognized, or the length of the recognized TLD. | 459 // unrecognized, or the length of the recognized TLD. |
| 460 registry_length = net::registry_controlled_domains::GetRegistryLength( | 460 registry_length = net::registry_controlled_domains::GetRegistryLength( |
| 461 base::StringPrintf("foo.%s", host_.c_str()), | 461 base::StringPrintf("foo.%s", host_.c_str()), |
| 462 net::registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES, | 462 net::registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES, |
| 463 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); | 463 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); |
| 464 // If we recognized this TLD, then this is a pattern like *.com, and it | 464 // If we recognized this TLD, then this is a pattern like *.com, and it |
| 465 // should imply all hosts. Otherwise, this doesn't imply all hosts. | 465 // should imply all hosts. Otherwise, this doesn't imply all hosts. |
| 466 return registry_length > 0; | 466 return registry_length > 0; |
| 467 } | 467 } |
| 468 | 468 |
| 469 bool URLPattern::MatchesSingleOrigin() const { |
| 470 // We ignore the port because it's not all that interesting. |
| 471 return !ImpliesAllHosts() && scheme_ != "*" && !match_subdomains_; |
| 472 } |
| 473 |
| 469 bool URLPattern::MatchesPath(const std::string& test) const { | 474 bool URLPattern::MatchesPath(const std::string& test) const { |
| 470 // Make the behaviour of OverlapsWith consistent with MatchesURL, which is | 475 // Make the behaviour of OverlapsWith consistent with MatchesURL, which is |
| 471 // need to match hosted apps on e.g. 'google.com' also run on 'google.com/'. | 476 // need to match hosted apps on e.g. 'google.com' also run on 'google.com/'. |
| 472 if (test + "/*" == path_escaped_) | 477 if (test + "/*" == path_escaped_) |
| 473 return true; | 478 return true; |
| 474 | 479 |
| 475 return MatchPattern(test, path_escaped_); | 480 return MatchPattern(test, path_escaped_); |
| 476 } | 481 } |
| 477 | 482 |
| 478 const std::string& URLPattern::GetAsString() const { | 483 const std::string& URLPattern::GetAsString() const { |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 } | 604 } |
| 600 | 605 |
| 601 return result; | 606 return result; |
| 602 } | 607 } |
| 603 | 608 |
| 604 // static | 609 // static |
| 605 const char* URLPattern::GetParseResultString( | 610 const char* URLPattern::GetParseResultString( |
| 606 URLPattern::ParseResult parse_result) { | 611 URLPattern::ParseResult parse_result) { |
| 607 return kParseResultMessages[parse_result]; | 612 return kParseResultMessages[parse_result]; |
| 608 } | 613 } |
| OLD | NEW |