diff options
author | mpearson@chromium.org <mpearson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-12 05:33:39 +0000 |
---|---|---|
committer | mpearson@chromium.org <mpearson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-12 05:33:39 +0000 |
commit | 2012a4a2a95fff44ccba0b2d240e4edcdfca8934 (patch) | |
tree | b8cf68346b0eb3ae9524b200f24cd845824c262c /chrome/browser/omnibox | |
parent | 74873d7928e570d7d223d47bfbfd9169d95b5e2d (diff) | |
download | chromium_src-2012a4a2a95fff44ccba0b2d240e4edcdfca8934.zip chromium_src-2012a4a2a95fff44ccba0b2d240e4edcdfca8934.tar.gz chromium_src-2012a4a2a95fff44ccba0b2d240e4edcdfca8934.tar.bz2 |
Omnibox: Convert Shortcuts Scoring Field Trial to Omnibox Bundled Field Trial
Switch from using its own field trial to being part of the bundled one.
As a natural consequence of this change, we can not alter the shortcuts
max relevance based on context in which the user is using the omnibox.
Tested interactively using a local variations server.
Also, adds missing inputs in certain files while I'm at it.
BUG=271058
Review URL: https://chromiumcodereview.appspot.com/22354006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@216938 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/omnibox')
-rw-r--r-- | chrome/browser/omnibox/omnibox_field_trial.cc | 34 | ||||
-rw-r--r-- | chrome/browser/omnibox/omnibox_field_trial.h | 28 | ||||
-rw-r--r-- | chrome/browser/omnibox/omnibox_field_trial_unittest.cc | 1 |
3 files changed, 30 insertions, 33 deletions
diff --git a/chrome/browser/omnibox/omnibox_field_trial.cc b/chrome/browser/omnibox/omnibox_field_trial.cc index 5f3457b..ffd2f72 100644 --- a/chrome/browser/omnibox/omnibox_field_trial.cc +++ b/chrome/browser/omnibox/omnibox_field_trial.cc @@ -11,6 +11,7 @@ #include "base/strings/string_split.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" +#include "chrome/browser/autocomplete/autocomplete_input.h" #include "chrome/browser/search/search.h" #include "chrome/common/metrics/metrics_util.h" #include "chrome/common/metrics/variations/variation_ids.h" @@ -23,10 +24,10 @@ const char kHUPCullRedirectsFieldTrialName[] = "OmniboxHUPCullRedirects"; const char kHUPCreateShorterMatchFieldTrialName[] = "OmniboxHUPCreateShorterMatch"; const char kStopTimerFieldTrialName[] = "OmniboxStopTimer"; -const char kShortcutsScoringFieldTrialName[] = "OmniboxShortcutsScoring"; const char kBundledExperimentFieldTrialName[] = "OmniboxBundledExperimentV1"; // Rule names used by the bundled experiment. +const char kShortcutsScoringMaxRelevanceRule[] = "ShortcutsScoringMaxRelevance"; const char kSearchHistoryRule[] = "SearchHistory"; const char kDemoteByTypeRule[] = "DemoteByType"; @@ -135,14 +136,9 @@ int OmniboxFieldTrial::GetDisabledProviderTypes() { continue; int types = 0; if (!base::StringToInt(base::StringPiece( - group_name.substr(strlen(kDisabledProviders))), &types)) { - LOG(WARNING) << "Malformed DisabledProviders string: " << group_name; + group_name.substr(strlen(kDisabledProviders))), &types)) continue; - } - if (types == 0) - LOG(WARNING) << "Expecting a non-zero bitmap; group = " << group_name; - else - provider_types |= types; + provider_types |= types; } return provider_types; } @@ -207,20 +203,18 @@ bool OmniboxFieldTrial::InZeroSuggestFieldTrial() { return false; } -// If the active group name starts with "MaxRelevance_", extract the -// int that immediately following that, returning true on success. -bool OmniboxFieldTrial::ShortcutsScoringMaxRelevance(int* max_relevance) { - std::string group_name = - base::FieldTrialList::FindFullName(kShortcutsScoringFieldTrialName); - const char kMaxRelevanceGroupPrefix[] = "MaxRelevance_"; - if (!StartsWithASCII(group_name, kMaxRelevanceGroupPrefix, true)) +bool OmniboxFieldTrial::ShortcutsScoringMaxRelevance( + AutocompleteInput::PageClassification current_page_classification, + int* max_relevance) { + // The value of the rule is a string that encodes an integer containing + // the max relevance. + const std::string& max_relevance_str = + OmniboxFieldTrial::GetValueForRuleInContext( + kShortcutsScoringMaxRelevanceRule, current_page_classification); + if (max_relevance_str.empty()) return false; - if (!base::StringToInt(base::StringPiece( - group_name.substr(strlen(kMaxRelevanceGroupPrefix))), - max_relevance)) { - LOG(WARNING) << "Malformed MaxRelevance string: " << group_name; + if (!base::StringToInt(max_relevance_str, max_relevance)) return false; - } return true; } diff --git a/chrome/browser/omnibox/omnibox_field_trial.h b/chrome/browser/omnibox/omnibox_field_trial.h index ee07285..cde6259 100644 --- a/chrome/browser/omnibox/omnibox_field_trial.h +++ b/chrome/browser/omnibox/omnibox_field_trial.h @@ -94,20 +94,22 @@ class OmniboxFieldTrial { static bool InZeroSuggestFieldTrial(); // --------------------------------------------------------- - // For the ShortcutsScoring field trial. - - // If the field trial is active and the user is in an experiment - // group, extract from the experiment group name the maximum - // relevance score ShortcutsProvider:: CalculateScore() can return. - // Returns true on a successful extraction. If the extraction failed, - // if the field trial is not active, etc., returns false. - // CalculateScore()'s return value is a product of this maximum - // relevance score and some attenuating factors that are all between - // 0 and 1. (Note that Shortcuts results may have their scores - // reduced later if the assigned score is higher than allowed for - // non-inlineable results. Shortcuts results are not allowed to be + // For the ShortcutsScoringMaxRelevance experiment that's part of the + // bundled omnibox field trial. + + // If the user is in an experiment group that, given the provided + // |current_page_classification| context, changes the maximum relevance + // ShortcutsProvider::CalculateScore() is supposed to assign, extract + // that maximum relevance score and put in in |max_relevance|. Returns + // true on a successful extraction. CalculateScore()'s return value is + // a product of this maximum relevance score and some attenuating factors + // that are all between 0 and 1. (Note that Shortcuts results may have + // their scores reduced later if the assigned score is higher than allowed + // for non-inlineable results. Shortcuts results are not allowed to be // inlined.) - static bool ShortcutsScoringMaxRelevance(int* max_relevance); + static bool ShortcutsScoringMaxRelevance( + AutocompleteInput::PageClassification current_page_classification, + int* max_relevance); // --------------------------------------------------------- // For the SearchHistory experiment that's part of the bundled omnibox diff --git a/chrome/browser/omnibox/omnibox_field_trial_unittest.cc b/chrome/browser/omnibox/omnibox_field_trial_unittest.cc index 9e113a5..22a5387 100644 --- a/chrome/browser/omnibox/omnibox_field_trial_unittest.cc +++ b/chrome/browser/omnibox/omnibox_field_trial_unittest.cc @@ -9,6 +9,7 @@ #include "base/memory/scoped_ptr.h" #include "base/metrics/field_trial.h" #include "base/strings/string16.h" +#include "chrome/browser/autocomplete/autocomplete_input.h" #include "chrome/browser/search/search.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/metrics/entropy_provider.h" |