OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/autocomplete/autocomplete_input.h" | 5 #include "chrome/browser/autocomplete/autocomplete_input.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/external_protocol/external_protocol_handler.h" | 9 #include "chrome/browser/external_protocol/external_protocol_handler.h" |
10 #include "chrome/browser/net/url_fixer_upper.h" | 10 #include "chrome/browser/net/url_fixer_upper.h" |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 // case we should reject invalid formulations. | 259 // case we should reject invalid formulations. |
260 | 260 |
261 // If we have an empty host it can't be a URL. | 261 // If we have an empty host it can't be a URL. |
262 if (!parts->host.is_nonempty()) | 262 if (!parts->host.is_nonempty()) |
263 return QUERY; | 263 return QUERY; |
264 | 264 |
265 // Likewise, the RCDS can reject certain obviously-invalid hosts. (We also | 265 // Likewise, the RCDS can reject certain obviously-invalid hosts. (We also |
266 // use the registry length later below.) | 266 // use the registry length later below.) |
267 const string16 host(text.substr(parts->host.begin, parts->host.len)); | 267 const string16 host(text.substr(parts->host.begin, parts->host.len)); |
268 const size_t registry_length = | 268 const size_t registry_length = |
269 net::RegistryControlledDomainService::GetRegistryLength(UTF16ToUTF8(host), | 269 net::registry_controlled_domains::GetRegistryLength( |
270 false); | 270 UTF16ToUTF8(host), |
| 271 net::registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES, |
| 272 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); |
271 if (registry_length == std::string::npos) { | 273 if (registry_length == std::string::npos) { |
272 // Try to append the desired_tld. | 274 // Try to append the desired_tld. |
273 if (!desired_tld.empty()) { | 275 if (!desired_tld.empty()) { |
274 string16 host_with_tld(host); | 276 string16 host_with_tld(host); |
275 if (host[host.length() - 1] != '.') | 277 if (host[host.length() - 1] != '.') |
276 host_with_tld += '.'; | 278 host_with_tld += '.'; |
277 host_with_tld += desired_tld; | 279 host_with_tld += desired_tld; |
278 if (net::RegistryControlledDomainService::GetRegistryLength( | 280 const size_t tld_length = |
279 UTF16ToUTF8(host_with_tld), false) != std::string::npos) | 281 net::registry_controlled_domains::GetRegistryLength( |
| 282 UTF16ToUTF8(host_with_tld), |
| 283 net::registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES, |
| 284 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); |
| 285 if (tld_length != std::string::npos) |
280 return URL; // Something like "99999999999" that looks like a bad IP | 286 return URL; // Something like "99999999999" that looks like a bad IP |
281 // address, but becomes valid on attaching a TLD. | 287 // address, but becomes valid on attaching a TLD. |
282 } | 288 } |
283 return QUERY; // Could be a broken IP address, etc. | 289 return QUERY; // Could be a broken IP address, etc. |
284 } | 290 } |
285 | 291 |
286 | 292 |
287 // See if the hostname is valid. While IE and GURL allow hostnames to contain | 293 // See if the hostname is valid. While IE and GURL allow hostnames to contain |
288 // many other characters (perhaps for weird intranet machines), it's extremely | 294 // many other characters (perhaps for weird intranet machines), it's extremely |
289 // unlikely that a user would be trying to type those in for anything other | 295 // unlikely that a user would be trying to type those in for anything other |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 current_url_ = GURL(); | 509 current_url_ = GURL(); |
504 type_ = INVALID; | 510 type_ = INVALID; |
505 parts_ = url_parse::Parsed(); | 511 parts_ = url_parse::Parsed(); |
506 scheme_.clear(); | 512 scheme_.clear(); |
507 canonicalized_url_ = GURL(); | 513 canonicalized_url_ = GURL(); |
508 prevent_inline_autocomplete_ = false; | 514 prevent_inline_autocomplete_ = false; |
509 prefer_keyword_ = false; | 515 prefer_keyword_ = false; |
510 allow_exact_keyword_match_ = false; | 516 allow_exact_keyword_match_ = false; |
511 matches_requested_ = ALL_MATCHES; | 517 matches_requested_ = ALL_MATCHES; |
512 } | 518 } |
OLD | NEW |