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

Side by Side Diff: url/url_canon_relative.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/gurl.cc ('k') | url/url_canon_stdurl.cc » ('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 // Canonicalizer functions for working with and resolving relative URLs. 5 // Canonicalizer functions for working with and resolving relative URLs.
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
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 #include "url/url_file.h" 11 #include "url/url_file.h"
11 #include "url/url_parse_internal.h" 12 #include "url/url_parse_internal.h"
12 #include "url/url_util_internal.h" 13 #include "url/url_util_internal.h"
13 14
14 namespace url { 15 namespace url {
15 16
16 namespace { 17 namespace {
17 18
18 // Firefox does a case-sensitive compare (which is probably wrong--Mozilla bug 19 // Firefox does a case-sensitive compare (which is probably wrong--Mozilla bug
19 // 379034), whereas IE is case-insensetive. 20 // 379034), whereas IE is case-insensetive.
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 // When the scheme that they both share is not hierarchical, treat the 139 // When the scheme that they both share is not hierarchical, treat the
139 // incoming scheme as absolute (this way with the base of "data:foo", 140 // incoming scheme as absolute (this way with the base of "data:foo",
140 // "data:bar" will be reported as absolute. 141 // "data:bar" will be reported as absolute.
141 if (!is_base_hierarchical) 142 if (!is_base_hierarchical)
142 return true; 143 return true;
143 144
144 int colon_offset = scheme.end(); 145 int colon_offset = scheme.end();
145 146
146 // If it's a filesystem URL, the only valid way to make it relative is not to 147 // If it's a filesystem URL, the only valid way to make it relative is not to
147 // supply a scheme. There's no equivalent to e.g. http:index.html. 148 // supply a scheme. There's no equivalent to e.g. http:index.html.
148 if (CompareSchemeComponent(url, scheme, "filesystem")) 149 if (CompareSchemeComponent(url, scheme, kFileSystemScheme))
149 return true; 150 return true;
150 151
151 // ExtractScheme guarantees that the colon immediately follows what it 152 // ExtractScheme guarantees that the colon immediately follows what it
152 // considers to be the scheme. CountConsecutiveSlashes will handle the 153 // considers to be the scheme. CountConsecutiveSlashes will handle the
153 // case where the begin offset is the end of the input. 154 // case where the begin offset is the end of the input.
154 int num_slashes = CountConsecutiveSlashes(url, colon_offset + 1, url_len); 155 int num_slashes = CountConsecutiveSlashes(url, colon_offset + 1, url_len);
155 156
156 if (num_slashes == 0 || num_slashes == 1) { 157 if (num_slashes == 0 || num_slashes == 1) {
157 // No slashes means it's a relative path like "http:foo.html". One slash 158 // No slashes means it's a relative path like "http:foo.html". One slash
158 // is an absolute path. "http:/home/foo.html" 159 // is an absolute path. "http:/home/foo.html"
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 const Component& relative_component, 551 const Component& relative_component,
551 CharsetConverter* query_converter, 552 CharsetConverter* query_converter,
552 CanonOutput* output, 553 CanonOutput* output,
553 Parsed* out_parsed) { 554 Parsed* out_parsed) {
554 return DoResolveRelativeURL<base::char16>( 555 return DoResolveRelativeURL<base::char16>(
555 base_url, base_parsed, base_is_file, relative_url, 556 base_url, base_parsed, base_is_file, relative_url,
556 relative_component, query_converter, output, out_parsed); 557 relative_component, query_converter, output, out_parsed);
557 } 558 }
558 559
559 } // namespace url 560 } // namespace url
OLDNEW
« no previous file with comments | « url/gurl.cc ('k') | url/url_canon_stdurl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698