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

Side by Side Diff: chrome/browser/net/url_fixer_upper.cc

Issue 66010: Merge 13388 - Properly handle empty components when converting url_parse::Par... (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/branches/172/src/
Patch Set: Created 11 years, 8 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 | « chrome/browser/autocomplete/autocomplete_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698