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
parent afbed27b
...@@ -137,7 +137,7 @@ void GURL::InitializeFromCanonicalSpec() { ...@@ -137,7 +137,7 @@ void GURL::InitializeFromCanonicalSpec() {
// canonical_spec actually points to the start of the outer URL, so we'd // canonical_spec actually points to the start of the outer URL, so we'd
// end up with infinite recursion in this constructor. // end up with infinite recursion in this constructor.
if (!url::FindAndCompareScheme(spec_.data(), spec_.length(), if (!url::FindAndCompareScheme(spec_.data(), spec_.length(),
"filesystem", &scheme) || url::kFileSystemScheme, &scheme) ||
scheme.begin == parsed_.scheme.begin) { scheme.begin == parsed_.scheme.begin) {
// We need to retain trailing whitespace on path URLs, as the |parsed_| // We need to retain trailing whitespace on path URLs, as the |parsed_|
// spec we originally received may legitimately contain trailing white- // spec we originally received may legitimately contain trailing white-
......
...@@ -222,12 +222,12 @@ class URL_EXPORT GURL { ...@@ -222,12 +222,12 @@ class URL_EXPORT GURL {
// We often need to know if this is a file URL. File URLs are "standard", but // We often need to know if this is a file URL. File URLs are "standard", but
// are often treated separately by some programs. // are often treated separately by some programs.
bool SchemeIsFile() const { bool SchemeIsFile() const {
return SchemeIs("file"); return SchemeIs(url::kFileScheme);
} }
// FileSystem URLs need to be treated differently in some cases. // FileSystem URLs need to be treated differently in some cases.
bool SchemeIsFileSystem() const { bool SchemeIsFileSystem() const {
return SchemeIs("filesystem"); return SchemeIs(url::kFileSystemScheme);
} }
// If the scheme indicates a secure connection // If the scheme indicates a secure connection
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/logging.h" #include "base/logging.h"
#include "url/url_canon.h" #include "url/url_canon.h"
#include "url/url_canon_internal.h" #include "url/url_canon_internal.h"
#include "url/url_constants.h"
#include "url/url_file.h" #include "url/url_file.h"
#include "url/url_parse_internal.h" #include "url/url_parse_internal.h"
#include "url/url_util_internal.h" #include "url/url_util_internal.h"
...@@ -145,7 +146,7 @@ bool DoIsRelativeURL(const char* base, ...@@ -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 // 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. // 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; return true;
// ExtractScheme guarantees that the colon immediately follows what it // ExtractScheme guarantees that the colon immediately follows what it
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "url/url_canon.h" #include "url/url_canon.h"
#include "url/url_canon_internal.h" #include "url/url_canon_internal.h"
#include "url/url_constants.h"
namespace url { namespace url {
...@@ -98,25 +99,25 @@ int DefaultPortForScheme(const char* scheme, int scheme_len) { ...@@ -98,25 +99,25 @@ int DefaultPortForScheme(const char* scheme, int scheme_len) {
int default_port = PORT_UNSPECIFIED; int default_port = PORT_UNSPECIFIED;
switch (scheme_len) { switch (scheme_len) {
case 4: case 4:
if (!strncmp(scheme, "http", scheme_len)) if (!strncmp(scheme, kHttpScheme, scheme_len))
default_port = 80; default_port = 80;
break; break;
case 5: case 5:
if (!strncmp(scheme, "https", scheme_len)) if (!strncmp(scheme, kHttpsScheme, scheme_len))
default_port = 443; default_port = 443;
break; break;
case 3: case 3:
if (!strncmp(scheme, "ftp", scheme_len)) if (!strncmp(scheme, kFtpScheme, scheme_len))
default_port = 21; default_port = 21;
else if (!strncmp(scheme, "wss", scheme_len)) else if (!strncmp(scheme, kWssScheme, scheme_len))
default_port = 443; default_port = 443;
break; break;
case 6: case 6:
if (!strncmp(scheme, "gopher", scheme_len)) if (!strncmp(scheme, kGopherScheme, scheme_len))
default_port = 70; default_port = 70;
break; break;
case 2: case 2:
if (!strncmp(scheme, "ws", scheme_len)) if (!strncmp(scheme, kWsScheme, scheme_len))
default_port = 80; default_port = 80;
break; break;
} }
......
...@@ -14,6 +14,7 @@ const char kDataScheme[] = "data"; ...@@ -14,6 +14,7 @@ const char kDataScheme[] = "data";
const char kFileScheme[] = "file"; const char kFileScheme[] = "file";
const char kFileSystemScheme[] = "filesystem"; const char kFileSystemScheme[] = "filesystem";
const char kFtpScheme[] = "ftp"; const char kFtpScheme[] = "ftp";
const char kGopherScheme[] = "gopher";
const char kHttpScheme[] = "http"; const char kHttpScheme[] = "http";
const char kHttpsScheme[] = "https"; const char kHttpsScheme[] = "https";
const char kJavaScriptScheme[] = "javascript"; const char kJavaScriptScheme[] = "javascript";
......
...@@ -17,6 +17,7 @@ URL_EXPORT extern const char kDataScheme[]; ...@@ -17,6 +17,7 @@ URL_EXPORT extern const char kDataScheme[];
URL_EXPORT extern const char kFileScheme[]; URL_EXPORT extern const char kFileScheme[];
URL_EXPORT extern const char kFileSystemScheme[]; URL_EXPORT extern const char kFileSystemScheme[];
URL_EXPORT extern const char kFtpScheme[]; URL_EXPORT extern const char kFtpScheme[];
URL_EXPORT extern const char kGopherScheme[];
URL_EXPORT extern const char kHttpScheme[]; URL_EXPORT extern const char kHttpScheme[];
URL_EXPORT extern const char kHttpsScheme[]; URL_EXPORT extern const char kHttpsScheme[];
URL_EXPORT extern const char kJavaScriptScheme[]; URL_EXPORT extern const char kJavaScriptScheme[];
......
...@@ -35,13 +35,13 @@ inline bool DoLowerCaseEqualsASCII(Iter a_begin, Iter a_end, const char* b) { ...@@ -35,13 +35,13 @@ inline bool DoLowerCaseEqualsASCII(Iter a_begin, Iter a_end, const char* b) {
const int kNumStandardURLSchemes = 8; const int kNumStandardURLSchemes = 8;
const char* kStandardURLSchemes[kNumStandardURLSchemes] = { const char* kStandardURLSchemes[kNumStandardURLSchemes] = {
"http", kHttpScheme,
"https", kHttpsScheme,
kFileScheme, // Yes, file urls can have a hostname! kFileScheme, // Yes, file urls can have a hostname!
"ftp", kFtpScheme,
"gopher", kGopherScheme,
"ws", // WebSocket. kWsScheme, // WebSocket.
"wss", // WebSocket secure. kWssScheme, // WebSocket secure.
kFileSystemScheme, kFileSystemScheme,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment