OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.h" | 5 #include "chrome/browser/autocomplete/autocomplete.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 if ((c == '\\') || (c == '/')) | 364 if ((c == '\\') || (c == '/')) |
365 return URL; | 365 return URL; |
366 } | 366 } |
367 | 367 |
368 // If there is more than one recognized non-host component, this is likely to | 368 // If there is more than one recognized non-host component, this is likely to |
369 // be a URL, even if the TLD is unknown (in which case this is likely an | 369 // be a URL, even if the TLD is unknown (in which case this is likely an |
370 // intranet URL). | 370 // intranet URL). |
371 if (NumNonHostComponents(*parts) > 1) | 371 if (NumNonHostComponents(*parts) > 1) |
372 return URL; | 372 return URL; |
373 | 373 |
374 // If the host has a known TLD, it's probably a URL, with the following | 374 // If the host has a known TLD or a port, it's probably a URL, with the |
375 // exceptions: | 375 // following exceptions: |
376 // * Any "IP addresses" that make it here are more likely searches | 376 // * Any "IP addresses" that make it here are more likely searches |
377 // (see above). | 377 // (see above). |
378 // * If we reach here with a username, our input looks like "user@host[.tld]". | 378 // * If we reach here with a username, our input looks like "user@host[.tld]". |
379 // Because there is no scheme explicitly specified, we think this is more | 379 // Because there is no scheme explicitly specified, we think this is more |
380 // likely an email address than an HTTP auth attempt. Hence, we search by | 380 // likely an email address than an HTTP auth attempt. Hence, we search by |
381 // default and let users correct us on a case-by-case basis. | 381 // default and let users correct us on a case-by-case basis. |
382 // Note that we special-case "localhost" as a known hostname. | 382 // Note that we special-case "localhost" as a known hostname. |
383 if ((host_info.family != url_canon::CanonHostInfo::IPV4) && | 383 if ((host_info.family != url_canon::CanonHostInfo::IPV4) && |
384 ((registry_length != 0) || (host == ASCIIToUTF16("localhost")))) | 384 ((registry_length != 0) || (host == ASCIIToUTF16("localhost") || |
| 385 parts->port.is_nonempty()))) |
385 return parts->username.is_nonempty() ? UNKNOWN : URL; | 386 return parts->username.is_nonempty() ? UNKNOWN : URL; |
386 | 387 |
387 // If we reach this point, we know there's no known TLD on the input, so if | 388 // If we reach this point, we know there's no known TLD on the input, so if |
388 // the user wishes to add a desired_tld, the fixup code will oblige; thus this | 389 // the user wishes to add a desired_tld, the fixup code will oblige; thus this |
389 // is a URL. | 390 // is a URL. |
390 if (!desired_tld.empty()) | 391 if (!desired_tld.empty()) |
391 return REQUESTED_URL; | 392 return REQUESTED_URL; |
392 | 393 |
393 // No scheme, password, port, path, and no known TLD on the host. | 394 // No scheme, password, port, path, and no known TLD on the host. |
394 // This could be: | 395 // This could be: |
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1056 } | 1057 } |
1057 done_ = true; | 1058 done_ = true; |
1058 } | 1059 } |
1059 | 1060 |
1060 void AutocompleteController::StartExpireTimer() { | 1061 void AutocompleteController::StartExpireTimer() { |
1061 if (result_.HasCopiedMatches()) | 1062 if (result_.HasCopiedMatches()) |
1062 expire_timer_.Start(FROM_HERE, | 1063 expire_timer_.Start(FROM_HERE, |
1063 base::TimeDelta::FromMilliseconds(kExpireTimeMS), | 1064 base::TimeDelta::FromMilliseconds(kExpireTimeMS), |
1064 this, &AutocompleteController::ExpireCopiedEntries); | 1065 this, &AutocompleteController::ExpireCopiedEntries); |
1065 } | 1066 } |
OLD | NEW |