| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #include <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "chrome/browser/net/url_fixer_upper.h" | 7 #include "chrome/browser/net/url_fixer_upper.h" |
| 8 | 8 |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 // TODO(estade): Remove these ugly, ugly functions. They are only used in | 26 // TODO(estade): Remove these ugly, ugly functions. They are only used in |
| 27 // SegmentURL. A url_parse::Parsed object keeps track of a bunch of indices into | 27 // SegmentURL. A url_parse::Parsed object keeps track of a bunch of indices into |
| 28 // a url string, and these need to be updated when the URL is converted from | 28 // a url string, and these need to be updated when the URL is converted from |
| 29 // UTF8 to UTF16. Instead of this after-the-fact adjustment, we should parse it | 29 // UTF8 to UTF16. Instead of this after-the-fact adjustment, we should parse it |
| 30 // in the correct string format to begin with. | 30 // in the correct string format to begin with. |
| 31 url_parse::Component UTF8ComponentToWideComponent( | 31 url_parse::Component UTF8ComponentToWideComponent( |
| 32 string text_utf8, | 32 string text_utf8, |
| 33 const url_parse::Component& component_utf8) { | 33 const url_parse::Component& component_utf8) { |
| 34 if (component_utf8.len == -1) |
| 35 return url_parse::Component(); |
| 36 |
| 34 string before_component_string = text_utf8.substr(0, component_utf8.begin); | 37 string before_component_string = text_utf8.substr(0, component_utf8.begin); |
| 35 string component_string = text_utf8.substr(component_utf8.begin, | 38 string component_string = text_utf8.substr(component_utf8.begin, |
| 36 component_utf8.len); | 39 component_utf8.len); |
| 37 wstring before_component_string_w = UTF8ToWide(before_component_string); | 40 wstring before_component_string_w = UTF8ToWide(before_component_string); |
| 38 wstring component_string_w = UTF8ToWide(component_string); | 41 wstring component_string_w = UTF8ToWide(component_string); |
| 39 url_parse::Component component_w(before_component_string_w.length(), | 42 url_parse::Component component_w(before_component_string_w.length(), |
| 40 component_string_w.length()); | 43 component_string_w.length()); |
| 41 return component_w; | 44 return component_w; |
| 42 } | 45 } |
| 43 | 46 |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 } | 527 } |
| 525 wstring URLFixerUpper::FixupURL(const wstring& text, | 528 wstring URLFixerUpper::FixupURL(const wstring& text, |
| 526 const wstring& desired_tld) { | 529 const wstring& desired_tld) { |
| 527 return UTF8ToWide(FixupURL(WideToUTF8(text), WideToUTF8(desired_tld))); | 530 return UTF8ToWide(FixupURL(WideToUTF8(text), WideToUTF8(desired_tld))); |
| 528 } | 531 } |
| 529 wstring URLFixerUpper::FixupRelativeFile(const wstring& base_dir, | 532 wstring URLFixerUpper::FixupRelativeFile(const wstring& base_dir, |
| 530 const wstring& text) { | 533 const wstring& text) { |
| 531 return UTF8ToWide(FixupRelativeFile(FilePath::FromWStringHack(base_dir), | 534 return UTF8ToWide(FixupRelativeFile(FilePath::FromWStringHack(base_dir), |
| 532 FilePath::FromWStringHack(text))); | 535 FilePath::FromWStringHack(text))); |
| 533 } | 536 } |
| OLD | NEW |