Index: chrome/browser/omnibox/omnibox_field_trial.cc |
diff --git a/chrome/browser/omnibox/omnibox_field_trial.cc b/chrome/browser/omnibox/omnibox_field_trial.cc |
index 09c2d1a72638da218e1c89c055ff345124d21b2d..e2974bcf3b02a098f36a8f0b7d0861cfff4d0f88 100644 |
--- a/chrome/browser/omnibox/omnibox_field_trial.cc |
+++ b/chrome/browser/omnibox/omnibox_field_trial.cc |
@@ -22,7 +22,10 @@ const char kHUPCreateShorterMatchFieldTrialName[] = |
"OmniboxHUPCreateShorterMatch"; |
const char kStopTimerFieldTrialName[] = "OmniboxStopTimer"; |
const char kShortcutsScoringFieldTrialName[] = "OmniboxShortcutsScoring"; |
-const char kSearchHistoryFieldTrialName[] = "OmniboxSearchHistory"; |
+const char kBundledExperimentFieldTrialName[] = "OmniboxBundledExperimentV1"; |
+ |
+// Rule names used by the bundled experiment. |
+const char kSearchHistoryRule[] = "SearchHistory"; |
// The autocomplete dynamic field trial name prefix. Each field trial is |
// configured dynamically and is retrieved automatically by Chrome during |
@@ -218,12 +221,54 @@ bool OmniboxFieldTrial::ShortcutsScoringMaxRelevance(int* max_relevance) { |
return true; |
} |
-bool OmniboxFieldTrial::SearchHistoryPreventInlining() { |
- return (base::FieldTrialList::FindFullName(kSearchHistoryFieldTrialName) == |
- "PreventInlining"); |
+bool OmniboxFieldTrial::SearchHistoryPreventInlining( |
+ AutocompleteInput::PageClassification current_page_classification) { |
+ return OmniboxFieldTrial::GetConsequencesOfRuleInPageClassificationContext( |
+ current_page_classification, kSearchHistoryRule) == "PreventInlining"; |
+} |
+ |
+bool OmniboxFieldTrial::SearchHistoryDisable( |
+ AutocompleteInput::PageClassification current_page_classification) { |
+ return OmniboxFieldTrial::GetConsequencesOfRuleInPageClassificationContext( |
+ current_page_classification, kSearchHistoryRule) == "Disable"; |
} |
-bool OmniboxFieldTrial::SearchHistoryDisable() { |
- return (base::FieldTrialList::FindFullName(kSearchHistoryFieldTrialName) == |
- "Disable"); |
+// Background and implementation details: |
+// |
+// Each experiment group in any field trial can come with an optional set of |
+// parameters (key-value pairs). In the bundled omnibox experiment |
+// (kBundledExperimentFieldTrialName), each experiment group comes with a |
+// list of parameters in the form: |
+// key=<AutocompleteInput::PageClassification (as an int)>:<Rule> |
+// value=<Consequences> |
+// The AutocompleteInput::PageClassification can also be "*", which means |
+// this rule applies in all contexts. |
+// One example parameter is |
+// key=6:SearchHistory |
+// value=PreventInlining |
+// This means in context 6 (a search result page doing search term replacement), |
+// the SearchHistory experience should PreventInlining. |
+// |
+// In short, this function tries to find the value associated with key |
+// |current_page_classification|:|rule|, failing that it looks up |
+// *:|rule|, and failing that it returns the empty string. |
+std::string OmniboxFieldTrial::GetConsequencesOfRuleInPageClassificationContext( |
Mark P
2013/07/30 21:00:29
asvitkine: This function would be a little shorter
|
+ AutocompleteInput::PageClassification current_page_classification, |
+ const std::string& rule) { |
+ std::map<std::string, std::string> params; |
+ if (!chrome_variations::GetVariationParams(kBundledExperimentFieldTrialName, |
+ ¶ms)) { |
+ return ""; |
+ } |
+ // Lookup rule in this exact context. |
+ std::map<std::string, std::string>::iterator it = |
+ params.find(base::IntToString( |
+ static_cast<int>(current_page_classification)) + ":" + rule); |
+ if (it != params.end()) |
+ return it->second; |
+ // Lookup rule in the global context. |
+ it = params.find("*:" + rule); |
+ if (it != params.end()) |
+ return it->second; |
+ return ""; |
} |