OLD | NEW |
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/variations/variation_ids.h" | 16 #include "chrome/common/metrics/variations/variation_ids.h" |
17 #include "chrome/common/metrics/variations/variations_util.h" | 17 #include "chrome/common/metrics/variations/variations_util.h" |
18 #include "components/variations/metrics_util.h" | 18 #include "components/variations/metrics_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 kEnableZeroSuggestGroupPrefix[] = "EnableZeroSuggest"; | 27 const char kEnableZeroSuggestGroupPrefix[] = "EnableZeroSuggest"; |
28 const char kEnableZeroSuggestMostVisitedGroupPrefix[] = | 28 const char kEnableZeroSuggestMostVisitedGroupPrefix[] = |
29 "EnableZeroSuggestMostVisited"; | 29 "EnableZeroSuggestMostVisited"; |
| 30 const char kEnableZeroSuggestSearchGroupPrefix[] = "EnableZeroSuggestSearch"; |
30 | 31 |
31 // The autocomplete dynamic field trial name prefix. Each field trial is | 32 // The autocomplete dynamic field trial name prefix. Each field trial is |
32 // configured dynamically and is retrieved automatically by Chrome during | 33 // configured dynamically and is retrieved automatically by Chrome during |
33 // the startup. | 34 // the startup. |
34 const char kAutocompleteDynamicFieldTrialPrefix[] = "AutocompleteDynamicTrial_"; | 35 const char kAutocompleteDynamicFieldTrialPrefix[] = "AutocompleteDynamicTrial_"; |
35 // The maximum number of the autocomplete dynamic field trials (aka layers). | 36 // The maximum number of the autocomplete dynamic field trials (aka layers). |
36 const int kMaxAutocompleteDynamicFieldTrials = 5; | 37 const int kMaxAutocompleteDynamicFieldTrials = 5; |
37 | 38 |
38 // Field trial experiment probabilities. | 39 // Field trial experiment probabilities. |
39 | 40 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 | 203 |
203 bool OmniboxFieldTrial::InZeroSuggestFieldTrial() { | 204 bool OmniboxFieldTrial::InZeroSuggestFieldTrial() { |
204 return HasDynamicFieldTrialGroupPrefix(kEnableZeroSuggestGroupPrefix); | 205 return HasDynamicFieldTrialGroupPrefix(kEnableZeroSuggestGroupPrefix); |
205 } | 206 } |
206 | 207 |
207 bool OmniboxFieldTrial::InZeroSuggestMostVisitedFieldTrial() { | 208 bool OmniboxFieldTrial::InZeroSuggestMostVisitedFieldTrial() { |
208 return HasDynamicFieldTrialGroupPrefix( | 209 return HasDynamicFieldTrialGroupPrefix( |
209 kEnableZeroSuggestMostVisitedGroupPrefix); | 210 kEnableZeroSuggestMostVisitedGroupPrefix); |
210 } | 211 } |
211 | 212 |
| 213 bool OmniboxFieldTrial::InZeroSuggestSearchFieldTrial() { |
| 214 return HasDynamicFieldTrialGroupPrefix(kEnableZeroSuggestSearchGroupPrefix); |
| 215 } |
| 216 |
212 bool OmniboxFieldTrial::ShortcutsScoringMaxRelevance( | 217 bool OmniboxFieldTrial::ShortcutsScoringMaxRelevance( |
213 AutocompleteInput::PageClassification current_page_classification, | 218 AutocompleteInput::PageClassification current_page_classification, |
214 int* max_relevance) { | 219 int* max_relevance) { |
215 // The value of the rule is a string that encodes an integer containing | 220 // The value of the rule is a string that encodes an integer containing |
216 // the max relevance. | 221 // the max relevance. |
217 const std::string& max_relevance_str = | 222 const std::string& max_relevance_str = |
218 OmniboxFieldTrial::GetValueForRuleInContext( | 223 OmniboxFieldTrial::GetValueForRuleInContext( |
219 kShortcutsScoringMaxRelevanceRule, current_page_classification); | 224 kShortcutsScoringMaxRelevanceRule, current_page_classification); |
220 if (max_relevance_str.empty()) | 225 if (max_relevance_str.empty()) |
221 return false; | 226 return false; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 if (it != params.end()) | 343 if (it != params.end()) |
339 return it->second; | 344 return it->second; |
340 // Fall back to the global instant extended context. | 345 // Fall back to the global instant extended context. |
341 it = params.find(rule + ":" + page_classification_str + ":*"); | 346 it = params.find(rule + ":" + page_classification_str + ":*"); |
342 if (it != params.end()) | 347 if (it != params.end()) |
343 return it->second; | 348 return it->second; |
344 // Look up rule in the global context. | 349 // Look up rule in the global context. |
345 it = params.find(rule + ":*:*"); | 350 it = params.find(rule + ":*:*"); |
346 return (it != params.end()) ? it->second : std::string(); | 351 return (it != params.end()) ? it->second : std::string(); |
347 } | 352 } |
OLD | NEW |