diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-25 10:01:05 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-25 10:01:05 +0000 |
commit | 9f72aa09129fbd19a5ae253371019752a0624997 (patch) | |
tree | 6c54d2280ebdf31fe31f46fd3d882977324e4f3d /chrome/common/extensions/url_pattern.cc | |
parent | 0a73a37731cf87370cb7c4f8dcb4801277c1d858 (diff) | |
download | chromium_src-9f72aa09129fbd19a5ae253371019752a0624997.zip chromium_src-9f72aa09129fbd19a5ae253371019752a0624997.tar.gz chromium_src-9f72aa09129fbd19a5ae253371019752a0624997.tar.bz2 |
Reland r50834
TBR=tony@chromium.org
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50837 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions/url_pattern.cc')
-rw-r--r-- | chrome/common/extensions/url_pattern.cc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/chrome/common/extensions/url_pattern.cc b/chrome/common/extensions/url_pattern.cc index e129903..1aae528 100644 --- a/chrome/common/extensions/url_pattern.cc +++ b/chrome/common/extensions/url_pattern.cc @@ -4,6 +4,7 @@ #include "chrome/common/extensions/url_pattern.h" +#include "base/scoped_ptr.h" #include "base/string_piece.h" #include "base/string_util.h" #include "chrome/common/url_constants.h" @@ -21,6 +22,15 @@ static const char* kValidSchemes[] = { static const char kPathSeparator[] = "/"; // static +URLPattern* URLPattern::CreateFromString(const std::string& pattern_string) { + scoped_ptr<URLPattern> pattern(new URLPattern); + if (pattern->Parse(pattern_string)) + return pattern.release(); + else + return NULL; +} + +// static bool URLPattern::IsValidScheme(const std::string& scheme) { for (size_t i = 0; i < arraysize(kValidSchemes); ++i) { if (scheme == kValidSchemes[i]) @@ -78,6 +88,7 @@ bool URLPattern::Parse(const std::string& pattern) { } path_ = pattern.substr(path_start_pos); + return true; } @@ -94,6 +105,14 @@ bool URLPattern::MatchesUrl(const GURL &test) const { return true; } +bool URLPattern::MatchesHost(const std::string& host) const { + std::string test(chrome::kHttpScheme); + test += chrome::kStandardSchemeSeparator; + test += host; + test += "/"; + return MatchesHost(GURL(test)); +} + bool URLPattern::MatchesHost(const GURL& test) const { // If the hosts are exactly equal, we have a match. if (test.host() == host_) |