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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "url/url_canon.h" | 10 #include "url/url_canon.h" |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 bool DoResolveRelativeURL(const char* base_url, | 436 bool DoResolveRelativeURL(const char* base_url, |
437 const Parsed& base_parsed, | 437 const Parsed& base_parsed, |
438 bool base_is_file, | 438 bool base_is_file, |
439 const CHAR* relative_url, | 439 const CHAR* relative_url, |
440 const Component& relative_component, | 440 const Component& relative_component, |
441 CharsetConverter* query_converter, | 441 CharsetConverter* query_converter, |
442 CanonOutput* output, | 442 CanonOutput* output, |
443 Parsed* out_parsed) { | 443 Parsed* out_parsed) { |
444 // |base_parsed| is the starting point for our output. Since we may have | 444 // |base_parsed| is the starting point for our output. Since we may have |
445 // removed whitespace from |relative_url| before entering this method, we'll | 445 // removed whitespace from |relative_url| before entering this method, we'll |
446 // carry over the |whitespace_removed| flag. | 446 // carry over the |potentially_dangling_markup| flag. |
447 bool whitespace_removed = out_parsed->whitespace_removed; | 447 bool potentially_dangling_markup = out_parsed->potentially_dangling_markup; |
448 *out_parsed = base_parsed; | 448 *out_parsed = base_parsed; |
449 if (whitespace_removed) | 449 if (potentially_dangling_markup) |
450 out_parsed->whitespace_removed = true; | 450 out_parsed->potentially_dangling_markup = true; |
451 | 451 |
452 // Sanity check: the input should have a host or we'll break badly below. | 452 // Sanity check: the input should have a host or we'll break badly below. |
453 // We can only resolve relative URLs with base URLs that have hosts and | 453 // We can only resolve relative URLs with base URLs that have hosts and |
454 // paths (even the default path of "/" is OK). | 454 // paths (even the default path of "/" is OK). |
455 // | 455 // |
456 // We allow hosts with no length so we can handle file URLs, for example. | 456 // We allow hosts with no length so we can handle file URLs, for example. |
457 if (base_parsed.path.len <= 0) { | 457 if (base_parsed.path.len <= 0) { |
458 // On error, return the input (resolving a relative URL on a non-relative | 458 // On error, return the input (resolving a relative URL on a non-relative |
459 // base = the base). | 459 // base = the base). |
460 int base_len = base_parsed.Length(); | 460 int base_len = base_parsed.Length(); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 const Component& relative_component, | 573 const Component& relative_component, |
574 CharsetConverter* query_converter, | 574 CharsetConverter* query_converter, |
575 CanonOutput* output, | 575 CanonOutput* output, |
576 Parsed* out_parsed) { | 576 Parsed* out_parsed) { |
577 return DoResolveRelativeURL<base::char16>( | 577 return DoResolveRelativeURL<base::char16>( |
578 base_url, base_parsed, base_is_file, relative_url, | 578 base_url, base_parsed, base_is_file, relative_url, |
579 relative_component, query_converter, output, out_parsed); | 579 relative_component, query_converter, output, out_parsed); |
580 } | 580 } |
581 | 581 |
582 } // namespace url | 582 } // namespace url |
OLD | NEW |