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::IsOrigin() const { | |
470 // We ignore the port because it's not all that interesting. | |
not at google - send to devlin
2014/08/13 22:59:17
Actually a better explanation would be
// Strictl
gpdavis
2014/08/13 23:23:06
Done.
| |
471 return !ImpliesAllHosts() && scheme_ != "*" && !match_subdomains_; | |
472 } | |
473 | |
474 GURL URLPattern::ToOrigin() const { | |
475 if (!IsOrigin()) | |
476 return GURL(); | |
477 | |
478 URLPattern origin(valid_schemes()); | |
479 origin.SetScheme(scheme()); | |
480 origin.SetHost(host()); | |
481 origin.SetPort(port()); | |
482 origin.SetPath("/*"); | |
483 return GURL(origin.GetAsString()); | |
484 } | |
485 | |
469 bool URLPattern::MatchesPath(const std::string& test) const { | 486 bool URLPattern::MatchesPath(const std::string& test) const { |
470 // Make the behaviour of OverlapsWith consistent with MatchesURL, which is | 487 // 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/'. | 488 // need to match hosted apps on e.g. 'google.com' also run on 'google.com/'. |
472 if (test + "/*" == path_escaped_) | 489 if (test + "/*" == path_escaped_) |
473 return true; | 490 return true; |
474 | 491 |
475 return MatchPattern(test, path_escaped_); | 492 return MatchPattern(test, path_escaped_); |
476 } | 493 } |
477 | 494 |
478 const std::string& URLPattern::GetAsString() const { | 495 const std::string& URLPattern::GetAsString() const { |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
599 } | 616 } |
600 | 617 |
601 return result; | 618 return result; |
602 } | 619 } |
603 | 620 |
604 // static | 621 // static |
605 const char* URLPattern::GetParseResultString( | 622 const char* URLPattern::GetParseResultString( |
606 URLPattern::ParseResult parse_result) { | 623 URLPattern::ParseResult parse_result) { |
607 return kParseResultMessages[parse_result]; | 624 return kParseResultMessages[parse_result]; |
608 } | 625 } |
OLD | NEW |