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

Side by Side Diff: chrome/browser/omnibox/omnibox_field_trial.cc

Issue 18878007: Omnibox: Make the Controller Reorder Matches for Inlining (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: public consts in omnibox field trial, better spacing and wrapping in search provider 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/omnibox/omnibox_field_trial.h" 5 #include "chrome/browser/omnibox/omnibox_field_trial.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "chrome/common/metrics/metrics_util.h" 13 #include "chrome/common/metrics/metrics_util.h"
14 #include "chrome/common/metrics/variations/variation_ids.h" 14 #include "chrome/common/metrics/variations/variation_ids.h"
15 #include "chrome/common/metrics/variations/variations_util.h" 15 #include "chrome/common/metrics/variations/variations_util.h"
16 16
17 namespace { 17 namespace {
18 18
19 // Field trial names. 19 // Field trial names.
20 const char kHUPCullRedirectsFieldTrialName[] = "OmniboxHUPCullRedirects"; 20 const char kHUPCullRedirectsFieldTrialName[] = "OmniboxHUPCullRedirects";
21 const char kHUPCreateShorterMatchFieldTrialName[] = 21 const char kHUPCreateShorterMatchFieldTrialName[] =
22 "OmniboxHUPCreateShorterMatch"; 22 "OmniboxHUPCreateShorterMatch";
23 const char kStopTimerFieldTrialName[] = "OmniboxStopTimer"; 23 const char kStopTimerFieldTrialName[] = "OmniboxStopTimer";
24 const char kShortcutsScoringFieldTrialName[] = "OmniboxShortcutsScoring"; 24 const char kShortcutsScoringFieldTrialName[] = "OmniboxShortcutsScoring";
25 const char kBundledExperimentFieldTrialName[] = "OmniboxBundledExperimentV1";
26
27 // Rule names used by the bundled experiment.
28 const char kSearchHistoryRule[] = "SearchHistory";
29 25
30 // The autocomplete dynamic field trial name prefix. Each field trial is 26 // The autocomplete dynamic field trial name prefix. Each field trial is
31 // configured dynamically and is retrieved automatically by Chrome during 27 // configured dynamically and is retrieved automatically by Chrome during
32 // the startup. 28 // the startup.
33 const char kAutocompleteDynamicFieldTrialPrefix[] = "AutocompleteDynamicTrial_"; 29 const char kAutocompleteDynamicFieldTrialPrefix[] = "AutocompleteDynamicTrial_";
34 // The maximum number of the autocomplete dynamic field trials (aka layers). 30 // The maximum number of the autocomplete dynamic field trials (aka layers).
35 const int kMaxAutocompleteDynamicFieldTrials = 5; 31 const int kMaxAutocompleteDynamicFieldTrials = 5;
36 32
37 // Field trial experiment probabilities. 33 // Field trial experiment probabilities.
38 34
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 return OmniboxFieldTrial::GetValueForRuleInContext( 222 return OmniboxFieldTrial::GetValueForRuleInContext(
227 kSearchHistoryRule, current_page_classification) == "PreventInlining"; 223 kSearchHistoryRule, current_page_classification) == "PreventInlining";
228 } 224 }
229 225
230 bool OmniboxFieldTrial::SearchHistoryDisable( 226 bool OmniboxFieldTrial::SearchHistoryDisable(
231 AutocompleteInput::PageClassification current_page_classification) { 227 AutocompleteInput::PageClassification current_page_classification) {
232 return OmniboxFieldTrial::GetValueForRuleInContext( 228 return OmniboxFieldTrial::GetValueForRuleInContext(
233 kSearchHistoryRule, current_page_classification) == "Disable"; 229 kSearchHistoryRule, current_page_classification) == "Disable";
234 } 230 }
235 231
232 bool OmniboxFieldTrial::ReorderForLegalDefaultMatch(
233 AutocompleteInput::PageClassification current_page_classification) {
234 return OmniboxFieldTrial::GetValueForRuleInContext(
235 kReorderForLegalDefaultMatchRule, current_page_classification) ==
236 kReorderForLegalDefaultMatchRuleEnabled;
237 }
238
239 // static (just like everything else in this file)
Peter Kasting 2013/08/09 21:59:34 Nit: I wouldn't just write this here, since no one
Mark P 2013/08/09 22:24:11 Okay, dropped.
240 const char OmniboxFieldTrial::kBundledExperimentFieldTrialName[] =
241 "OmniboxBundledExperimentV1";
242 const char OmniboxFieldTrial::kSearchHistoryRule[] = "SearchHistory";
243 const char OmniboxFieldTrial::kReorderForLegalDefaultMatchRule[] =
244 "ReorderForLegalDefaultMatch";
245 const char OmniboxFieldTrial::kReorderForLegalDefaultMatchRuleEnabled[] =
246 "ReorderForLegalDefaultMatch";
247
236 // Background and implementation details: 248 // Background and implementation details:
237 // 249 //
238 // Each experiment group in any field trial can come with an optional set of 250 // Each experiment group in any field trial can come with an optional set of
239 // parameters (key-value pairs). In the bundled omnibox experiment 251 // parameters (key-value pairs). In the bundled omnibox experiment
240 // (kBundledExperimentFieldTrialName), each experiment group comes with a 252 // (kBundledExperimentFieldTrialName), each experiment group comes with a
241 // list of parameters in the form: 253 // list of parameters in the form:
242 // key=<Rule>:<AutocompleteInput::PageClassification (as an int)> 254 // key=<Rule>:<AutocompleteInput::PageClassification (as an int)>
243 // value=<arbitrary string> 255 // value=<arbitrary string>
244 // The AutocompleteInput::PageClassification can also be "*", which means 256 // The AutocompleteInput::PageClassification can also be "*", which means
245 // this rule applies in all page classification contexts. 257 // this rule applies in all page classification contexts.
(...skipping 18 matching lines...) Expand all
264 // Look up rule in this exact context. 276 // Look up rule in this exact context.
265 std::map<std::string, std::string>::iterator it = 277 std::map<std::string, std::string>::iterator it =
266 params.find(rule + ":" + base::IntToString( 278 params.find(rule + ":" + base::IntToString(
267 static_cast<int>(page_classification))); 279 static_cast<int>(page_classification)));
268 if (it != params.end()) 280 if (it != params.end())
269 return it->second; 281 return it->second;
270 // Look up rule in the global context. 282 // Look up rule in the global context.
271 it = params.find(rule + ":*"); 283 it = params.find(rule + ":*");
272 return (it != params.end()) ? it->second : std::string(); 284 return (it != params.end()) ? it->second : std::string();
273 } 285 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698