| OLD | NEW |
| 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_file.h" | 10 #include "url/url_file.h" |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 bool DoResolveRelativeHost(const char* base_url, | 365 bool DoResolveRelativeHost(const char* base_url, |
| 366 const url_parse::Parsed& base_parsed, | 366 const url_parse::Parsed& base_parsed, |
| 367 const CHAR* relative_url, | 367 const CHAR* relative_url, |
| 368 const url_parse::Component& relative_component, | 368 const url_parse::Component& relative_component, |
| 369 CharsetConverter* query_converter, | 369 CharsetConverter* query_converter, |
| 370 CanonOutput* output, | 370 CanonOutput* output, |
| 371 url_parse::Parsed* out_parsed) { | 371 url_parse::Parsed* out_parsed) { |
| 372 // Parse the relative URL, just like we would for anything following a | 372 // Parse the relative URL, just like we would for anything following a |
| 373 // scheme. | 373 // scheme. |
| 374 url_parse::Parsed relative_parsed; // Everything but the scheme is valid. | 374 url_parse::Parsed relative_parsed; // Everything but the scheme is valid. |
| 375 url_parse::ParseAfterScheme(&relative_url[relative_component.begin], | 375 url_parse::ParseAfterScheme(relative_url, relative_component.end(), |
| 376 relative_component.len, relative_component.begin, | 376 relative_component.begin, &relative_parsed); |
| 377 &relative_parsed); | |
| 378 | 377 |
| 379 // Now we can just use the replacement function to replace all the necessary | 378 // Now we can just use the replacement function to replace all the necessary |
| 380 // parts of the old URL with the new one. | 379 // parts of the old URL with the new one. |
| 381 Replacements<CHAR> replacements; | 380 Replacements<CHAR> replacements; |
| 382 replacements.SetUsername(relative_url, relative_parsed.username); | 381 replacements.SetUsername(relative_url, relative_parsed.username); |
| 383 replacements.SetPassword(relative_url, relative_parsed.password); | 382 replacements.SetPassword(relative_url, relative_parsed.password); |
| 384 replacements.SetHost(relative_url, relative_parsed.host); | 383 replacements.SetHost(relative_url, relative_parsed.host); |
| 385 replacements.SetPort(relative_url, relative_parsed.port); | 384 replacements.SetPort(relative_url, relative_parsed.port); |
| 386 replacements.SetPath(relative_url, relative_parsed.path); | 385 replacements.SetPath(relative_url, relative_parsed.path); |
| 387 replacements.SetQuery(relative_url, relative_parsed.query); | 386 replacements.SetQuery(relative_url, relative_parsed.query); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 const url_parse::Component& relative_component, | 544 const url_parse::Component& relative_component, |
| 546 CharsetConverter* query_converter, | 545 CharsetConverter* query_converter, |
| 547 CanonOutput* output, | 546 CanonOutput* output, |
| 548 url_parse::Parsed* out_parsed) { | 547 url_parse::Parsed* out_parsed) { |
| 549 return DoResolveRelativeURL<base::char16>( | 548 return DoResolveRelativeURL<base::char16>( |
| 550 base_url, base_parsed, base_is_file, relative_url, | 549 base_url, base_parsed, base_is_file, relative_url, |
| 551 relative_component, query_converter, output, out_parsed); | 550 relative_component, query_converter, output, out_parsed); |
| 552 } | 551 } |
| 553 | 552 |
| 554 } // namespace url_canon | 553 } // namespace url_canon |
| OLD | NEW |