summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autocomplete
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/autocomplete')
-rw-r--r--chrome/browser/autocomplete/autocomplete_result.cc16
-rw-r--r--chrome/browser/autocomplete/autocomplete_result_unittest.cc51
2 files changed, 1 insertions, 66 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_result.cc b/chrome/browser/autocomplete/autocomplete_result.cc
index 044b890..0943ac2 100644
--- a/chrome/browser/autocomplete/autocomplete_result.cc
+++ b/chrome/browser/autocomplete/autocomplete_result.cc
@@ -178,22 +178,10 @@ void AutocompleteResult::SortAndCull(const AutocompleteInput& input,
DedupMatchesByDestination(input.current_page_classification(), true,
&matches_);
- // Find the top match before possibly applying demotions.
- if (!matches_.empty())
- std::partial_sort(matches_.begin(), matches_.begin() + 1, matches_.end(),
- &AutocompleteMatch::MoreRelevant);
- // Don't demote the top match if applicable.
- OmniboxFieldTrial::UndemotableTopMatchTypes undemotable_top_types =
- OmniboxFieldTrial::GetUndemotableTopTypes(
- input.current_page_classification());
- const bool preserve_top_match = !matches_.empty() &&
- (undemotable_top_types.count(matches_.begin()->type) != 0);
-
// Sort and trim to the most relevant kMaxMatches matches.
size_t max_num_matches = std::min(kMaxMatches, matches_.size());
CompareWithDemoteByType comparing_object(input.current_page_classification());
- std::sort(matches_.begin() + (preserve_top_match ? 1 : 0), matches_.end(),
- comparing_object);
+ std::sort(matches_.begin(), matches_.end(), comparing_object);
if (!matches_.empty() && !matches_.begin()->allowed_to_be_default_match) {
// Top match is not allowed to be the default match. Find the most
// relevant legal match and shift it to the front.
@@ -390,8 +378,6 @@ void AutocompleteResult::AddMatch(
DCHECK_EQ(AutocompleteMatch::SanitizeString(match.contents), match.contents);
DCHECK_EQ(AutocompleteMatch::SanitizeString(match.description),
match.description);
- // GetUndemotableTopTypes() is not used here because it's done in
- // SortAndCull(), and we depend on SortAndCull() to be called afterwards.
CompareWithDemoteByType comparing_object(page_classification);
ACMatches::iterator insertion_point =
std::upper_bound(begin(), end(), match, comparing_object);
diff --git a/chrome/browser/autocomplete/autocomplete_result_unittest.cc b/chrome/browser/autocomplete/autocomplete_result_unittest.cc
index 24dd96e..e98653e 100644
--- a/chrome/browser/autocomplete/autocomplete_result_unittest.cc
+++ b/chrome/browser/autocomplete/autocomplete_result_unittest.cc
@@ -463,57 +463,6 @@ TEST_F(AutocompleteResultTest, SortAndCullWithDemotionsByType) {
result.match_at(2)->destination_url.spec());
}
-TEST_F(AutocompleteResultTest, SortAndCullWithUndemotableTypes) {
- // Add some matches.
- ACMatches matches(3);
- matches[0].destination_url = GURL("http://top-history-url/");
- matches[0].relevance = 1400;
- matches[0].allowed_to_be_default_match = true;
- matches[0].type = AutocompleteMatchType::HISTORY_URL;
- matches[1].destination_url = GURL("http://history-url2/");
- matches[1].relevance = 1300;
- matches[1].allowed_to_be_default_match = true;
- matches[1].type = AutocompleteMatchType::HISTORY_URL;
- matches[2].destination_url = GURL("http://search-what-you-typed/");
- matches[2].relevance = 1200;
- matches[2].allowed_to_be_default_match = true;
- matches[2].type = AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED;
-
- // Add a rule demoting history-url, but don't demote the top match.
- {
- std::map<std::string, std::string> params;
- // 3 == HOME_PAGE
- params[std::string(OmniboxFieldTrial::kDemoteByTypeRule) + ":3:*"] =
- "1:50";
- params[std::string(OmniboxFieldTrial::kUndemotableTopTypeRule) + ":3:*"] =
- "1,5";
- ASSERT_TRUE(chrome_variations::AssociateVariationParams(
- OmniboxFieldTrial::kBundledExperimentFieldTrialName, "B", params));
- }
- base::FieldTrialList::CreateFieldTrial(
- OmniboxFieldTrial::kBundledExperimentFieldTrialName, "B");
-
- AutocompleteResult result;
- result.AppendMatches(matches);
- AutocompleteInput input(base::string16(), base::string16::npos,
- base::string16(), GURL(),
- AutocompleteInput::HOME_PAGE, false, false, false,
- AutocompleteInput::ALL_MATCHES);
- result.SortAndCull(input, test_util_.profile());
-
- // Check the new ordering. The first history-url result should not be
- // demoted, but the second result should be.
- // We cannot check relevance scores because the matches are sorted by
- // demoted relevance but the actual relevance scores are not modified.
- ASSERT_EQ(3u, result.size());
- EXPECT_EQ("http://top-history-url/",
- result.match_at(0)->destination_url.spec());
- EXPECT_EQ("http://search-what-you-typed/",
- result.match_at(1)->destination_url.spec());
- EXPECT_EQ("http://history-url2/",
- result.match_at(2)->destination_url.spec());
-}
-
TEST_F(AutocompleteResultTest, SortAndCullWithMatchDupsAndDemotionsByType) {
// Add some matches.
ACMatches matches;