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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 OffsetComponent(offset, &parts->path); | 353 OffsetComponent(offset, &parts->path); |
354 OffsetComponent(offset, &parts->query); | 354 OffsetComponent(offset, &parts->query); |
355 OffsetComponent(offset, &parts->ref); | 355 OffsetComponent(offset, &parts->ref); |
356 | 356 |
357 return scheme; | 357 return scheme; |
358 } | 358 } |
359 | 359 |
360 string URLFixerUpper::FixupURL(const string& text, | 360 string URLFixerUpper::FixupURL(const string& text, |
361 const string& desired_tld) { | 361 const string& desired_tld) { |
362 string trimmed; | 362 string trimmed; |
363 TrimWhitespace(text, TRIM_ALL, &trimmed); | 363 TrimWhitespaceUTF8(text, TRIM_ALL, &trimmed); |
364 if (trimmed.empty()) | 364 if (trimmed.empty()) |
365 return string(); // Nothing here. | 365 return string(); // Nothing here. |
366 | 366 |
367 // Segment the URL. | 367 // Segment the URL. |
368 url_parse::Parsed parts; | 368 url_parse::Parsed parts; |
369 string scheme(SegmentURL(trimmed, &parts)); | 369 string scheme(SegmentURL(trimmed, &parts)); |
370 | 370 |
371 // We handle the file scheme separately. | 371 // We handle the file scheme separately. |
372 if (scheme == "file") | 372 if (scheme == "file") |
373 return (parts.scheme.is_valid() ? text : FixupPath(text)); | 373 return (parts.scheme.is_valid() ? text : FixupPath(text)); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 } | 473 } |
474 wstring URLFixerUpper::FixupURL(const wstring& text, | 474 wstring URLFixerUpper::FixupURL(const wstring& text, |
475 const wstring& desired_tld) { | 475 const wstring& desired_tld) { |
476 return UTF8ToWide(FixupURL(WideToUTF8(text), WideToUTF8(desired_tld))); | 476 return UTF8ToWide(FixupURL(WideToUTF8(text), WideToUTF8(desired_tld))); |
477 } | 477 } |
478 wstring URLFixerUpper::FixupRelativeFile(const wstring& base_dir, | 478 wstring URLFixerUpper::FixupRelativeFile(const wstring& base_dir, |
479 const wstring& text) { | 479 const wstring& text) { |
480 return UTF8ToWide(FixupRelativeFile(FilePath::FromWStringHack(base_dir), | 480 return UTF8ToWide(FixupRelativeFile(FilePath::FromWStringHack(base_dir), |
481 FilePath::FromWStringHack(text))); | 481 FilePath::FromWStringHack(text))); |
482 } | 482 } |
OLD | NEW |