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 "base/metrics/field_trial.h" | 7 #include "base/metrics/field_trial.h" |
8 #include "chrome/browser/prefs/pref_service.h" | 8 #include "chrome/browser/prefs/pref_service.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 trial->UseOneTimeRandomization(); | 31 trial->UseOneTimeRandomization(); |
32 | 32 |
33 g_control_group_id_1 = trial->AppendGroup("InstantControl1", 450); // 45% | 33 g_control_group_id_1 = trial->AppendGroup("InstantControl1", 450); // 45% |
34 g_control_group_id_2 = trial->AppendGroup("InstantControl2", 450); // 45% | 34 g_control_group_id_2 = trial->AppendGroup("InstantControl2", 450); // 45% |
35 g_experiment_group_id_1 = trial->AppendGroup("InstantExperiment1", 50); // 5% | 35 g_experiment_group_id_1 = trial->AppendGroup("InstantExperiment1", 50); // 5% |
36 g_experiment_group_id_2 = trial->AppendGroup("InstantExperiment2", 50); // 5% | 36 g_experiment_group_id_2 = trial->AppendGroup("InstantExperiment2", 50); // 5% |
37 } | 37 } |
38 | 38 |
39 // static | 39 // static |
40 InstantFieldTrial::Group InstantFieldTrial::GetGroup(Profile* profile) { | 40 InstantFieldTrial::Group InstantFieldTrial::GetGroup(Profile* profile) { |
41 if (profile->IsOffTheRecord()) | 41 if (!profile || profile->IsOffTheRecord()) |
42 return INACTIVE; | 42 return INACTIVE; |
43 | 43 |
44 const PrefService* prefs = profile->GetPrefs(); | 44 const PrefService* prefs = profile->GetPrefs(); |
45 if (!prefs || | 45 if (!prefs || |
46 !prefs->GetBoolean(prefs::kSearchSuggestEnabled) || | 46 !prefs->GetBoolean(prefs::kSearchSuggestEnabled) || |
47 prefs->GetBoolean(prefs::kInstantEnabledOnce) || | 47 prefs->GetBoolean(prefs::kInstantEnabledOnce) || |
48 prefs->IsManagedPreference(prefs::kInstantEnabled)) { | 48 prefs->IsManagedPreference(prefs::kInstantEnabled)) { |
49 return INACTIVE; | 49 return INACTIVE; |
50 } | 50 } |
51 | 51 |
(...skipping 22 matching lines...) Expand all Loading... |
74 switch (GetGroup(profile)) { | 74 switch (GetGroup(profile)) { |
75 case INACTIVE: return "InstantInactive"; | 75 case INACTIVE: return "InstantInactive"; |
76 case CONTROL1: return "InstantControl1"; | 76 case CONTROL1: return "InstantControl1"; |
77 case CONTROL2: return "InstantControl2"; | 77 case CONTROL2: return "InstantControl2"; |
78 case EXPERIMENT1: return "InstantExperiment1"; | 78 case EXPERIMENT1: return "InstantExperiment1"; |
79 case EXPERIMENT2: return "InstantExperiment2"; | 79 case EXPERIMENT2: return "InstantExperiment2"; |
80 } | 80 } |
81 NOTREACHED(); | 81 NOTREACHED(); |
82 return "InstantUnknown"; | 82 return "InstantUnknown"; |
83 } | 83 } |
| 84 |
| 85 // static |
| 86 std::string InstantFieldTrial::GetGroupAsUrlParam(Profile* profile) { |
| 87 switch (GetGroup(profile)) { |
| 88 case INACTIVE: return std::string(); |
| 89 case CONTROL1: return "ix=c1&"; |
| 90 case CONTROL2: return "ix=c2&"; |
| 91 case EXPERIMENT1: return "ix=e1&"; |
| 92 case EXPERIMENT2: return "ix=e2&"; |
| 93 } |
| 94 NOTREACHED(); |
| 95 return std::string(); |
| 96 } |
OLD | NEW |