| 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" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 sync_driver::prefs::kEnhancedBookmarksExperimentEnabled)); | 80 sync_driver::prefs::kEnhancedBookmarksExperimentEnabled)); |
| 81 // If user signed out, clear possible previous state. | 81 // If user signed out, clear possible previous state. |
| 82 if (!user_signed_in) { | 82 if (!user_signed_in) { |
| 83 bookmarks_experiment_state_before = BOOKMARKS_EXPERIMENT_NONE; | 83 bookmarks_experiment_state_before = BOOKMARKS_EXPERIMENT_NONE; |
| 84 ForceFinchBookmarkExperimentIfNeeded(flags_storage, | 84 ForceFinchBookmarkExperimentIfNeeded(flags_storage, |
| 85 BOOKMARKS_EXPERIMENT_NONE); | 85 BOOKMARKS_EXPERIMENT_NONE); |
| 86 } | 86 } |
| 87 | 87 |
| 88 // kEnhancedBookmarksExperiment flag could have values "", "1" and "0". | 88 // kEnhancedBookmarksExperiment flag could have values "", "1" and "0". |
| 89 // "0" - user opted out. | 89 // "0" - user opted out. |
| 90 bool opt_out = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 90 bool opt_out = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 91 switches::kEnhancedBookmarksExperiment) == "0"; | 91 switches::kEnhancedBookmarksExperiment) == "0"; |
| 92 | 92 |
| 93 BookmarksExperimentState bookmarks_experiment_new_state = | 93 BookmarksExperimentState bookmarks_experiment_new_state = |
| 94 BOOKMARKS_EXPERIMENT_NONE; | 94 BOOKMARKS_EXPERIMENT_NONE; |
| 95 | 95 |
| 96 if (IsEnhancedBookmarksExperimentEnabledFromFinch() && !user_signed_in) { | 96 if (IsEnhancedBookmarksExperimentEnabledFromFinch() && !user_signed_in) { |
| 97 if (opt_out) { | 97 if (opt_out) { |
| 98 // Experiment enabled but user opted out. | 98 // Experiment enabled but user opted out. |
| 99 bookmarks_experiment_new_state = BOOKMARKS_EXPERIMENT_OPT_OUT_FROM_FINCH; | 99 bookmarks_experiment_new_state = BOOKMARKS_EXPERIMENT_OPT_OUT_FROM_FINCH; |
| 100 } else { | 100 } else { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 128 if (opt_out) { | 128 if (opt_out) { |
| 129 bookmarks_experiment_new_state = | 129 bookmarks_experiment_new_state = |
| 130 BOOKMARKS_EXPERIMENT_ENABLED_USER_OPT_OUT; | 130 BOOKMARKS_EXPERIMENT_ENABLED_USER_OPT_OUT; |
| 131 } else { | 131 } else { |
| 132 // User opted in again. | 132 // User opted in again. |
| 133 bookmarks_experiment_new_state = BOOKMARKS_EXPERIMENT_ENABLED; | 133 bookmarks_experiment_new_state = BOOKMARKS_EXPERIMENT_ENABLED; |
| 134 } | 134 } |
| 135 } | 135 } |
| 136 | 136 |
| 137 #if defined(OS_ANDROID) | 137 #if defined(OS_ANDROID) |
| 138 bool opt_in = !opt_out | 138 bool opt_in = !opt_out && |
| 139 && CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 139 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 140 switches::kEnhancedBookmarksExperiment) == "1"; | 140 switches::kEnhancedBookmarksExperiment) == "1"; |
| 141 if (opt_in && bookmarks_experiment_new_state == BOOKMARKS_EXPERIMENT_NONE) | 141 if (opt_in && bookmarks_experiment_new_state == BOOKMARKS_EXPERIMENT_NONE) |
| 142 bookmarks_experiment_new_state = BOOKMARKS_EXPERIMENT_ENABLED; | 142 bookmarks_experiment_new_state = BOOKMARKS_EXPERIMENT_ENABLED; |
| 143 #endif | 143 #endif |
| 144 | 144 |
| 145 UMA_HISTOGRAM_ENUMERATION("EnhancedBookmarks.SyncExperimentState", | 145 UMA_HISTOGRAM_ENUMERATION("EnhancedBookmarks.SyncExperimentState", |
| 146 bookmarks_experiment_new_state, | 146 bookmarks_experiment_new_state, |
| 147 BOOKMARKS_EXPERIMENT_ENUM_SIZE); | 147 BOOKMARKS_EXPERIMENT_ENUM_SIZE); |
| 148 user_prefs->SetInteger( | 148 user_prefs->SetInteger( |
| 149 sync_driver::prefs::kEnhancedBookmarksExperimentEnabled, | 149 sync_driver::prefs::kEnhancedBookmarksExperimentEnabled, |
| 150 bookmarks_experiment_new_state); | 150 bookmarks_experiment_new_state); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 about_flags::FlagsStorage* flags_storage) { | 195 about_flags::FlagsStorage* flags_storage) { |
| 196 #if defined(OS_CHROMEOS) | 196 #if defined(OS_CHROMEOS) |
| 197 // We are not setting command line flags on Chrome OS to avoid browser restart | 197 // We are not setting command line flags on Chrome OS to avoid browser restart |
| 198 // but still have flags in flags_storage. So check flags_storage instead. | 198 // but still have flags in flags_storage. So check flags_storage instead. |
| 199 const std::set<std::string> flags = flags_storage->GetFlags(); | 199 const std::set<std::string> flags = flags_storage->GetFlags(); |
| 200 if (flags.find(switches::kManualEnhancedBookmarks) != flags.end()) | 200 if (flags.find(switches::kManualEnhancedBookmarks) != flags.end()) |
| 201 return true; | 201 return true; |
| 202 if (flags.find(switches::kManualEnhancedBookmarksOptout) != flags.end()) | 202 if (flags.find(switches::kManualEnhancedBookmarksOptout) != flags.end()) |
| 203 return true; | 203 return true; |
| 204 #else | 204 #else |
| 205 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 205 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 206 if (command_line->HasSwitch(switches::kManualEnhancedBookmarks) || | 206 if (command_line->HasSwitch(switches::kManualEnhancedBookmarks) || |
| 207 command_line->HasSwitch(switches::kManualEnhancedBookmarksOptout)) { | 207 command_line->HasSwitch(switches::kManualEnhancedBookmarksOptout)) { |
| 208 return true; | 208 return true; |
| 209 } | 209 } |
| 210 #endif | 210 #endif |
| 211 | 211 |
| 212 return IsEnhancedBookmarksExperimentEnabledFromFinch(); | 212 return IsEnhancedBookmarksExperimentEnabledFromFinch(); |
| 213 } | 213 } |
| 214 | 214 |
| 215 #if defined(OS_ANDROID) | 215 #if defined(OS_ANDROID) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 230 bool IsEnhancedBookmarksEnabled(const PrefService* user_prefs) { | 230 bool IsEnhancedBookmarksEnabled(const PrefService* user_prefs) { |
| 231 BookmarksExperimentState bookmarks_experiment_state = | 231 BookmarksExperimentState bookmarks_experiment_state = |
| 232 static_cast<BookmarksExperimentState>(user_prefs->GetInteger( | 232 static_cast<BookmarksExperimentState>(user_prefs->GetInteger( |
| 233 sync_driver::prefs::kEnhancedBookmarksExperimentEnabled)); | 233 sync_driver::prefs::kEnhancedBookmarksExperimentEnabled)); |
| 234 return bookmarks_experiment_state == BOOKMARKS_EXPERIMENT_ENABLED || | 234 return bookmarks_experiment_state == BOOKMARKS_EXPERIMENT_ENABLED || |
| 235 bookmarks_experiment_state == BOOKMARKS_EXPERIMENT_ENABLED_FROM_FINCH; | 235 bookmarks_experiment_state == BOOKMARKS_EXPERIMENT_ENABLED_FROM_FINCH; |
| 236 } | 236 } |
| 237 #endif | 237 #endif |
| 238 | 238 |
| 239 bool IsEnableDomDistillerSet() { | 239 bool IsEnableDomDistillerSet() { |
| 240 if (CommandLine::ForCurrentProcess()-> | 240 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 241 HasSwitch(switches::kEnableDomDistiller)) { | 241 switches::kEnableDomDistiller)) { |
| 242 return true; | 242 return true; |
| 243 } | 243 } |
| 244 if (variations::GetVariationParamValue( | 244 if (variations::GetVariationParamValue( |
| 245 kFieldTrialName, "enable-dom-distiller") == "1") | 245 kFieldTrialName, "enable-dom-distiller") == "1") |
| 246 return true; | 246 return true; |
| 247 | 247 |
| 248 return false; | 248 return false; |
| 249 } | 249 } |
| 250 | 250 |
| 251 bool IsEnableSyncArticlesSet() { | 251 bool IsEnableSyncArticlesSet() { |
| 252 if (CommandLine::ForCurrentProcess()-> | 252 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 253 HasSwitch(switches::kEnableSyncArticles)) { | 253 switches::kEnableSyncArticles)) { |
| 254 return true; | 254 return true; |
| 255 } | 255 } |
| 256 if (variations::GetVariationParamValue( | 256 if (variations::GetVariationParamValue( |
| 257 kFieldTrialName, "enable-sync-articles") == "1") | 257 kFieldTrialName, "enable-sync-articles") == "1") |
| 258 return true; | 258 return true; |
| 259 | 259 |
| 260 return false; | 260 return false; |
| 261 } | 261 } |
| OLD | NEW |