| 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 // Strictly speaking, the port is part of the origin, but in URLPattern it |
| 471 // defaults to *. It's not very interesting anyway, so leave it out. |
| 472 return !ImpliesAllHosts() && scheme_ != "*" && !match_subdomains_; |
| 473 } |
| 474 |
| 469 bool URLPattern::MatchesPath(const std::string& test) const { | 475 bool URLPattern::MatchesPath(const std::string& test) const { |
| 470 // Make the behaviour of OverlapsWith consistent with MatchesURL, which is | 476 // 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/'. | 477 // need to match hosted apps on e.g. 'google.com' also run on 'google.com/'. |
| 472 if (test + "/*" == path_escaped_) | 478 if (test + "/*" == path_escaped_) |
| 473 return true; | 479 return true; |
| 474 | 480 |
| 475 return MatchPattern(test, path_escaped_); | 481 return MatchPattern(test, path_escaped_); |
| 476 } | 482 } |
| 477 | 483 |
| 478 const std::string& URLPattern::GetAsString() const { | 484 const std::string& URLPattern::GetAsString() const { |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 } | 605 } |
| 600 | 606 |
| 601 return result; | 607 return result; |
| 602 } | 608 } |
| 603 | 609 |
| 604 // static | 610 // static |
| 605 const char* URLPattern::GetParseResultString( | 611 const char* URLPattern::GetParseResultString( |
| 606 URLPattern::ParseResult parse_result) { | 612 URLPattern::ParseResult parse_result) { |
| 607 return kParseResultMessages[parse_result]; | 613 return kParseResultMessages[parse_result]; |
| 608 } | 614 } |
| OLD | NEW |