| 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/ui/webui/sync_promo/sync_promo_trial.h" | 5 #include "chrome/browser/ui/webui/sync_promo/sync_promo_trial.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
| 9 #include "base/string_number_conversions.h" |
| 9 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 10 #include "chrome/browser/google/google_util.h" | 11 #include "chrome/browser/google/google_util.h" |
| 11 #include "chrome/browser/metrics/metrics_service.h" | 12 #include "chrome/browser/metrics/metrics_service.h" |
| 12 #include "chrome/browser/prefs/pref_service.h" | 13 #include "chrome/browser/prefs/pref_service.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" | 15 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" |
| 15 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
| 16 #include "chrome/common/chrome_version_info.h" | 17 #include "chrome/common/chrome_version_info.h" |
| 17 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
| 18 #include "content/public/browser/web_ui.h" | 19 #include "content/public/browser/web_ui.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 33 }; | 34 }; |
| 34 | 35 |
| 35 // Flag to make sure sync_promo_trial::Activate() has been called. | 36 // Flag to make sure sync_promo_trial::Activate() has been called. |
| 36 bool sync_promo_trial_initialized; | 37 bool sync_promo_trial_initialized; |
| 37 | 38 |
| 38 // Checks if a sync promo layout experiment is active. If it is active then the | 39 // Checks if a sync promo layout experiment is active. If it is active then the |
| 39 // layout type is return in |type|. | 40 // layout type is return in |type|. |
| 40 bool GetActiveLayoutExperiment(LayoutExperimentType* type) { | 41 bool GetActiveLayoutExperiment(LayoutExperimentType* type) { |
| 41 DCHECK(type); | 42 DCHECK(type); |
| 42 | 43 |
| 43 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSyncPromoVersion)) | 44 int version = 0; |
| 44 return false; | 45 if (base::StringToInt(CommandLine::ForCurrentProcess()-> |
| 46 GetSwitchValueASCII(switches::kSyncPromoVersion), &version)) { |
| 47 switch (version) { |
| 48 case SyncPromoUI::VERSION_DEFAULT: |
| 49 *type = LAYOUT_EXPERIMENT_DEFAULT; |
| 50 return true; |
| 51 case SyncPromoUI::VERSION_DEVICES: |
| 52 *type = LAYOUT_EXPERIMENT_DEVICES; |
| 53 return true; |
| 54 case SyncPromoUI::VERSION_VERBOSE: |
| 55 *type = LAYOUT_EXPERIMENT_VERBOSE; |
| 56 return true; |
| 57 case SyncPromoUI::VERSION_SIMPLE: |
| 58 *type = LAYOUT_EXPERIMENT_SIMPLE; |
| 59 return true; |
| 60 case SyncPromoUI::VERSION_DIALOG: |
| 61 *type = LAYOUT_EXPERIMENT_DIALOG; |
| 62 return true; |
| 63 default: |
| 64 return false; |
| 65 } |
| 66 } |
| 45 | 67 |
| 46 if (chrome::VersionInfo::GetChannel() == | 68 if (chrome::VersionInfo::GetChannel() == |
| 47 chrome::VersionInfo::CHANNEL_STABLE) { | 69 chrome::VersionInfo::CHANNEL_STABLE) { |
| 48 std::string brand; | 70 std::string brand; |
| 49 if (!google_util::GetBrand(&brand)) | 71 if (!google_util::GetBrand(&brand)) |
| 50 return false; | 72 return false; |
| 51 | 73 |
| 52 if (brand == "GGRG" || brand == "CHCG") | 74 if (brand == "GGRG" || brand == "CHCG") |
| 53 *type = LAYOUT_EXPERIMENT_DEFAULT; | 75 *type = LAYOUT_EXPERIMENT_DEFAULT; |
| 54 else if (brand == "GGRH" || brand == "CHCH") | 76 else if (brand == "GGRH" || brand == "CHCH") |
| (...skipping 24 matching lines...) Expand all Loading... |
| 79 namespace sync_promo_trial { | 101 namespace sync_promo_trial { |
| 80 | 102 |
| 81 void Activate() { | 103 void Activate() { |
| 82 DCHECK(!sync_promo_trial_initialized); | 104 DCHECK(!sync_promo_trial_initialized); |
| 83 sync_promo_trial_initialized = true; | 105 sync_promo_trial_initialized = true; |
| 84 | 106 |
| 85 // For stable builds we'll use brand codes to enroll uesrs into experiments. | 107 // For stable builds we'll use brand codes to enroll uesrs into experiments. |
| 86 // For dev and beta we don't have brand codes so we randomly enroll users. | 108 // For dev and beta we don't have brand codes so we randomly enroll users. |
| 87 if (chrome::VersionInfo::GetChannel() != | 109 if (chrome::VersionInfo::GetChannel() != |
| 88 chrome::VersionInfo::CHANNEL_STABLE) { | 110 chrome::VersionInfo::CHANNEL_STABLE) { |
| 111 #if defined(GOOGLE_CHROME_BUILD) |
| 89 // Create a field trial that expires in August 8, 2012. It contains 6 groups | 112 // Create a field trial that expires in August 8, 2012. It contains 6 groups |
| 90 // with each group having an equal chance of enrollment. | 113 // with each group having an equal chance of enrollment. |
| 91 scoped_refptr<base::FieldTrial> trial(new base::FieldTrial( | 114 scoped_refptr<base::FieldTrial> trial(new base::FieldTrial( |
| 92 kLayoutExperimentTrialName, 5, "default", 2012, 8, 1)); | 115 kLayoutExperimentTrialName, 6, "default", 2012, 8, 1)); |
| 93 if (base::FieldTrialList::IsOneTimeRandomizationEnabled()) | 116 if (base::FieldTrialList::IsOneTimeRandomizationEnabled()) |
| 94 trial->UseOneTimeRandomization(); | 117 trial->UseOneTimeRandomization(); |
| 95 trial->AppendGroup("", 1); | 118 trial->AppendGroup("", 1); |
| 96 trial->AppendGroup("", 1); | 119 trial->AppendGroup("", 1); |
| 97 trial->AppendGroup("", 1); | 120 trial->AppendGroup("", 1); |
| 98 trial->AppendGroup("", 1); | 121 trial->AppendGroup("", 1); |
| 99 trial->AppendGroup("", 1); | 122 trial->AppendGroup("", 1); |
| 123 #endif |
| 100 } | 124 } |
| 101 } | 125 } |
| 102 | 126 |
| 103 StartupOverride GetStartupOverrideForCurrentTrial() { | 127 StartupOverride GetStartupOverrideForCurrentTrial() { |
| 104 DCHECK(sync_promo_trial_initialized); | 128 DCHECK(sync_promo_trial_initialized); |
| 105 | 129 |
| 106 LayoutExperimentType type; | 130 LayoutExperimentType type; |
| 107 if (GetActiveLayoutExperiment(&type)) { | 131 if (GetActiveLayoutExperiment(&type)) { |
| 108 return type == LAYOUT_EXPERIMENT_NONE ? STARTUP_OVERRIDE_HIDE : | 132 return type == LAYOUT_EXPERIMENT_NONE ? STARTUP_OVERRIDE_HIDE : |
| 109 STARTUP_OVERRIDE_SHOW; | 133 STARTUP_OVERRIDE_SHOW; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 return true; | 194 return true; |
| 171 case LAYOUT_EXPERIMENT_DIALOG: | 195 case LAYOUT_EXPERIMENT_DIALOG: |
| 172 *version = SyncPromoUI::VERSION_DIALOG; | 196 *version = SyncPromoUI::VERSION_DIALOG; |
| 173 return true; | 197 return true; |
| 174 default: | 198 default: |
| 175 return false; | 199 return false; |
| 176 } | 200 } |
| 177 } | 201 } |
| 178 | 202 |
| 179 } // namespace sync_promo_trial | 203 } // namespace sync_promo_trial |
| OLD | NEW |