diff options
author | abarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-18 01:25:25 +0000 |
---|---|---|
committer | abarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-18 01:25:25 +0000 |
commit | 818071ce86a5860d65cc97cfc82e2639a4f328a2 (patch) | |
tree | adea656297a7d5e819a4ec4fa2afa91ef20fd23a /chrome/browser/autocomplete | |
parent | 46f6f38fefe5bfca416518b99179cc3bc2ed68ac (diff) | |
download | chromium_src-818071ce86a5860d65cc97cfc82e2639a4f328a2.zip chromium_src-818071ce86a5860d65cc97cfc82e2639a4f328a2.tar.gz chromium_src-818071ce86a5860d65cc97cfc82e2639a4f328a2.tar.bz2 |
Allow IPv6 literals to be typed directly into the address bar, without
requiring a preceding http://. The square brackets are still needed, though.
Fix some of the style problems in url_fixer_upper.cc:
- Multi-line if should have {}s
- "using namespace" is bad.
Patch by pmarks@google.com.
R=abarth
TEST=New unit tests.
http://codereview.chromium.org/113509
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16267 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete')
-rw-r--r-- | chrome/browser/autocomplete/autocomplete.cc | 6 | ||||
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_unittest.cc | 4 |
2 files changed, 9 insertions, 1 deletions
diff --git a/chrome/browser/autocomplete/autocomplete.cc b/chrome/browser/autocomplete/autocomplete.cc index 4b9db4e..65f71c4 100644 --- a/chrome/browser/autocomplete/autocomplete.cc +++ b/chrome/browser/autocomplete/autocomplete.cc @@ -181,8 +181,12 @@ AutocompleteInput::Type AutocompleteInput::Parse( // See if the host is an IP address. bool is_ip_address; - net::CanonicalizeHost(host, &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; + // 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 diff --git a/chrome/browser/autocomplete/autocomplete_unittest.cc b/chrome/browser/autocomplete/autocomplete_unittest.cc index 6cdd646..e7fdd4c 100644 --- a/chrome/browser/autocomplete/autocomplete_unittest.cc +++ b/chrome/browser/autocomplete/autocomplete_unittest.cc @@ -233,8 +233,12 @@ TEST(AutocompleteTest, InputType) { #endif // defined(OS_WIN) { L"http://foo.com/", AutocompleteInput::URL }, { L"127.0.0.1", AutocompleteInput::URL }, + { L"127.0.1", AutocompleteInput::UNKNOWN }, + { L"127.0.1/", AutocompleteInput::UNKNOWN }, { L"browser.tabs.closeButtons", AutocompleteInput::UNKNOWN }, { L"\u6d4b\u8bd5", AutocompleteInput::UNKNOWN }, + { L"[2001:]", AutocompleteInput::QUERY }, // Not a valid IP + { L"[2001:dB8::1]", AutocompleteInput::URL }, }; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(input_cases); ++i) { |