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

Unified Diff: chrome/browser/autocomplete/autocomplete.cc

Issue 113944: Use the new CanonicalizeHostVerbose() function. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: is_valid -> is_nonempty Created 11 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « DEPS ('k') | chrome/browser/autocomplete/autocomplete_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autocomplete/autocomplete.cc
===================================================================
--- chrome/browser/autocomplete/autocomplete.cc (revision 19036)
+++ chrome/browser/autocomplete/autocomplete.cc (working copy)
@@ -164,7 +164,7 @@
const size_t registry_length =
net::RegistryControlledDomainService::GetRegistryLength(host, false);
if (registry_length == std::wstring::npos)
- return QUERY; // It's not clear to me that we can reach this...
+ return QUERY; // Could be a broken IP address, etc.
// A space in the "host" means this is a query. (Technically, IE and GURL
// allow hostnames with spaces for wierd intranet machines, but it's supposed
@@ -180,27 +180,21 @@
return URL;
// See if the host is an IP address.
- bool is_ip_address;
- const std::string canon_host(net::CanonicalizeHost(host, &is_ip_address));
- if (is_ip_address) {
- // If the user typed a valid IPv6 address, treat it as a URL.
- if (canon_host[0] == '[')
- return URL;
-
+ url_canon::CanonHostInfo host_info;
+ net::CanonicalizeHost(host, &host_info);
+ if (host_info.family == url_canon::CanonHostInfo::IPV4) {
// If the user originally typed a host that looks like an IP address (a
// dotted quad), they probably want to open it. If the original input was
// something else (like a single number), they probably wanted to search for
// it. This is true even if the URL appears to have a path: "1.2/45" is
// more likely a search (for the answer to a math problem) than a URL.
- url_parse::Component components[4];
- const bool found_ipv4 =
- url_canon::FindIPv4Components(WideToUTF8(text).c_str(),
- parts->host, components);
- DCHECK(found_ipv4);
- for (size_t i = 0; i < arraysize(components); ++i) {
- if (!components[i].is_nonempty())
- return desired_tld.empty() ? UNKNOWN : REQUESTED_URL;
- }
+ if (host_info.num_ipv4_components == 4)
+ return URL;
+ return desired_tld.empty() ? UNKNOWN : REQUESTED_URL;
+ }
+
+ if (host_info.family == url_canon::CanonHostInfo::IPV6) {
+ // If the user typed a valid bracketed IPv6 address, treat it as a URL.
return URL;
}
« no previous file with comments | « DEPS ('k') | chrome/browser/autocomplete/autocomplete_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698