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

Unified Diff: chrome/browser/omnibox/omnibox_field_trial.cc

Issue 22698002: Omnibox: Allow Bundled Omnibox Field Trial to Examine Instant Extended (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test for android Created 7 years, 4 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
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 2bec78bc0ccf477943baf275e0d459b0f0edaa24..5f3457b8c0c7a1f657914f9b758c3bab5619a327 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/search/search.h"
#include "chrome/common/metrics/metrics_util.h"
#include "chrome/common/metrics/variations/variation_ids.h"
#include "chrome/common/metrics/variations/variations_util.h"
@@ -270,19 +271,32 @@ void OmniboxFieldTrial::GetDemotionsByType(
// parameters (key-value pairs). In the bundled omnibox experiment
// (kBundledExperimentFieldTrialName), each experiment group comes with a
// list of parameters in the form:
-// key=<Rule>:<AutocompleteInput::PageClassification (as an int)>
+// key=<Rule>:
+// <AutocompleteInput::PageClassification (as an int)>:
+// <whether Instant Extended is enabled (as a 1 or 0)>
+// (note that there are no linebreaks in keys; this format is for
+// presentation only>
// value=<arbitrary string>
-// The AutocompleteInput::PageClassification can also be "*", which means
-// this rule applies in all page classification contexts.
+// Both the AutocompleteInput::PageClassification and the Instant Extended
+// entries can be "*", which means this rule applies for all values of the
+// matching portion of the context.
// One example parameter is
-// key=SearchHistory:6
+// key=SearchHistory:6:1
// value=PreventInlining
// This means in page classification context 6 (a search result page doing
-// search term replacement), the SearchHistory experiment should
-// PreventInlining.
+// search term replacement) with Instant Extended enabled, the SearchHistory
+// experiment should PreventInlining.
+//
+// When an exact match to the rule in the current context is missing, we
+// give preference to a wildcard rule that matches the instant extended
+// context over a wildcard rule that matches the page classification
+// context. Hopefully, though, users will write their field trial configs
+// so as not to rely on this fall back order.
//
// In short, this function tries to find the value associated with key
-// |rule|:|page_classification|, failing that it looks up |rule|:*,
+// |rule|:|page_classification|:|instant_extended|, failing that it looks up
+// |rule|:*:|instant_extended|, failing that it looks up
+// |rule|:|page_classification|:*, failing that it looks up |rule|:*:*,
// and failing that it returns the empty string.
std::string OmniboxFieldTrial::GetValueForRuleInContext(
const std::string& rule,
@@ -292,13 +306,24 @@ std::string OmniboxFieldTrial::GetValueForRuleInContext(
&params)) {
return std::string();
}
+ const std::string page_classification_str =
+ base::IntToString(static_cast<int>(page_classification));
+ const std::string instant_extended =
+ chrome::IsInstantExtendedAPIEnabled() ? "1" : "0";
// Look up rule in this exact context.
- std::map<std::string, std::string>::iterator it =
- params.find(rule + ":" + base::IntToString(
- static_cast<int>(page_classification)));
+ std::map<std::string, std::string>::iterator it = params.find(
+ rule + ":" + page_classification_str + ":" + instant_extended);
+ if (it != params.end())
+ return it->second;
+ // Fall back to the global page classification context.
+ it = params.find(rule + ":*:" + instant_extended);
+ if (it != params.end())
+ return it->second;
+ // Fall back to the global instant extended context.
+ it = params.find(rule + ":" + page_classification_str + ":*");
if (it != params.end())
return it->second;
// Look up rule in the global context.
- it = params.find(rule + ":*");
+ it = params.find(rule + ":*:*");
return (it != params.end()) ? it->second : std::string();
}
« no previous file with comments | « chrome/browser/omnibox/omnibox_field_trial.h ('k') | chrome/browser/omnibox/omnibox_field_trial_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698