Chromium Code Reviews| Index: chrome/browser/autocomplete/search_provider.cc |
| diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc |
| index 89d29257b45d18355f036406f556a99ad4426500..f84b56a950100e50b29fa0236973d26962469ad6 100644 |
| --- a/chrome/browser/autocomplete/search_provider.cc |
| +++ b/chrome/browser/autocomplete/search_provider.cc |
| @@ -251,11 +251,7 @@ SearchProvider::SearchProvider(AutocompleteProviderListener* listener, |
| suggest_results_pending_(0), |
| field_trial_triggered_(false), |
| field_trial_triggered_in_session_(false), |
| - omnibox_start_margin_(-1), |
| - prevent_search_history_inlining_( |
| - OmniboxFieldTrial::SearchHistoryPreventInlining()), |
| - disable_search_history_( |
| - OmniboxFieldTrial::SearchHistoryDisable()) { |
| + omnibox_start_margin_(-1) { |
| } |
| // static |
| @@ -630,8 +626,10 @@ void SearchProvider::DoHistoryQuery(bool minimal_changes) { |
| keyword_history_results_.clear(); |
| default_history_results_.clear(); |
| - if (disable_search_history_) |
| + if (OmniboxFieldTrial::SearchHistoryDisable( |
| + input_.current_page_classification())) { |
|
Peter Kasting
2013/08/01 22:44:48
Nit: Indent 4, not 8. I would remove {} too since
Mark P
2013/08/02 00:44:36
Hey, I previously indented 4 and Alexei told me to
|
| return; |
| + } |
| HistoryService* const history_service = |
| HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); |
| @@ -1203,6 +1201,9 @@ SearchProvider::SuggestResults SearchProvider::ScoreHistoryResults( |
| AutocompleteClassifier* classifier = |
| AutocompleteClassifierFactory::GetForProfile(profile_); |
| SuggestResults scored_results; |
| + const bool prevent_search_history_inlining = |
| + OmniboxFieldTrial::SearchHistoryPreventInlining( |
| + input_.current_page_classification()); |
| for (HistoryResults::const_iterator i(results.begin()); i != results.end(); |
| ++i) { |
| // Don't autocomplete multi-word queries that have only been seen once |
| @@ -1230,8 +1231,9 @@ SearchProvider::SuggestResults SearchProvider::ScoreHistoryResults( |
| !AutocompleteMatch::IsSearchType(match.type); |
| } |
| - int relevance = CalculateRelevanceForHistory(i->time, is_keyword, |
| - prevent_inline_autocomplete); |
| + int relevance = CalculateRelevanceForHistory( |
| + i->time, is_keyword, prevent_inline_autocomplete, |
| + prevent_search_history_inlining); |
| scored_results.push_back( |
| SuggestResult(i->term, is_keyword, relevance, false)); |
| } |
| @@ -1336,11 +1338,12 @@ int SearchProvider::GetKeywordVerbatimRelevance( |
| int SearchProvider::CalculateRelevanceForHistory( |
| const base::Time& time, |
| bool is_keyword, |
| - bool prevent_inline_autocomplete) const { |
| + bool prevent_inline_autocomplete, |
| + bool prevent_search_history_inlining) const { |
| // The relevance of past searches falls off over time. There are two distinct |
| // equations used. If the first equation is used (searches to the primary |
| // provider that we want to inline autocomplete), the score is in the range |
| - // 1300-1599 (unless |prevent_search_history_inlining_|, in which case |
| + // 1300-1599 (unless |prevent_search_history_inlining|, in which case |
| // it's in the range 1200-1299). If the second equation is used the |
| // relevance of a search 15 minutes ago is discounted 50 points, while the |
| // relevance of a search two weeks ago is discounted 450 points. |
| @@ -1351,7 +1354,7 @@ int SearchProvider::CalculateRelevanceForHistory( |
| const double autocomplete_time = 2 * 24 * 60 * 60; |
| if (elapsed_time < autocomplete_time) { |
| int max_score = is_keyword ? 1599 : 1399; |
| - if (prevent_search_history_inlining_) |
| + if (prevent_search_history_inlining) |
| max_score = 1299; |
| return max_score - static_cast<int>(99 * |
| std::pow(elapsed_time / autocomplete_time, 2.5)); |