diff options
author | mpearson@chromium.org <mpearson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-10 09:46:16 +0000 |
---|---|---|
committer | mpearson@chromium.org <mpearson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-10 09:46:16 +0000 |
commit | d8cd76bbc19a5403db1af621a9d485d582ae5dd9 (patch) | |
tree | ce68fe2cfdd2b18264c50b37a40375bcf89db14f | |
parent | 91b3cd274f7f6c6501a78b9e4e2503e977e847eb (diff) | |
download | chromium_src-d8cd76bbc19a5403db1af621a9d485d582ae5dd9.zip chromium_src-d8cd76bbc19a5403db1af621a9d485d582ae5dd9.tar.gz chromium_src-d8cd76bbc19a5403db1af621a9d485d582ae5dd9.tar.bz2 |
Omnibox: Add Field Trial for Demoting/Disabling Search History
Adds a field trial that tries:
* demoting search history suggestions (so they never appear inline)
* disabling search history suggestions (so they never appear)
Note that query suggestions from the suggest server can still be
inlined, so if you test this with a popular query you may be misled into
thinking the trial isn't working because you're still see the
suggestion. Check about:omnibox to see where the suggestion is coming
from.
Tested using --force-fieldtrials and about:omnibox
BUG=172491
Review URL: https://chromiumcodereview.appspot.com/18870004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@210802 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/autocomplete/search_provider.cc | 23 | ||||
-rw-r--r-- | chrome/browser/autocomplete/search_provider.h | 7 | ||||
-rw-r--r-- | chrome/browser/omnibox/omnibox_field_trial.cc | 11 | ||||
-rw-r--r-- | chrome/browser/omnibox/omnibox_field_trial.h | 12 |
4 files changed, 47 insertions, 6 deletions
diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc index c5861c4..2f30450 100644 --- a/chrome/browser/autocomplete/search_provider.cc +++ b/chrome/browser/autocomplete/search_provider.cc @@ -251,7 +251,11 @@ SearchProvider::SearchProvider(AutocompleteProviderListener* listener, suggest_results_pending_(0), field_trial_triggered_(false), field_trial_triggered_in_session_(false), - omnibox_start_margin_(-1) { + omnibox_start_margin_(-1), + prevent_search_history_inlining_( + OmniboxFieldTrial::SearchHistoryPreventInlining()), + disable_search_history_( + OmniboxFieldTrial::SearchHistoryDisable()) { } // static @@ -627,6 +631,9 @@ void SearchProvider::DoHistoryQuery(bool minimal_changes) { keyword_history_results_.clear(); default_history_results_.clear(); + if (disable_search_history_) + return; + HistoryService* const history_service = HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); history::URLDatabase* url_db = history_service ? @@ -1336,17 +1343,21 @@ int SearchProvider::CalculateRelevanceForHistory( bool prevent_inline_autocomplete) 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 starts at 1399 and - // falls to 1300. 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. + // provider that we want to inline autocomplete), 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) { // Searches with the past two days get a different curve. const double autocomplete_time = 2 * 24 * 60 * 60; if (elapsed_time < autocomplete_time) { - return (is_keyword ? 1599 : 1399) - static_cast<int>(99 * + int max_score = is_keyword ? 1599 : 1399; + if (prevent_search_history_inlining_) + max_score = 1299; + return max_score - static_cast<int>(99 * std::pow(elapsed_time / autocomplete_time, 2.5)); } elapsed_time -= autocomplete_time; diff --git a/chrome/browser/autocomplete/search_provider.h b/chrome/browser/autocomplete/search_provider.h index 59ecc79..f01fdb6 100644 --- a/chrome/browser/autocomplete/search_provider.h +++ b/chrome/browser/autocomplete/search_provider.h @@ -527,6 +527,13 @@ class SearchProvider : public AutocompleteProvider, // Start margin of the omnibox. Used to construct search URLs. int omnibox_start_margin_; + // If true, search history query suggestions will score low enough that + // they will not be inlined. + bool prevent_search_history_inlining_; + + // If true, no search history query suggestions will be offered. + bool disable_search_history_; + DISALLOW_COPY_AND_ASSIGN(SearchProvider); }; diff --git a/chrome/browser/omnibox/omnibox_field_trial.cc b/chrome/browser/omnibox/omnibox_field_trial.cc index da16943..514c669 100644 --- a/chrome/browser/omnibox/omnibox_field_trial.cc +++ b/chrome/browser/omnibox/omnibox_field_trial.cc @@ -23,6 +23,7 @@ const char kHUPCreateShorterMatchFieldTrialName[] = "OmniboxHUPCreateShorterMatch"; const char kStopTimerFieldTrialName[] = "OmniboxStopTimer"; const char kShortcutsScoringFieldTrialName[] = "OmniboxShortcutsScoring"; +const char kSearchHistoryFieldTrialName[] = "OmniboxSearchHistory"; // The autocomplete dynamic field trial name prefix. Each field trial is // configured dynamically and is retrieved automatically by Chrome during @@ -258,3 +259,13 @@ bool OmniboxFieldTrial::ShortcutsScoringMaxRelevance(int* max_relevance) { } return true; } + +bool OmniboxFieldTrial::SearchHistoryPreventInlining() { + return (base::FieldTrialList::FindFullName(kSearchHistoryFieldTrialName) == + "PreventInlining"); +} + +bool OmniboxFieldTrial::SearchHistoryDisable() { + return (base::FieldTrialList::FindFullName(kSearchHistoryFieldTrialName) == + "Disable"); +} diff --git a/chrome/browser/omnibox/omnibox_field_trial.h b/chrome/browser/omnibox/omnibox_field_trial.h index ab5babc..5a928be 100644 --- a/chrome/browser/omnibox/omnibox_field_trial.h +++ b/chrome/browser/omnibox/omnibox_field_trial.h @@ -113,6 +113,18 @@ class OmniboxFieldTrial { // inlined.) static bool ShortcutsScoringMaxRelevance(int* max_relevance); + // --------------------------------------------------------- + // For the SearchHistory field trial. + + // Returns true if the user is in the experiment group that scores + // search history query suggestions less aggressively so that they don't + // inline. + static bool SearchHistoryPreventInlining(); + + // Returns true if the user is in the experiment group that disables + // all query suggestions from search history. + static bool SearchHistoryDisable(); + private: DISALLOW_IMPLICIT_CONSTRUCTORS(OmniboxFieldTrial); }; |