| Index: chrome/browser/autocomplete/autocomplete.cc
|
| ===================================================================
|
| --- chrome/browser/autocomplete/autocomplete.cc (revision 72382)
|
| +++ chrome/browser/autocomplete/autocomplete.cc (working copy)
|
| @@ -51,8 +51,8 @@
|
| synchronous_only_(false) {
|
| }
|
|
|
| -AutocompleteInput::AutocompleteInput(const string16& text,
|
| - const string16& desired_tld,
|
| +AutocompleteInput::AutocompleteInput(const std::wstring& text,
|
| + const std::wstring& desired_tld,
|
| bool prevent_inline_autocomplete,
|
| bool prefer_keyword,
|
| bool allow_exact_keyword_match,
|
| @@ -88,7 +88,7 @@
|
|
|
| // static
|
| void AutocompleteInput::RemoveForcedQueryStringIfNecessary(Type type,
|
| - string16* text) {
|
| + std::wstring* text) {
|
| if (type == FORCED_QUERY && !text->empty() && (*text)[0] == L'?')
|
| text->erase(0, 1);
|
| }
|
| @@ -111,13 +111,13 @@
|
|
|
| // static
|
| AutocompleteInput::Type AutocompleteInput::Parse(
|
| - const string16& text,
|
| - const string16& desired_tld,
|
| + const std::wstring& text,
|
| + const std::wstring& desired_tld,
|
| url_parse::Parsed* parts,
|
| - string16* scheme,
|
| + std::wstring* scheme,
|
| GURL* canonicalized_url) {
|
| - const size_t first_non_white = text.find_first_not_of(kWhitespaceUTF16, 0);
|
| - if (first_non_white == string16::npos)
|
| + const size_t first_non_white = text.find_first_not_of(kWhitespaceWide, 0);
|
| + if (first_non_white == std::wstring::npos)
|
| return INVALID; // All whitespace.
|
|
|
| if (text.at(first_non_white) == L'?') {
|
| @@ -133,15 +133,15 @@
|
| url_parse::Parsed local_parts;
|
| if (!parts)
|
| parts = &local_parts;
|
| - const string16 parsed_scheme(URLFixerUpper::SegmentURL(text, parts));
|
| + const std::wstring parsed_scheme(URLFixerUpper::SegmentURL(text, parts));
|
| if (scheme)
|
| *scheme = parsed_scheme;
|
| if (canonicalized_url) {
|
| - *canonicalized_url = URLFixerUpper::FixupURL(UTF16ToUTF8(text),
|
| - UTF16ToUTF8(desired_tld));
|
| + *canonicalized_url = URLFixerUpper::FixupURL(WideToUTF8(text),
|
| + WideToUTF8(desired_tld));
|
| }
|
|
|
| - if (LowerCaseEqualsASCII(parsed_scheme, chrome::kFileScheme)) {
|
| + if (parsed_scheme == L"file") {
|
| // A user might or might not type a scheme when entering a file URL. In
|
| // either case, |parsed_scheme| will tell us that this is a file URL, but
|
| // |parts->scheme| might be empty, e.g. if the user typed "C:\foo".
|
| @@ -155,10 +155,9 @@
|
| // (e.g. "ftp" or "view-source") but I'll wait to spend the effort on that
|
| // until I run into some cases that really need it.
|
| if (parts->scheme.is_nonempty() &&
|
| - !LowerCaseEqualsASCII(parsed_scheme, chrome::kHttpScheme) &&
|
| - !LowerCaseEqualsASCII(parsed_scheme, chrome::kHttpsScheme)) {
|
| + (parsed_scheme != L"http") && (parsed_scheme != L"https")) {
|
| // See if we know how to handle the URL internally.
|
| - if (net::URLRequest::IsHandledProtocol(UTF16ToASCII(parsed_scheme)))
|
| + if (net::URLRequest::IsHandledProtocol(WideToASCII(parsed_scheme)))
|
| return URL;
|
|
|
| // There are also some schemes that we convert to other things before they
|
| @@ -176,9 +175,7 @@
|
| // "blocked" by the external protocol handler because we don't want pages to
|
| // open them, but users still can.
|
| // TODO(viettrungluu): get rid of conversion.
|
| - ExternalProtocolHandler::BlockState block_state =
|
| - ExternalProtocolHandler::GetBlockState(UTF16ToUTF8(parsed_scheme));
|
| - switch (block_state) {
|
| + switch (ExternalProtocolHandler::GetBlockState(WideToUTF8(parsed_scheme))) {
|
| case ExternalProtocolHandler::DONT_BLOCK:
|
| return URL;
|
|
|
| @@ -190,16 +187,14 @@
|
| default: {
|
| // We don't know about this scheme. It might be that the user typed a
|
| // URL of the form "username:password@foo.com".
|
| - const string16 http_scheme_prefix =
|
| - ASCIIToUTF16(std::string(chrome::kHttpScheme) +
|
| - chrome::kStandardSchemeSeparator);
|
| + const std::wstring http_scheme_prefix = L"http://";
|
| url_parse::Parsed http_parts;
|
| - string16 http_scheme;
|
| + std::wstring http_scheme;
|
| GURL http_canonicalized_url;
|
| Type http_type = Parse(http_scheme_prefix + text, desired_tld,
|
| &http_parts, &http_scheme,
|
| &http_canonicalized_url);
|
| - DCHECK_EQ(std::string(chrome::kHttpScheme), UTF16ToUTF8(http_scheme));
|
| + DCHECK_EQ("http", WideToUTF8(http_scheme));
|
|
|
| if ((http_type == URL || http_type == REQUESTED_URL) &&
|
| http_parts.username.is_nonempty() &&
|
| @@ -251,19 +246,18 @@
|
|
|
| // Likewise, the RCDS can reject certain obviously-invalid hosts. (We also
|
| // use the registry length later below.)
|
| - const string16 host(text.substr(parts->host.begin, parts->host.len));
|
| + const std::wstring host(text.substr(parts->host.begin, parts->host.len));
|
| const size_t registry_length =
|
| - net::RegistryControlledDomainService::GetRegistryLength(UTF16ToUTF8(host),
|
| - false);
|
| - if (registry_length == std::string::npos) {
|
| + net::RegistryControlledDomainService::GetRegistryLength(host, false);
|
| + if (registry_length == std::wstring::npos) {
|
| // Try to append the desired_tld.
|
| if (!desired_tld.empty()) {
|
| - string16 host_with_tld(host);
|
| + std::wstring host_with_tld(host);
|
| if (host[host.length() - 1] != '.')
|
| host_with_tld += '.';
|
| host_with_tld += desired_tld;
|
| if (net::RegistryControlledDomainService::GetRegistryLength(
|
| - UTF16ToUTF8(host_with_tld), false) != std::string::npos)
|
| + host_with_tld, false) != std::wstring::npos)
|
| return REQUESTED_URL; // Something like "99999999999" that looks like a
|
| // bad IP address, but becomes valid on attaching
|
| // a TLD.
|
| @@ -277,11 +271,10 @@
|
| // unlikely that a user would be trying to type those in for anything other
|
| // than a search query.
|
| url_canon::CanonHostInfo host_info;
|
| - const std::string canonicalized_host(net::CanonicalizeHost(UTF16ToUTF8(host),
|
| - &host_info));
|
| + const std::string canonicalized_host(net::CanonicalizeHost(host, &host_info));
|
| if ((host_info.family == url_canon::CanonHostInfo::NEUTRAL) &&
|
| !net::IsCanonicalizedHostCompliant(canonicalized_host,
|
| - UTF16ToUTF8(desired_tld))) {
|
| + WideToUTF8(desired_tld))) {
|
| // Invalid hostname. There are several possible cases:
|
| // * Our checker is too strict and the user pasted in a real-world URL
|
| // that's "invalid" but resolves. To catch these, we return UNKNOWN when
|
| @@ -301,7 +294,7 @@
|
| // TLD
|
| // These are rare, though probably possible in intranets.
|
| return (parts->scheme.is_nonempty() ||
|
| - ((registry_length != 0) && (host.find(' ') == string16::npos))) ?
|
| + ((registry_length != 0) && (host.find(' ') == std::wstring::npos))) ?
|
| UNKNOWN : QUERY;
|
| }
|
|
|
| @@ -313,8 +306,8 @@
|
| // below.
|
| if (parts->port.is_nonempty()) {
|
| int port;
|
| - if (!base::StringToInt(text.substr(parts->port.begin, parts->port.len),
|
| - &port) ||
|
| + if (!base::StringToInt(WideToUTF8(
|
| + text.substr(parts->port.begin, parts->port.len)), &port) ||
|
| (port < 0) || (port > 65535))
|
| return QUERY;
|
| }
|
| @@ -363,7 +356,7 @@
|
| // since that's the common case.
|
| return ((registry_length == 0) &&
|
| (text.substr(parts->path.begin, parts->path.len).find(' ') !=
|
| - string16::npos)) ? UNKNOWN : URL;
|
| + std::wstring::npos)) ? UNKNOWN : URL;
|
| }
|
|
|
| // If we reach here with a username, our input looks like "user@host".
|
| @@ -399,12 +392,12 @@
|
|
|
| // static
|
| void AutocompleteInput::ParseForEmphasizeComponents(
|
| - const string16& text,
|
| - const string16& desired_tld,
|
| + const std::wstring& text,
|
| + const std::wstring& desired_tld,
|
| url_parse::Component* scheme,
|
| url_parse::Component* host) {
|
| url_parse::Parsed parts;
|
| - string16 scheme_str;
|
| + std::wstring scheme_str;
|
| Parse(text, desired_tld, &parts, &scheme_str, NULL);
|
|
|
| *scheme = parts.scheme;
|
| @@ -416,7 +409,7 @@
|
| if (LowerCaseEqualsASCII(scheme_str, chrome::kViewSourceScheme) &&
|
| (static_cast<int>(text.length()) > after_scheme_and_colon)) {
|
| // Obtain the URL prefixed by view-source and parse it.
|
| - string16 real_url(text.substr(after_scheme_and_colon));
|
| + std::wstring real_url(text.substr(after_scheme_and_colon));
|
| url_parse::Parsed real_parts;
|
| AutocompleteInput::Parse(real_url, desired_tld, &real_parts, NULL, NULL);
|
| if (real_parts.scheme.is_nonempty() || real_parts.host.is_nonempty()) {
|
| @@ -439,15 +432,15 @@
|
| }
|
|
|
| // static
|
| -string16 AutocompleteInput::FormattedStringWithEquivalentMeaning(
|
| +std::wstring AutocompleteInput::FormattedStringWithEquivalentMeaning(
|
| const GURL& url,
|
| - const string16& formatted_url) {
|
| + const std::wstring& formatted_url) {
|
| if (!net::CanStripTrailingSlash(url))
|
| return formatted_url;
|
| - const string16 url_with_path(formatted_url + char16('/'));
|
| - return (AutocompleteInput::Parse(formatted_url, string16(), NULL, NULL,
|
| + const std::wstring url_with_path(formatted_url + L"/");
|
| + return (AutocompleteInput::Parse(formatted_url, std::wstring(), NULL, NULL,
|
| NULL) ==
|
| - AutocompleteInput::Parse(url_with_path, string16(), NULL, NULL,
|
| + AutocompleteInput::Parse(url_with_path, std::wstring(), NULL, NULL,
|
| NULL)) ?
|
| formatted_url : url_with_path;
|
| }
|
| @@ -508,8 +501,8 @@
|
| }
|
|
|
| // static
|
| -bool AutocompleteProvider::HasHTTPScheme(const string16& input) {
|
| - std::string utf8_input(UTF16ToUTF8(input));
|
| +bool AutocompleteProvider::HasHTTPScheme(const std::wstring& input) {
|
| + std::string utf8_input(WideToUTF8(input));
|
| url_parse::Component scheme;
|
| if (url_util::FindAndCompareScheme(utf8_input, chrome::kViewSourceScheme,
|
| &scheme))
|
| @@ -531,16 +524,16 @@
|
| i->starred = bookmark_model->IsBookmarked(GURL(i->destination_url));
|
| }
|
|
|
| -string16 AutocompleteProvider::StringForURLDisplay(const GURL& url,
|
| - bool check_accept_lang,
|
| - bool trim_http) const {
|
| +std::wstring AutocompleteProvider::StringForURLDisplay(const GURL& url,
|
| + bool check_accept_lang,
|
| + bool trim_http) const {
|
| std::string languages = (check_accept_lang && profile_) ?
|
| profile_->GetPrefs()->GetString(prefs::kAcceptLanguages) : std::string();
|
| - return net::FormatUrl(
|
| + return UTF16ToWideHack(net::FormatUrl(
|
| url,
|
| languages,
|
| net::kFormatUrlOmitAll & ~(trim_http ? 0 : net::kFormatUrlOmitHTTP),
|
| - UnescapeRule::SPACES, NULL, NULL, NULL);
|
| + UnescapeRule::SPACES, NULL, NULL, NULL));
|
| }
|
|
|
| // AutocompleteResult ---------------------------------------------------------
|
| @@ -720,13 +713,13 @@
|
| // different profile.
|
| }
|
|
|
| -void AutocompleteController::Start(const string16& text,
|
| - const string16& desired_tld,
|
| +void AutocompleteController::Start(const std::wstring& text,
|
| + const std::wstring& desired_tld,
|
| bool prevent_inline_autocomplete,
|
| bool prefer_keyword,
|
| bool allow_exact_keyword_match,
|
| bool synchronous_only) {
|
| - const string16 old_input_text(input_.text());
|
| + const std::wstring old_input_text(input_.text());
|
| const bool old_synchronous_only = input_.synchronous_only();
|
| input_ = AutocompleteInput(text, desired_tld, prevent_inline_autocomplete,
|
| prefer_keyword, allow_exact_keyword_match, synchronous_only);
|
|
|