Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(399)

Unified Diff: chrome/browser/autocomplete/search_provider.cc

Issue 20777006: Omnibox: Create Bundled Field Trial; Convert SearchHistory trial to it (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/autocomplete/search_provider.h ('k') | chrome/browser/omnibox/omnibox_field_trial.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..d4245fd34e8719b14b02a9213e22a51447052195 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,7 +626,8 @@ 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()))
return;
HistoryService* const history_service =
@@ -1203,6 +1200,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 +1230,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,22 +1337,23 @@ int SearchProvider::GetKeywordVerbatimRelevance(
int SearchProvider::CalculateRelevanceForHistory(
const base::Time& time,
bool is_keyword,
- bool prevent_inline_autocomplete) const {
+ bool use_aggressive_method,
+ 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
+ // provider that we want to score aggressively), the score is in the range
+ // 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.
double elapsed_time = std::max((base::Time::Now() - time).InSecondsF(), 0.0);
bool is_primary_provider = is_keyword || !providers_.has_keyword_provider();
- if (is_primary_provider && !prevent_inline_autocomplete) {
+ if (is_primary_provider && use_aggressive_method) {
// Searches with the past two days get a different curve.
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));
« no previous file with comments | « chrome/browser/autocomplete/search_provider.h ('k') | chrome/browser/omnibox/omnibox_field_trial.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698