diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-26 01:56:02 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-26 01:56:02 +0000 |
commit | dcf7d3525aa9b1f16b56a16d16108262db0571ee (patch) | |
tree | 91228f9d96aa74f102df742cdf76598cbb328958 /chrome/common/extensions | |
parent | 387b71b7d1d1bf267cbe088136610959b319f3b3 (diff) | |
download | chromium_src-dcf7d3525aa9b1f16b56a16d16108262db0571ee.zip chromium_src-dcf7d3525aa9b1f16b56a16d16108262db0571ee.tar.gz chromium_src-dcf7d3525aa9b1f16b56a16d16108262db0571ee.tar.bz2 |
Coalesce more hardcoded schemes to using predefined constants.
Review URL: http://codereview.chromium.org/31008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10437 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions')
-rw-r--r-- | chrome/common/extensions/url_pattern.cc | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/chrome/common/extensions/url_pattern.cc b/chrome/common/extensions/url_pattern.cc index ce345ca..7f705f2 100644 --- a/chrome/common/extensions/url_pattern.cc +++ b/chrome/common/extensions/url_pattern.cc @@ -2,21 +2,22 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "chrome/common/extensions/url_pattern.h" + #include "base/string_piece.h" #include "base/string_util.h" -#include "chrome/common/extensions/url_pattern.h" +#include "chrome/common/url_constants.h" // TODO(aa): Consider adding chrome-extension? What about more obscure ones // like data: and javascript: ? static const char* kValidSchemes[] = { - "http", - "https", - "file", - "ftp", - "chrome-ui" + chrome::kHttpScheme, + chrome::kHttpsScheme, + chrome::kFileScheme, + chrome::kFtpScheme, + chrome::kChromeUIScheme, }; -static const char kSchemeSeparator[] = "://"; static const char kPathSeparator[] = "/"; static bool IsValidScheme(const std::string& scheme) { @@ -29,7 +30,7 @@ static bool IsValidScheme(const std::string& scheme) { } bool URLPattern::Parse(const std::string& pattern) { - size_t scheme_end_pos = pattern.find(kSchemeSeparator); + size_t scheme_end_pos = pattern.find(chrome::kStandardSchemeSeparator); if (scheme_end_pos == std::string::npos) return false; @@ -37,7 +38,8 @@ bool URLPattern::Parse(const std::string& pattern) { if (!IsValidScheme(scheme_)) return false; - size_t host_start_pos = scheme_end_pos + strlen(kSchemeSeparator); + size_t host_start_pos = scheme_end_pos + + strlen(chrome::kStandardSchemeSeparator); if (host_start_pos >= pattern.length()) return false; @@ -128,7 +130,7 @@ bool URLPattern::MatchesPath(const GURL& test) { } std::string URLPattern::GetAsString() const { - std::string spec = scheme_ + kSchemeSeparator; + std::string spec = scheme_ + chrome::kStandardSchemeSeparator; if (match_subdomains_) { spec += "*"; |