diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-25 15:23:36 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-25 15:23:36 +0000 |
commit | a2fedb1e1311bc6acffabebc03e8dbca761b385e (patch) | |
tree | 6c7e7970bb476b8ac4ec402c721e83fb3f425db4 /chrome/browser/net | |
parent | f5b0d12e8a294f748e2800dda141cbb664afb111 (diff) | |
download | chromium_src-a2fedb1e1311bc6acffabebc03e8dbca761b385e.zip chromium_src-a2fedb1e1311bc6acffabebc03e8dbca761b385e.tar.gz chromium_src-a2fedb1e1311bc6acffabebc03e8dbca761b385e.tar.bz2 |
Remove wstring from autocomplete.
Recommit of r72380.
BUG=23581
TEST=no visible changes; all tests pass
Review URL: http://codereview.chromium.org/6306011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72492 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net')
-rw-r--r-- | chrome/browser/net/url_fixer_upper.cc | 54 | ||||
-rw-r--r-- | chrome/browser/net/url_fixer_upper.h | 6 |
2 files changed, 59 insertions, 1 deletions
diff --git a/chrome/browser/net/url_fixer_upper.cc b/chrome/browser/net/url_fixer_upper.cc index 4c36368..07881a4 100644 --- a/chrome/browser/net/url_fixer_upper.cc +++ b/chrome/browser/net/url_fixer_upper.cc @@ -72,6 +72,50 @@ void UTF8PartsToWideParts(const std::string& text_utf8, parts->ref = UTF8ComponentToWideComponent(text_utf8, parts_utf8.ref); } +#if defined(WCHAR_T_IS_UTF32) +url_parse::Component UTF8ComponentToUTF16Component( + const std::string& text_utf8, + const url_parse::Component& component_utf8) { + if (component_utf8.len == -1) + return url_parse::Component(); + + std::string before_component_string = + text_utf8.substr(0, component_utf8.begin); + std::string component_string = text_utf8.substr(component_utf8.begin, + component_utf8.len); + string16 before_component_string_16 = UTF8ToUTF16(before_component_string); + string16 component_string_16 = UTF8ToUTF16(component_string); + url_parse::Component component_16(before_component_string_16.length(), + component_string_16.length()); + return component_16; +} + +void UTF8PartsToUTF16Parts(const std::string& text_utf8, + const url_parse::Parsed& parts_utf8, + url_parse::Parsed* parts) { + if (IsStringASCII(text_utf8)) { + *parts = parts_utf8; + return; + } + + parts->scheme = + UTF8ComponentToUTF16Component(text_utf8, parts_utf8.scheme); + parts ->username = + UTF8ComponentToUTF16Component(text_utf8, parts_utf8.username); + parts->password = + UTF8ComponentToUTF16Component(text_utf8, parts_utf8.password); + parts->host = + UTF8ComponentToUTF16Component(text_utf8, parts_utf8.host); + parts->port = + UTF8ComponentToUTF16Component(text_utf8, parts_utf8.port); + parts->path = + UTF8ComponentToUTF16Component(text_utf8, parts_utf8.path); + parts->query = + UTF8ComponentToUTF16Component(text_utf8, parts_utf8.query); + parts->ref = + UTF8ComponentToUTF16Component(text_utf8, parts_utf8.ref); +} +#endif TrimPositions TrimWhitespaceUTF8(const std::string& input, TrimPositions positions, @@ -581,6 +625,16 @@ std::wstring URLFixerUpper::SegmentURL(const std::wstring& text, UTF8PartsToWideParts(text_utf8, parts_utf8, parts); return UTF8ToWide(scheme_utf8); } +#if defined(WCHAR_T_IS_UTF32) +string16 URLFixerUpper::SegmentURL(const string16& text, + url_parse::Parsed* parts) { + std::string text_utf8 = UTF16ToUTF8(text); + url_parse::Parsed parts_utf8; + std::string scheme_utf8 = SegmentURL(text_utf8, &parts_utf8); + UTF8PartsToUTF16Parts(text_utf8, parts_utf8, parts); + return UTF8ToUTF16(scheme_utf8); +} +#endif GURL URLFixerUpper::FixupRelativeFile(const std::wstring& base_dir, const std::wstring& text) { return FixupRelativeFile(FilePath::FromWStringHack(base_dir), diff --git a/chrome/browser/net/url_fixer_upper.h b/chrome/browser/net/url_fixer_upper.h index 9f5beb5..fa5ba1b 100644 --- a/chrome/browser/net/url_fixer_upper.h +++ b/chrome/browser/net/url_fixer_upper.h @@ -8,6 +8,7 @@ #include <string> +#include "base/string16.h" #include "googleurl/src/gurl.h" namespace url_parse { @@ -29,8 +30,11 @@ namespace URLFixerUpper { // Returns the canonicalized scheme, or the empty string when |text| is only // whitespace. std::string SegmentURL(const std::string& text, url_parse::Parsed* parts); - // Deprecated temporary compatibility function. + // Deprecated temporary compatibility functions. std::wstring SegmentURL(const std::wstring& text, url_parse::Parsed* parts); +#if defined(WCHAR_T_IS_UTF32) + string16 SegmentURL(const string16& text, url_parse::Parsed* parts); +#endif // Converts |text| to a fixed-up URL and returns it. Attempts to make // some "smart" adjustments to obviously-invalid input where possible. |