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

Unified Diff: chrome/common/extensions/url_pattern.cc

Issue 31008: Coalesce more hardcoded schemes to using predefined constants. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/tabs/tab_strip_model_unittest.cc ('k') | chrome/common/url_constants.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/url_pattern.cc
===================================================================
--- chrome/common/extensions/url_pattern.cc (revision 10345)
+++ chrome/common/extensions/url_pattern.cc (working copy)
@@ -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 @@
}
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 @@
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 @@
}
std::string URLPattern::GetAsString() const {
- std::string spec = scheme_ + kSchemeSeparator;
+ std::string spec = scheme_ + chrome::kStandardSchemeSeparator;
if (match_subdomains_) {
spec += "*";
« no previous file with comments | « chrome/browser/tabs/tab_strip_model_unittest.cc ('k') | chrome/common/url_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698