diff options
author | sungmann.cho@navercorp.com <sungmann.cho@navercorp.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-18 07:57:49 +0000 |
---|---|---|
committer | sungmann.cho@navercorp.com <sungmann.cho@navercorp.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-18 07:57:49 +0000 |
commit | 08dc705a466d0f2f2cffdf6b36fe8bc651b780f5 (patch) | |
tree | 9953afe3dcf82822a990d1c9817dc9d11f52cf18 /url | |
parent | afbed27bab1a43e40129215aced8983fb5272707 (diff) | |
download | chromium_src-08dc705a466d0f2f2cffdf6b36fe8bc651b780f5.zip chromium_src-08dc705a466d0f2f2cffdf6b36fe8bc651b780f5.tar.gz chromium_src-08dc705a466d0f2f2cffdf6b36fe8bc651b780f5.tar.bz2 |
Replace some hard coded schemes with the constants in /url/url_constants.h.
BUG=none
TEST=compile
Review URL: https://codereview.chromium.org/335353002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277979 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'url')
-rw-r--r-- | url/gurl.cc | 2 | ||||
-rw-r--r-- | url/gurl.h | 4 | ||||
-rw-r--r-- | url/url_canon_relative.cc | 3 | ||||
-rw-r--r-- | url/url_canon_stdurl.cc | 13 | ||||
-rw-r--r-- | url/url_constants.cc | 1 | ||||
-rw-r--r-- | url/url_constants.h | 1 | ||||
-rw-r--r-- | url/url_util.cc | 12 |
7 files changed, 20 insertions, 16 deletions
diff --git a/url/gurl.cc b/url/gurl.cc index 947403e..b7374b1 100644 --- a/url/gurl.cc +++ b/url/gurl.cc @@ -137,7 +137,7 @@ void GURL::InitializeFromCanonicalSpec() { // canonical_spec actually points to the start of the outer URL, so we'd // end up with infinite recursion in this constructor. if (!url::FindAndCompareScheme(spec_.data(), spec_.length(), - "filesystem", &scheme) || + url::kFileSystemScheme, &scheme) || scheme.begin == parsed_.scheme.begin) { // We need to retain trailing whitespace on path URLs, as the |parsed_| // spec we originally received may legitimately contain trailing white- @@ -222,12 +222,12 @@ class URL_EXPORT GURL { // We often need to know if this is a file URL. File URLs are "standard", but // are often treated separately by some programs. bool SchemeIsFile() const { - return SchemeIs("file"); + return SchemeIs(url::kFileScheme); } // FileSystem URLs need to be treated differently in some cases. bool SchemeIsFileSystem() const { - return SchemeIs("filesystem"); + return SchemeIs(url::kFileSystemScheme); } // If the scheme indicates a secure connection diff --git a/url/url_canon_relative.cc b/url/url_canon_relative.cc index 275a6fd..9436245 100644 --- a/url/url_canon_relative.cc +++ b/url/url_canon_relative.cc @@ -7,6 +7,7 @@ #include "base/logging.h" #include "url/url_canon.h" #include "url/url_canon_internal.h" +#include "url/url_constants.h" #include "url/url_file.h" #include "url/url_parse_internal.h" #include "url/url_util_internal.h" @@ -145,7 +146,7 @@ bool DoIsRelativeURL(const char* base, // If it's a filesystem URL, the only valid way to make it relative is not to // supply a scheme. There's no equivalent to e.g. http:index.html. - if (CompareSchemeComponent(url, scheme, "filesystem")) + if (CompareSchemeComponent(url, scheme, kFileSystemScheme)) return true; // ExtractScheme guarantees that the colon immediately follows what it diff --git a/url/url_canon_stdurl.cc b/url/url_canon_stdurl.cc index 1f5000e..7a61de8 100644 --- a/url/url_canon_stdurl.cc +++ b/url/url_canon_stdurl.cc @@ -7,6 +7,7 @@ #include "url/url_canon.h" #include "url/url_canon_internal.h" +#include "url/url_constants.h" namespace url { @@ -98,25 +99,25 @@ int DefaultPortForScheme(const char* scheme, int scheme_len) { int default_port = PORT_UNSPECIFIED; switch (scheme_len) { case 4: - if (!strncmp(scheme, "http", scheme_len)) + if (!strncmp(scheme, kHttpScheme, scheme_len)) default_port = 80; break; case 5: - if (!strncmp(scheme, "https", scheme_len)) + if (!strncmp(scheme, kHttpsScheme, scheme_len)) default_port = 443; break; case 3: - if (!strncmp(scheme, "ftp", scheme_len)) + if (!strncmp(scheme, kFtpScheme, scheme_len)) default_port = 21; - else if (!strncmp(scheme, "wss", scheme_len)) + else if (!strncmp(scheme, kWssScheme, scheme_len)) default_port = 443; break; case 6: - if (!strncmp(scheme, "gopher", scheme_len)) + if (!strncmp(scheme, kGopherScheme, scheme_len)) default_port = 70; break; case 2: - if (!strncmp(scheme, "ws", scheme_len)) + if (!strncmp(scheme, kWsScheme, scheme_len)) default_port = 80; break; } diff --git a/url/url_constants.cc b/url/url_constants.cc index d5c57f4..9ef0e63 100644 --- a/url/url_constants.cc +++ b/url/url_constants.cc @@ -14,6 +14,7 @@ const char kDataScheme[] = "data"; const char kFileScheme[] = "file"; const char kFileSystemScheme[] = "filesystem"; const char kFtpScheme[] = "ftp"; +const char kGopherScheme[] = "gopher"; const char kHttpScheme[] = "http"; const char kHttpsScheme[] = "https"; const char kJavaScriptScheme[] = "javascript"; diff --git a/url/url_constants.h b/url/url_constants.h index c2f163a..3228bbb 100644 --- a/url/url_constants.h +++ b/url/url_constants.h @@ -17,6 +17,7 @@ URL_EXPORT extern const char kDataScheme[]; URL_EXPORT extern const char kFileScheme[]; URL_EXPORT extern const char kFileSystemScheme[]; URL_EXPORT extern const char kFtpScheme[]; +URL_EXPORT extern const char kGopherScheme[]; URL_EXPORT extern const char kHttpScheme[]; URL_EXPORT extern const char kHttpsScheme[]; URL_EXPORT extern const char kJavaScriptScheme[]; diff --git a/url/url_util.cc b/url/url_util.cc index 7cb2de2..9f2ad2c 100644 --- a/url/url_util.cc +++ b/url/url_util.cc @@ -35,13 +35,13 @@ inline bool DoLowerCaseEqualsASCII(Iter a_begin, Iter a_end, const char* b) { const int kNumStandardURLSchemes = 8; const char* kStandardURLSchemes[kNumStandardURLSchemes] = { - "http", - "https", + kHttpScheme, + kHttpsScheme, kFileScheme, // Yes, file urls can have a hostname! - "ftp", - "gopher", - "ws", // WebSocket. - "wss", // WebSocket secure. + kFtpScheme, + kGopherScheme, + kWsScheme, // WebSocket. + kWssScheme, // WebSocket secure. kFileSystemScheme, }; |