diff options
author | mpearson@chromium.org <mpearson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-21 17:32:41 +0000 |
---|---|---|
committer | mpearson@chromium.org <mpearson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-21 17:32:41 +0000 |
commit | 1be0b45815e548f453be4e1dae88842afb6e0d6c (patch) | |
tree | 9e2133acec42deb77c607b17db6315596627c3b7 /chrome/browser/autocomplete/shortcuts_provider.cc | |
parent | aa44546e0270e7cff9d934d9d5dc236df2030e99 (diff) | |
download | chromium_src-1be0b45815e548f453be4e1dae88842afb6e0d6c.zip chromium_src-1be0b45815e548f453be4e1dae88842afb6e0d6c.tar.gz chromium_src-1be0b45815e548f453be4e1dae88842afb6e0d6c.tar.bz2 |
Omnibox: Add Field Trial to Make Shortcuts More Aggressive
Change ShortcutsProvider so it can assign high relevance scores.
Simultaneously, make ShortcutsProvider explicitly enforce the rule
that it should not return a result with an inlineable score (>=1200).
Finally, create a field trial that will allow the server to specify
the maximum relevance score ShortcutsProvider can assign. Setting this
to 1199 will maintain current behavior. Also, if the field trial is
not enabled through the variations server, Chrome will maintain the
current behavior.
BUG=252032
TEST=enter omnibox inputs that you've used before to get places (and hence shortcuts will have data about them) into about:omnibox and look at the resulting scores. Try again with --force-fieldtrials=OmniboxShortcutsScoring/MaxRelevance_XXX/ (where XXX is a number) and see how the scores change.
Review URL: https://chromiumcodereview.appspot.com/17261012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207872 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete/shortcuts_provider.cc')
-rw-r--r-- | chrome/browser/autocomplete/shortcuts_provider.cc | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/chrome/browser/autocomplete/shortcuts_provider.cc b/chrome/browser/autocomplete/shortcuts_provider.cc index 21d7b5e..1d380b3 100644 --- a/chrome/browser/autocomplete/shortcuts_provider.cc +++ b/chrome/browser/autocomplete/shortcuts_provider.cc @@ -25,6 +25,7 @@ #include "chrome/browser/history/history_service.h" #include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/history/shortcuts_backend_factory.h" +#include "chrome/browser/omnibox/omnibox_field_trial.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" @@ -53,7 +54,8 @@ ShortcutsProvider::ShortcutsProvider(AutocompleteProviderListener* listener, : AutocompleteProvider(listener, profile, AutocompleteProvider::TYPE_SHORTCUTS), languages_(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)), - initialized_(false) { + initialized_(false), + max_relevance_(AutocompleteResult::kLowestDefaultScore - 1) { scoped_refptr<history::ShortcutsBackend> backend = ShortcutsBackendFactory::GetForProfile(profile_); if (backend.get()) { @@ -61,6 +63,9 @@ ShortcutsProvider::ShortcutsProvider(AutocompleteProviderListener* listener, if (backend->initialized()) initialized_ = true; } + int max_relevance; + if (OmniboxFieldTrial::ShortcutsScoringMaxRelevance(&max_relevance)) + max_relevance_ = max_relevance; } void ShortcutsProvider::Start(const AutocompleteInput& input, @@ -169,6 +174,16 @@ void ShortcutsProvider::GetMatches(const AutocompleteInput& input) { matches_.erase(matches_.begin() + AutocompleteProvider::kMaxMatches, matches_.end()); } + // Reset relevance scores to guarantee no results are given an + // inlineable score and all scores are decreasing (but not do assign + // any scores below 1). + int max_relevance = AutocompleteResult::kLowestDefaultScore - 1; + for (ACMatches::iterator it = matches_.begin(); it != matches_.end(); ++it) { + max_relevance = std::min(max_relevance, it->relevance); + it->relevance = max_relevance; + if (max_relevance > 1) + --max_relevance; + } } AutocompleteMatch ShortcutsProvider::ShortcutToACMatch( @@ -321,7 +336,6 @@ history::ShortcutsBackend::ShortcutMap::const_iterator backend->shortcuts_map().end(); } -// static int ShortcutsProvider::CalculateScore( const string16& terms, const history::ShortcutsBackend::Shortcut& shortcut) { @@ -334,7 +348,7 @@ int ShortcutsProvider::CalculateScore( // directly. This makes sense since the first characters typed are much more // important for determining how likely it is a user wants a particular // shortcut than are the remaining continued characters. - double base_score = (AutocompleteResult::kLowestDefaultScore - 1) * + double base_score = max_relevance_ * sqrt(static_cast<double>(terms.length()) / shortcut.text.length()); // Then we decay this by half each week. |