Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Side by Side Diff: extensions/common/url_pattern.cc

Issue 396033002: Support "always allow" for runtime script execution (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup extravaganza Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 return !ImpliesAllHosts() && scheme_ != "*" && !match_subdomains_;
471 }
472
469 bool URLPattern::MatchesPath(const std::string& test) const { 473 bool URLPattern::MatchesPath(const std::string& test) const {
470 // Make the behaviour of OverlapsWith consistent with MatchesURL, which is 474 // 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/'. 475 // need to match hosted apps on e.g. 'google.com' also run on 'google.com/'.
472 if (test + "/*" == path_escaped_) 476 if (test + "/*" == path_escaped_)
473 return true; 477 return true;
474 478
475 return MatchPattern(test, path_escaped_); 479 return MatchPattern(test, path_escaped_);
476 } 480 }
477 481
478 const std::string& URLPattern::GetAsString() const { 482 const std::string& URLPattern::GetAsString() const {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 } 603 }
600 604
601 return result; 605 return result;
602 } 606 }
603 607
604 // static 608 // static
605 const char* URLPattern::GetParseResultString( 609 const char* URLPattern::GetParseResultString(
606 URLPattern::ParseResult parse_result) { 610 URLPattern::ParseResult parse_result) {
607 return kParseResultMessages[parse_result]; 611 return kParseResultMessages[parse_result];
608 } 612 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698