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

Side by Side Diff: url/url_canon_stdurl.cc

Issue 335353002: Replace some hard coded schemes with the constants in /url/url_constants.h. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typos. Created 6 years, 6 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 unified diff | Download patch
« no previous file with comments | « url/url_canon_relative.cc ('k') | url/url_constants.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Functions to canonicalize "standard" URLs, which are ones that have an 5 // Functions to canonicalize "standard" URLs, which are ones that have an
6 // authority section including a host name. 6 // authority section including a host name.
7 7
8 #include "url/url_canon.h" 8 #include "url/url_canon.h"
9 #include "url/url_canon_internal.h" 9 #include "url/url_canon_internal.h"
10 #include "url/url_constants.h"
10 11
11 namespace url { 12 namespace url {
12 13
13 namespace { 14 namespace {
14 15
15 template<typename CHAR, typename UCHAR> 16 template<typename CHAR, typename UCHAR>
16 bool DoCanonicalizeStandardURL(const URLComponentSource<CHAR>& source, 17 bool DoCanonicalizeStandardURL(const URLComponentSource<CHAR>& source,
17 const Parsed& parsed, 18 const Parsed& parsed,
18 CharsetConverter* query_converter, 19 CharsetConverter* query_converter,
19 CanonOutput* output, 20 CanonOutput* output,
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 92
92 } // namespace 93 } // namespace
93 94
94 95
95 // Returns the default port for the given canonical scheme, or PORT_UNSPECIFIED 96 // Returns the default port for the given canonical scheme, or PORT_UNSPECIFIED
96 // if the scheme is unknown. 97 // if the scheme is unknown.
97 int DefaultPortForScheme(const char* scheme, int scheme_len) { 98 int DefaultPortForScheme(const char* scheme, int scheme_len) {
98 int default_port = PORT_UNSPECIFIED; 99 int default_port = PORT_UNSPECIFIED;
99 switch (scheme_len) { 100 switch (scheme_len) {
100 case 4: 101 case 4:
101 if (!strncmp(scheme, "http", scheme_len)) 102 if (!strncmp(scheme, kHttpScheme, scheme_len))
102 default_port = 80; 103 default_port = 80;
103 break; 104 break;
104 case 5: 105 case 5:
105 if (!strncmp(scheme, "https", scheme_len)) 106 if (!strncmp(scheme, kHttpsScheme, scheme_len))
106 default_port = 443; 107 default_port = 443;
107 break; 108 break;
108 case 3: 109 case 3:
109 if (!strncmp(scheme, "ftp", scheme_len)) 110 if (!strncmp(scheme, kFtpScheme, scheme_len))
110 default_port = 21; 111 default_port = 21;
111 else if (!strncmp(scheme, "wss", scheme_len)) 112 else if (!strncmp(scheme, kWssScheme, scheme_len))
112 default_port = 443; 113 default_port = 443;
113 break; 114 break;
114 case 6: 115 case 6:
115 if (!strncmp(scheme, "gopher", scheme_len)) 116 if (!strncmp(scheme, kGopherScheme, scheme_len))
116 default_port = 70; 117 default_port = 70;
117 break; 118 break;
118 case 2: 119 case 2:
119 if (!strncmp(scheme, "ws", scheme_len)) 120 if (!strncmp(scheme, kWsScheme, scheme_len))
120 default_port = 80; 121 default_port = 80;
121 break; 122 break;
122 } 123 }
123 return default_port; 124 return default_port;
124 } 125 }
125 126
126 bool CanonicalizeStandardURL(const char* spec, 127 bool CanonicalizeStandardURL(const char* spec,
127 int spec_len, 128 int spec_len,
128 const Parsed& parsed, 129 const Parsed& parsed,
129 CharsetConverter* query_converter, 130 CharsetConverter* query_converter,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 Parsed* new_parsed) { 178 Parsed* new_parsed) {
178 RawCanonOutput<1024> utf8; 179 RawCanonOutput<1024> utf8;
179 URLComponentSource<char> source(base); 180 URLComponentSource<char> source(base);
180 Parsed parsed(base_parsed); 181 Parsed parsed(base_parsed);
181 SetupUTF16OverrideComponents(base, replacements, &utf8, &source, &parsed); 182 SetupUTF16OverrideComponents(base, replacements, &utf8, &source, &parsed);
182 return DoCanonicalizeStandardURL<char, unsigned char>( 183 return DoCanonicalizeStandardURL<char, unsigned char>(
183 source, parsed, query_converter, output, new_parsed); 184 source, parsed, query_converter, output, new_parsed);
184 } 185 }
185 186
186 } // namespace url 187 } // namespace url
OLDNEW
« no previous file with comments | « url/url_canon_relative.cc ('k') | url/url_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698