| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/bookmarks/enhanced_bookmarks_features.h" | 5 #include "chrome/browser/bookmarks/enhanced_bookmarks_features.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/prefs/scoped_user_pref_update.h" | 10 #include "base/prefs/scoped_user_pref_update.h" |
| 11 #include "base/sha1.h" | 11 #include "base/sha1.h" |
| 12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 13 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/signin/signin_manager_factory.h" |
| 13 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
| 14 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
| 18 #include "components/signin/core/browser/signin_manager.h" |
| 15 #include "components/sync_driver/pref_names.h" | 19 #include "components/sync_driver/pref_names.h" |
| 16 #include "components/variations/variations_associated_data.h" | 20 #include "components/variations/variations_associated_data.h" |
| 17 #include "extensions/common/features/feature.h" | 21 #include "extensions/common/features/feature.h" |
| 18 #include "extensions/common/features/feature_provider.h" | 22 #include "extensions/common/features/feature_provider.h" |
| 19 | 23 |
| 20 namespace { | 24 namespace { |
| 21 | 25 |
| 22 const char kFieldTrialName[] = "EnhancedBookmarks"; | 26 const char kFieldTrialName[] = "EnhancedBookmarks"; |
| 23 | 27 |
| 24 // Get extension id from Finch EnhancedBookmarks group parameters. | 28 // Get extension id from Finch EnhancedBookmarks group parameters. |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 BOOKMARKS_EXPERIMENT_ENABLED_USER_OPT_OUT) { | 126 BOOKMARKS_EXPERIMENT_ENABLED_USER_OPT_OUT) { |
| 123 if (opt_out) { | 127 if (opt_out) { |
| 124 bookmarks_experiment_new_state = | 128 bookmarks_experiment_new_state = |
| 125 BOOKMARKS_EXPERIMENT_ENABLED_USER_OPT_OUT; | 129 BOOKMARKS_EXPERIMENT_ENABLED_USER_OPT_OUT; |
| 126 } else { | 130 } else { |
| 127 // User opted in again. | 131 // User opted in again. |
| 128 bookmarks_experiment_new_state = BOOKMARKS_EXPERIMENT_ENABLED; | 132 bookmarks_experiment_new_state = BOOKMARKS_EXPERIMENT_ENABLED; |
| 129 } | 133 } |
| 130 } | 134 } |
| 131 | 135 |
| 136 #if defined(OS_ANDROID) |
| 137 bool opt_in = !opt_out |
| 138 && CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 139 switches::kEnhancedBookmarksExperiment) == "1"; |
| 140 if (opt_in && bookmarks_experiment_new_state == BOOKMARKS_EXPERIMENT_NONE) |
| 141 bookmarks_experiment_new_state = BOOKMARKS_EXPERIMENT_ENABLED; |
| 142 #endif |
| 143 |
| 132 UMA_HISTOGRAM_ENUMERATION("EnhancedBookmarks.SyncExperimentState", | 144 UMA_HISTOGRAM_ENUMERATION("EnhancedBookmarks.SyncExperimentState", |
| 133 bookmarks_experiment_new_state, | 145 bookmarks_experiment_new_state, |
| 134 BOOKMARKS_EXPERIMENT_ENUM_SIZE); | 146 BOOKMARKS_EXPERIMENT_ENUM_SIZE); |
| 135 user_prefs->SetInteger( | 147 user_prefs->SetInteger( |
| 136 sync_driver::prefs::kEnhancedBookmarksExperimentEnabled, | 148 sync_driver::prefs::kEnhancedBookmarksExperimentEnabled, |
| 137 bookmarks_experiment_new_state); | 149 bookmarks_experiment_new_state); |
| 138 ForceFinchBookmarkExperimentIfNeeded(flags_storage, | 150 ForceFinchBookmarkExperimentIfNeeded(flags_storage, |
| 139 bookmarks_experiment_new_state); | 151 bookmarks_experiment_new_state); |
| 140 } | 152 } |
| 141 | 153 |
| 154 void InitBookmarksExperimentState(Profile* profile) { |
| 155 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile); |
| 156 bool is_signed_in = signin && !signin->IsAuthenticated(); |
| 157 UpdateBookmarksExperimentState( |
| 158 profile->GetPrefs(), |
| 159 g_browser_process->local_state(), |
| 160 is_signed_in, |
| 161 BOOKMARKS_EXPERIMENT_ENABLED_FROM_SYNC_UNKNOWN); |
| 162 } |
| 163 |
| 142 void ForceFinchBookmarkExperimentIfNeeded( | 164 void ForceFinchBookmarkExperimentIfNeeded( |
| 143 PrefService* flags_storage, | 165 PrefService* flags_storage, |
| 144 BookmarksExperimentState bookmarks_experiment_state) { | 166 BookmarksExperimentState bookmarks_experiment_state) { |
| 145 if (!flags_storage) | 167 if (!flags_storage) |
| 146 return; | 168 return; |
| 147 ListPrefUpdate update(flags_storage, prefs::kEnabledLabsExperiments); | 169 ListPrefUpdate update(flags_storage, prefs::kEnabledLabsExperiments); |
| 148 base::ListValue* experiments_list = update.Get(); | 170 base::ListValue* experiments_list = update.Get(); |
| 149 if (!experiments_list) | 171 if (!experiments_list) |
| 150 return; | 172 return; |
| 151 size_t index; | 173 size_t index; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 if (CommandLine::ForCurrentProcess()-> | 240 if (CommandLine::ForCurrentProcess()-> |
| 219 HasSwitch(switches::kEnableSyncArticles)) { | 241 HasSwitch(switches::kEnableSyncArticles)) { |
| 220 return true; | 242 return true; |
| 221 } | 243 } |
| 222 if (variations::GetVariationParamValue( | 244 if (variations::GetVariationParamValue( |
| 223 kFieldTrialName, "enable-sync-articles") == "1") | 245 kFieldTrialName, "enable-sync-articles") == "1") |
| 224 return true; | 246 return true; |
| 225 | 247 |
| 226 return false; | 248 return false; |
| 227 } | 249 } |
| OLD | NEW |