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

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: rebase 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_split.h" 11 #include "base/strings/string_split.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
14 #include "chrome/browser/autocomplete/autocomplete_input.h" 14 #include "chrome/browser/autocomplete/autocomplete_input.h"
15 #include "chrome/browser/search/search.h" 15 #include "chrome/browser/search/search.h"
16 #include "chrome/common/metrics/metrics_util.h" 16 #include "chrome/common/metrics/metrics_util.h"
17 #include "chrome/common/metrics/variations/variation_ids.h" 17 #include "chrome/common/metrics/variations/variation_ids.h"
18 #include "chrome/common/metrics/variations/variations_util.h" 18 #include "chrome/common/metrics/variations/variations_util.h"
19 19
20 namespace { 20 namespace {
21 21
22 // Field trial names. 22 // Field trial names.
23 const char kHUPCullRedirectsFieldTrialName[] = "OmniboxHUPCullRedirects"; 23 const char kHUPCullRedirectsFieldTrialName[] = "OmniboxHUPCullRedirects";
24 const char kHUPCreateShorterMatchFieldTrialName[] = 24 const char kHUPCreateShorterMatchFieldTrialName[] =
25 "OmniboxHUPCreateShorterMatch"; 25 "OmniboxHUPCreateShorterMatch";
26 const char kStopTimerFieldTrialName[] = "OmniboxStopTimer"; 26 const char kStopTimerFieldTrialName[] = "OmniboxStopTimer";
27 const char kBundledExperimentFieldTrialName[] = "OmniboxBundledExperimentV1";
28
29 // Rule names used by the bundled experiment.
30 const char kShortcutsScoringMaxRelevanceRule[] = "ShortcutsScoringMaxRelevance";
31 const char kSearchHistoryRule[] = "SearchHistory";
32 const char kDemoteByTypeRule[] = "DemoteByType";
33 27
34 // The autocomplete dynamic field trial name prefix. Each field trial is 28 // The autocomplete dynamic field trial name prefix. Each field trial is
35 // configured dynamically and is retrieved automatically by Chrome during 29 // configured dynamically and is retrieved automatically by Chrome during
36 // the startup. 30 // the startup.
37 const char kAutocompleteDynamicFieldTrialPrefix[] = "AutocompleteDynamicTrial_"; 31 const char kAutocompleteDynamicFieldTrialPrefix[] = "AutocompleteDynamicTrial_";
38 // The maximum number of the autocomplete dynamic field trials (aka layers). 32 // The maximum number of the autocomplete dynamic field trials (aka layers).
39 const int kMaxAutocompleteDynamicFieldTrials = 5; 33 const int kMaxAutocompleteDynamicFieldTrials = 5;
40 34
41 // Field trial experiment probabilities. 35 // Field trial experiment probabilities.
42 36
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 // errors smartly. 246 // errors smartly.
253 int k, v; 247 int k, v;
254 base::StringToInt(it->first, &k); 248 base::StringToInt(it->first, &k);
255 base::StringToInt(it->second, &v); 249 base::StringToInt(it->second, &v);
256 (*demotions_by_type)[static_cast<AutocompleteMatchType::Type>(k)] = 250 (*demotions_by_type)[static_cast<AutocompleteMatchType::Type>(k)] =
257 static_cast<float>(v) / 100.0f; 251 static_cast<float>(v) / 100.0f;
258 } 252 }
259 } 253 }
260 } 254 }
261 255
256 bool OmniboxFieldTrial::ReorderForLegalDefaultMatch(
257 AutocompleteInput::PageClassification current_page_classification) {
258 return OmniboxFieldTrial::GetValueForRuleInContext(
259 kReorderForLegalDefaultMatchRule, current_page_classification) ==
260 kReorderForLegalDefaultMatchRuleEnabled;
261 }
262
263 const char OmniboxFieldTrial::kBundledExperimentFieldTrialName[] =
264 "OmniboxBundledExperimentV1";
265 const char OmniboxFieldTrial::kShortcutsScoringMaxRelevanceRule[] =
266 "ShortcutsScoringMaxRelevance";
267 const char OmniboxFieldTrial::kSearchHistoryRule[] = "SearchHistory";
268 const char OmniboxFieldTrial::kDemoteByTypeRule[] = "DemoteByType";
269 const char OmniboxFieldTrial::kReorderForLegalDefaultMatchRule[] =
270 "ReorderForLegalDefaultMatch";
271 const char OmniboxFieldTrial::kReorderForLegalDefaultMatchRuleEnabled[] =
272 "ReorderForLegalDefaultMatch";
273
262 // Background and implementation details: 274 // Background and implementation details:
263 // 275 //
264 // Each experiment group in any field trial can come with an optional set of 276 // Each experiment group in any field trial can come with an optional set of
265 // parameters (key-value pairs). In the bundled omnibox experiment 277 // parameters (key-value pairs). In the bundled omnibox experiment
266 // (kBundledExperimentFieldTrialName), each experiment group comes with a 278 // (kBundledExperimentFieldTrialName), each experiment group comes with a
267 // list of parameters in the form: 279 // list of parameters in the form:
268 // key=<Rule>: 280 // key=<Rule>:
269 // <AutocompleteInput::PageClassification (as an int)>: 281 // <AutocompleteInput::PageClassification (as an int)>:
270 // <whether Instant Extended is enabled (as a 1 or 0)> 282 // <whether Instant Extended is enabled (as a 1 or 0)>
271 // (note that there are no linebreaks in keys; this format is for 283 // (note that there are no linebreaks in keys; this format is for
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 if (it != params.end()) 326 if (it != params.end())
315 return it->second; 327 return it->second;
316 // Fall back to the global instant extended context. 328 // Fall back to the global instant extended context.
317 it = params.find(rule + ":" + page_classification_str + ":*"); 329 it = params.find(rule + ":" + page_classification_str + ":*");
318 if (it != params.end()) 330 if (it != params.end())
319 return it->second; 331 return it->second;
320 // Look up rule in the global context. 332 // Look up rule in the global context.
321 it = params.find(rule + ":*:*"); 333 it = params.find(rule + ":*:*");
322 return (it != params.end()) ? it->second : std::string(); 334 return (it != params.end()) ? it->second : std::string();
323 } 335 }
OLDNEW
« 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