diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-19 02:45:05 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-19 02:45:05 +0000 |
commit | a2d2e2f9de8dad20f28734486cadcd3c03e45bfa (patch) | |
tree | faf6efa06a03b9da2369592bcb89f0b3382dd516 /chrome/browser/autocomplete | |
parent | 0e6d0b4250e3d5e6925d2c84fa640a06ce5787a6 (diff) | |
download | chromium_src-a2d2e2f9de8dad20f28734486cadcd3c03e45bfa.zip chromium_src-a2d2e2f9de8dad20f28734486cadcd3c03e45bfa.tar.gz chromium_src-a2d2e2f9de8dad20f28734486cadcd3c03e45bfa.tar.bz2 |
Correctly score intranet URLs with typed_counts of 0 as UNVISITED_INTRANET if they are on known hostnames.
BUG=103470
TEST=On a clean profile, type an intranet host (e.g. "go/") and hit enter; then paste a different address on that host (e.g. "go/shuttlealerts") and hit enter; then in a new tab, paste that second address again and verify that the default action is to navigate rather than search.
Review URL: http://codereview.chromium.org/8497050
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110820 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete')
-rw-r--r-- | chrome/browser/autocomplete/history_url_provider.cc | 18 | ||||
-rw-r--r-- | chrome/browser/autocomplete/history_url_provider_unittest.cc | 15 |
2 files changed, 20 insertions, 13 deletions
diff --git a/chrome/browser/autocomplete/history_url_provider.cc b/chrome/browser/autocomplete/history_url_provider.cc index cbbfb0e..692587b 100644 --- a/chrome/browser/autocomplete/history_url_provider.cc +++ b/chrome/browser/autocomplete/history_url_provider.cc @@ -705,13 +705,12 @@ bool HistoryURLProvider::FixupExactSuggestion( ACMatchClassification::NONE, &match->description_class); if (!classifier.url_row().typed_count()) { // If we reach here, we must be in the second pass, and we must not have - // promoted this match as an exact match during the first pass. That - // means it will have been outscored by the "search what you typed - // match". We need to maintain that ordering in order to not make the - // destination for the user's typing change depending on when they hit - // enter. So lower the score here enough to let the search provider - // continue to outscore this match. - type = WHAT_YOU_TYPED; + // this row's data available during the first pass. That means we + // either scored it as WHAT_YOU_TYPED or UNVISITED_INTRANET, and to + // maintain the ordering between passes consistent, we need to score it + // the same way here. + type = CanFindIntranetURL(db, input) ? + UNVISITED_INTRANET : WHAT_YOU_TYPED; } break; case VisitClassifier::UNVISITED_INTRANET: @@ -752,9 +751,8 @@ bool HistoryURLProvider::CanFindIntranetURL( return false; const std::string host(UTF16ToUTF8( input.text().substr(input.parts().host.begin, input.parts().host.len))); - if (net::RegistryControlledDomainService::GetRegistryLength(host, false) != 0) - return false; - return db->IsTypedHost(host); + return (net::RegistryControlledDomainService::GetRegistryLength(host, + false) == 0) && db->IsTypedHost(host); } bool HistoryURLProvider::PromoteMatchForInlineAutocomplete( diff --git a/chrome/browser/autocomplete/history_url_provider_unittest.cc b/chrome/browser/autocomplete/history_url_provider_unittest.cc index ac63a02..97427dd 100644 --- a/chrome/browser/autocomplete/history_url_provider_unittest.cc +++ b/chrome/browser/autocomplete/history_url_provider_unittest.cc @@ -108,10 +108,12 @@ struct TestURLInfo { {"http://intra/two", "Intranet two", 1, 1}, {"http://intra/three", "Intranet three", 2, 2}, {"http://moo/bar", "Intranet moo", 1, 1}, + {"http://typedhost/typedpath", "Intranet typed", 1, 1}, + {"http://typedhost/untypedpath", "Intranet untyped", 1, 0}, - {"http://x.com/one", "Intranet", 2, 2}, - {"http://x.com/two", "Intranet two", 1, 1}, - {"http://x.com/three", "Intranet three", 2, 2}, + {"http://x.com/one", "Internet", 2, 2}, + {"http://x.com/two", "Internet two", 1, 1}, + {"http://x.com/three", "Internet three", 2, 2}, }; class HistoryURLProviderTest : public testing::Test, @@ -642,6 +644,13 @@ TEST_F(HistoryURLProviderTest, IntranetURLCompletion) { ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16("intra/x"), string16(), false, expected6, arraysize(expected6))); EXPECT_EQ(1400, matches_[0].relevance); + + const std::string expected7[] = { + "http://typedhost/untypedpath", + }; + ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16("typedhost/untypedpath"), + string16(), false, expected7, arraysize(expected7))); + EXPECT_EQ(1400, matches_[0].relevance); } TEST_F(HistoryURLProviderTest, CrashDueToFixup) { |