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_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 kDisallowInlineHQPFieldTrialName[] = "OmniboxDisallowInlineHQP"; | 20 const char kDisallowInlineHQPFieldTrialName[] = "OmniboxDisallowInlineHQP"; |
21 const char kHUPCullRedirectsFieldTrialName[] = "OmniboxHUPCullRedirects"; | 21 const char kHUPCullRedirectsFieldTrialName[] = "OmniboxHUPCullRedirects"; |
22 const char kHUPCreateShorterMatchFieldTrialName[] = | 22 const char kHUPCreateShorterMatchFieldTrialName[] = |
23 "OmniboxHUPCreateShorterMatch"; | 23 "OmniboxHUPCreateShorterMatch"; |
24 const char kStopTimerFieldTrialName[] = "OmniboxStopTimer"; | 24 const char kStopTimerFieldTrialName[] = "OmniboxStopTimer"; |
| 25 const char kShortcutsScoringFieldTrialName[] = "OmniboxShortcutsScoring"; |
25 | 26 |
26 // The autocomplete dynamic field trial name prefix. Each field trial is | 27 // The autocomplete dynamic field trial name prefix. Each field trial is |
27 // configured dynamically and is retrieved automatically by Chrome during | 28 // configured dynamically and is retrieved automatically by Chrome during |
28 // the startup. | 29 // the startup. |
29 const char kAutocompleteDynamicFieldTrialPrefix[] = "AutocompleteDynamicTrial_"; | 30 const char kAutocompleteDynamicFieldTrialPrefix[] = "AutocompleteDynamicTrial_"; |
30 // The maximum number of the autocomplete dynamic field trials (aka layers). | 31 // The maximum number of the autocomplete dynamic field trials (aka layers). |
31 const int kMaxAutocompleteDynamicFieldTrials = 5; | 32 const int kMaxAutocompleteDynamicFieldTrials = 5; |
32 | 33 |
33 // Field trial experiment probabilities. | 34 // Field trial experiment probabilities. |
34 | 35 |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 // Look for group names starting with "EnableZeroSuggest" | 234 // Look for group names starting with "EnableZeroSuggest" |
234 for (int i = 0; i < kMaxAutocompleteDynamicFieldTrials; ++i) { | 235 for (int i = 0; i < kMaxAutocompleteDynamicFieldTrials; ++i) { |
235 const std::string& group_name = base::FieldTrialList::FindFullName( | 236 const std::string& group_name = base::FieldTrialList::FindFullName( |
236 DynamicFieldTrialName(i)); | 237 DynamicFieldTrialName(i)); |
237 const char kEnableZeroSuggest[] = "EnableZeroSuggest"; | 238 const char kEnableZeroSuggest[] = "EnableZeroSuggest"; |
238 if (StartsWithASCII(group_name, kEnableZeroSuggest, true)) | 239 if (StartsWithASCII(group_name, kEnableZeroSuggest, true)) |
239 return true; | 240 return true; |
240 } | 241 } |
241 return false; | 242 return false; |
242 } | 243 } |
| 244 |
| 245 // If the active group name starts with "MaxRelevance_", extract the |
| 246 // int that immediately following that, returning true on success. |
| 247 bool OmniboxFieldTrial::ShortcutsScoringMaxRelevance(int* max_relevance) { |
| 248 std::string group_name = |
| 249 base::FieldTrialList::FindFullName(kShortcutsScoringFieldTrialName); |
| 250 const char kMaxRelevanceGroupPrefix[] = "MaxRelevance_"; |
| 251 if (!StartsWithASCII(group_name, kMaxRelevanceGroupPrefix, true)) |
| 252 return false; |
| 253 if (!base::StringToInt(base::StringPiece( |
| 254 group_name.substr(strlen(kMaxRelevanceGroupPrefix))), |
| 255 max_relevance)) { |
| 256 LOG(WARNING) << "Malformed MaxRelevance string: " << group_name; |
| 257 return false; |
| 258 } |
| 259 return true; |
| 260 } |
OLD | NEW |