OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/instant/instant_field_trial.h" | 5 #include "chrome/browser/instant/instant_field_trial.h" |
6 | 6 |
7 #include "chrome/browser/prefs/pref_service.h" | 7 #include "chrome/browser/prefs/pref_service.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/common/pref_names.h" | 9 #include "chrome/common/pref_names.h" |
10 | 10 |
11 namespace { | 11 namespace { |
12 bool field_trial_active_ = false; | 12 bool field_trial_active_ = false; |
13 } | 13 } |
14 | 14 |
15 // static | 15 // static |
16 void InstantFieldTrial::Activate() { | 16 void InstantFieldTrial::Activate() { |
17 field_trial_active_ = true; | 17 field_trial_active_ = true; |
18 } | 18 } |
19 | 19 |
20 // static | 20 // static |
21 InstantFieldTrial::Group InstantFieldTrial::GetGroup(Profile* profile) { | 21 InstantFieldTrial::Group InstantFieldTrial::GetGroup(Profile* profile) { |
22 if (!field_trial_active_) | 22 if (!field_trial_active_) |
23 return INACTIVE; | 23 return INACTIVE; |
24 | 24 |
25 if (profile->IsOffTheRecord()) | 25 if (profile->IsOffTheRecord()) |
26 return INACTIVE; | 26 return INACTIVE; |
27 | 27 |
28 const PrefService* prefs = profile->GetPrefs(); | 28 const PrefService* prefs = profile->GetPrefs(); |
29 if (!prefs || | 29 if (!prefs || |
| 30 !prefs->GetBoolean(prefs::kSearchSuggestEnabled) || |
30 prefs->GetBoolean(prefs::kInstantEnabledOnce) || | 31 prefs->GetBoolean(prefs::kInstantEnabledOnce) || |
31 prefs->IsManagedPreference(prefs::kInstantEnabled)) { | 32 prefs->IsManagedPreference(prefs::kInstantEnabled)) { |
32 return INACTIVE; | 33 return INACTIVE; |
33 } | 34 } |
34 | 35 |
35 const int random = prefs->GetInteger(prefs::kInstantFieldTrialRandomDraw); | 36 const int random = prefs->GetInteger(prefs::kInstantFieldTrialRandomDraw); |
36 return random < 4500 ? CONTROL1 : // 45% | 37 return random < 4500 ? CONTROL1 : // 45% |
37 random < 9000 ? CONTROL2 : // 45% | 38 random < 9000 ? CONTROL2 : // 45% |
38 random < 9500 ? EXPERIMENT1 // 5% | 39 random < 9500 ? EXPERIMENT1 // 5% |
39 : EXPERIMENT2; // 5% | 40 : EXPERIMENT2; // 5% |
(...skipping 10 matching lines...) Expand all Loading... |
50 switch (GetGroup(profile)) { | 51 switch (GetGroup(profile)) { |
51 case INACTIVE: return "InstantInactive"; | 52 case INACTIVE: return "InstantInactive"; |
52 case CONTROL1: return "InstantControl1"; | 53 case CONTROL1: return "InstantControl1"; |
53 case CONTROL2: return "InstantControl2"; | 54 case CONTROL2: return "InstantControl2"; |
54 case EXPERIMENT1: return "InstantExperiment1"; | 55 case EXPERIMENT1: return "InstantExperiment1"; |
55 case EXPERIMENT2: return "InstantExperiment2"; | 56 case EXPERIMENT2: return "InstantExperiment2"; |
56 } | 57 } |
57 NOTREACHED(); | 58 NOTREACHED(); |
58 return "InstantUnknown"; | 59 return "InstantUnknown"; |
59 } | 60 } |
OLD | NEW |