| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/omnibox/browser/autocomplete_input.h" | 5 #include "components/omnibox/browser/autocomplete_input.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/strings/string_split.h" | 8 #include "base/strings/string_split.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 // the option of treating it as a URL if we're wrong. | 247 // the option of treating it as a URL if we're wrong. |
| 248 // Note that SegmentURL() is smart so we aren't tricked by "c:\foo" or | 248 // Note that SegmentURL() is smart so we aren't tricked by "c:\foo" or |
| 249 // "www.example.com:81" in this case. | 249 // "www.example.com:81" in this case. |
| 250 return metrics::OmniboxInputType::UNKNOWN; | 250 return metrics::OmniboxInputType::UNKNOWN; |
| 251 } | 251 } |
| 252 | 252 |
| 253 // Either the user didn't type a scheme, in which case we need to distinguish | 253 // Either the user didn't type a scheme, in which case we need to distinguish |
| 254 // between an HTTP URL and a query, or the scheme is HTTP or HTTPS, in which | 254 // between an HTTP URL and a query, or the scheme is HTTP or HTTPS, in which |
| 255 // case we should reject invalid formulations. | 255 // case we should reject invalid formulations. |
| 256 | 256 |
| 257 // If we have an empty host it can't be a valid HTTP[S] URL. (This should | |
| 258 // only trigger for input that begins with a colon, which GURL will parse as a | |
| 259 // valid, non-standard URL; for standard URLs, an empty host would have | |
| 260 // resulted in an invalid |canonicalized_url| above.) | |
| 261 if (!canonicalized_url->has_host()) | |
| 262 return metrics::OmniboxInputType::QUERY; | |
| 263 | |
| 264 // Determine the host family. We get this information by (re-)canonicalizing | 257 // Determine the host family. We get this information by (re-)canonicalizing |
| 265 // the already-canonicalized host rather than using the user's original input, | 258 // the already-canonicalized host rather than using the user's original input, |
| 266 // in case fixup affected the result here (e.g. an input that looks like an | 259 // in case fixup affected the result here (e.g. an input that looks like an |
| 267 // IPv4 address but with a non-empty desired TLD would return IPV4 before | 260 // IPv4 address but with a non-empty desired TLD would return IPV4 before |
| 268 // fixup and NEUTRAL afterwards, and we want to treat it as NEUTRAL). | 261 // fixup and NEUTRAL afterwards, and we want to treat it as NEUTRAL). |
| 269 url::CanonHostInfo host_info; | 262 url::CanonHostInfo host_info; |
| 270 net::CanonicalizeHost(canonicalized_url->host(), &host_info); | 263 net::CanonicalizeHost(canonicalized_url->host(), &host_info); |
| 271 | 264 |
| 272 // Check if the canonicalized host has a known TLD, which we'll want to know | 265 // Check if the canonicalized host has a known TLD, which we'll want to know |
| 273 // below. | 266 // below. |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 parts_ = url::Parsed(); | 519 parts_ = url::Parsed(); |
| 527 scheme_.clear(); | 520 scheme_.clear(); |
| 528 canonicalized_url_ = GURL(); | 521 canonicalized_url_ = GURL(); |
| 529 prevent_inline_autocomplete_ = false; | 522 prevent_inline_autocomplete_ = false; |
| 530 prefer_keyword_ = false; | 523 prefer_keyword_ = false; |
| 531 allow_exact_keyword_match_ = false; | 524 allow_exact_keyword_match_ = false; |
| 532 want_asynchronous_matches_ = true; | 525 want_asynchronous_matches_ = true; |
| 533 from_omnibox_focus_ = false; | 526 from_omnibox_focus_ = false; |
| 534 terms_prefixed_by_http_or_https_.clear(); | 527 terms_prefixed_by_http_or_https_.clear(); |
| 535 } | 528 } |
| OLD | NEW |