summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/autocomplete/history_quick_provider.cc9
-rw-r--r--chrome/browser/autocomplete/history_quick_provider.h3
-rw-r--r--chrome/browser/autocomplete/history_quick_provider_unittest.cc39
3 files changed, 23 insertions, 28 deletions
diff --git a/chrome/browser/autocomplete/history_quick_provider.cc b/chrome/browser/autocomplete/history_quick_provider.cc
index d1ac04c..8a96c52 100644
--- a/chrome/browser/autocomplete/history_quick_provider.cc
+++ b/chrome/browser/autocomplete/history_quick_provider.cc
@@ -110,7 +110,7 @@ void HistoryQuickProvider::DoAutocomplete() {
// |max_match_score|. Upon use of |max_match_score| it is decremented.
// All subsequent matches must be clamped to retain match results ordering.
int max_match_score = autocomplete_input_.prevent_inline_autocomplete() ?
- kMaxNonInliningScore : -1;
+ (AutocompleteResult::kLowestDefaultScore - 1) : -1;
for (ScoredHistoryMatches::const_iterator match_iter = matches.begin();
match_iter != matches.end(); ++match_iter) {
const ScoredHistoryMatch& history_match(*match_iter);
@@ -126,10 +126,6 @@ void HistoryQuickProvider::DoAutocomplete() {
}
}
-// static
-const int HistoryQuickProvider::kMaxNonInliningScore =
- AutocompleteResult::kLowestDefaultScore - 1;
-
AutocompleteMatch HistoryQuickProvider::QuickMatchToACMatch(
const ScoredHistoryMatch& history_match,
const ScoredHistoryMatches& history_matches,
@@ -202,7 +198,8 @@ int HistoryQuickProvider::CalculateRelevance(
// at the beginning of the result's URL and there is exactly one substring
// match in the URL.
int score = (history_match.can_inline) ? history_match.raw_score :
- std::min(kMaxNonInliningScore, history_match.raw_score);
+ std::min(AutocompleteResult::kLowestDefaultScore - 1,
+ history_match.raw_score);
*max_match_score = ((*max_match_score < 0) ?
score : std::min(score, *max_match_score)) - 1;
return *max_match_score + 1;
diff --git a/chrome/browser/autocomplete/history_quick_provider.h b/chrome/browser/autocomplete/history_quick_provider.h
index 8f581c3..e6bb353 100644
--- a/chrome/browser/autocomplete/history_quick_provider.h
+++ b/chrome/browser/autocomplete/history_quick_provider.h
@@ -52,9 +52,6 @@ class HistoryQuickProvider : public HistoryProvider {
FRIEND_TEST_ALL_PREFIXES(HistoryQuickProviderTest, Spans);
FRIEND_TEST_ALL_PREFIXES(HistoryQuickProviderTest, Relevance);
- // The initial maximum allowable score for a match which cannot be inlined.
- static const int kMaxNonInliningScore;
-
// Creates an AutocompleteMatch from |history_match|. |max_match_score| gives
// the maximum possible score for the match. |history_matches| is the full set
// of matches to compare each match to when calculating confidence.
diff --git a/chrome/browser/autocomplete/history_quick_provider_unittest.cc b/chrome/browser/autocomplete/history_quick_provider_unittest.cc
index 021efb7..f936860 100644
--- a/chrome/browser/autocomplete/history_quick_provider_unittest.cc
+++ b/chrome/browser/autocomplete/history_quick_provider_unittest.cc
@@ -377,49 +377,50 @@ TEST_F(HistoryQuickProviderTest, Relevance) {
next_score = 1500;
match.raw_score = 1425;
match.can_inline = false;
+ const int kMaxNonInliningScore = AutocompleteResult::kLowestDefaultScore - 1;
EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score),
- HistoryQuickProvider::kMaxNonInliningScore);
- EXPECT_EQ(next_score, HistoryQuickProvider::kMaxNonInliningScore - 1);
+ kMaxNonInliningScore);
+ EXPECT_EQ(next_score, kMaxNonInliningScore - 1);
// Can inline, clamped.
- next_score = HistoryQuickProvider::kMaxNonInliningScore;
+ next_score = kMaxNonInliningScore;
match.raw_score = 1425;
match.can_inline = true;
EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score),
- HistoryQuickProvider::kMaxNonInliningScore);
- EXPECT_EQ(next_score, HistoryQuickProvider::kMaxNonInliningScore - 1);
+ kMaxNonInliningScore);
+ EXPECT_EQ(next_score, kMaxNonInliningScore - 1);
// Can't inline, clamped.
- next_score = HistoryQuickProvider::kMaxNonInliningScore;
+ next_score = kMaxNonInliningScore;
match.raw_score = 1425;
match.can_inline = false;
EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score),
- HistoryQuickProvider::kMaxNonInliningScore);
- EXPECT_EQ(next_score, HistoryQuickProvider::kMaxNonInliningScore - 1);
+ kMaxNonInliningScore);
+ EXPECT_EQ(next_score, kMaxNonInliningScore - 1);
// Score just above the clamped limit.
- next_score = HistoryQuickProvider::kMaxNonInliningScore;
+ next_score = kMaxNonInliningScore;
match.raw_score = AutocompleteResult::kLowestDefaultScore;
match.can_inline = false;
EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score),
- HistoryQuickProvider::kMaxNonInliningScore);
- EXPECT_EQ(next_score, HistoryQuickProvider::kMaxNonInliningScore - 1);
+ kMaxNonInliningScore);
+ EXPECT_EQ(next_score, kMaxNonInliningScore - 1);
// Score right at the clamped limit.
- next_score = HistoryQuickProvider::kMaxNonInliningScore;
- match.raw_score = HistoryQuickProvider::kMaxNonInliningScore;
+ next_score = kMaxNonInliningScore;
+ match.raw_score = kMaxNonInliningScore;
match.can_inline = true;
EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score),
- HistoryQuickProvider::kMaxNonInliningScore);
- EXPECT_EQ(next_score, HistoryQuickProvider::kMaxNonInliningScore - 1);
+ kMaxNonInliningScore);
+ EXPECT_EQ(next_score, kMaxNonInliningScore - 1);
// Score just below the clamped limit.
- next_score = HistoryQuickProvider::kMaxNonInliningScore;
- match.raw_score = HistoryQuickProvider::kMaxNonInliningScore - 1;
+ next_score = kMaxNonInliningScore;
+ match.raw_score = kMaxNonInliningScore - 1;
match.can_inline = true;
EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score),
- HistoryQuickProvider::kMaxNonInliningScore - 1);
- EXPECT_EQ(next_score, HistoryQuickProvider::kMaxNonInliningScore - 2);
+ kMaxNonInliningScore - 1);
+ EXPECT_EQ(next_score, kMaxNonInliningScore - 2);
// Low score, can inline, not clamped.
next_score = 1500;