| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 } | 48 } |
| 49 if (bookmarks_experiment_state == kBookmarksExperimentEnabled) { | 49 if (bookmarks_experiment_state == kBookmarksExperimentEnabled) { |
| 50 *extension_id = user_prefs->GetString( | 50 *extension_id = user_prefs->GetString( |
| 51 sync_driver::prefs::kEnhancedBookmarksExtensionId); | 51 sync_driver::prefs::kEnhancedBookmarksExtensionId); |
| 52 return !extension_id->empty(); | 52 return !extension_id->empty(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 return false; | 55 return false; |
| 56 } | 56 } |
| 57 | 57 |
| 58 void UpdateBookmarksExperimentState(const PrefService* user_prefs, | 58 void UpdateBookmarksExperimentState(PrefService* user_prefs, |
| 59 PrefService* local_state, | 59 PrefService* local_state, |
| 60 bool user_signed_in) { | 60 bool user_signed_in) { |
| 61 BookmarksExperimentState bookmarks_experiment_state_before = | 61 BookmarksExperimentState bookmarks_experiment_state_before = |
| 62 static_cast<BookmarksExperimentState>(user_prefs->GetInteger( | 62 static_cast<BookmarksExperimentState>(user_prefs->GetInteger( |
| 63 sync_driver::prefs::kEnhancedBookmarksExperimentEnabled)); | 63 sync_driver::prefs::kEnhancedBookmarksExperimentEnabled)); |
| 64 // If user signed out, clear possible previous state. | 64 // If user signed out, clear possible previous state. |
| 65 if (!user_signed_in) { | 65 if (!user_signed_in) { |
| 66 bookmarks_experiment_state_before = kNoBookmarksExperiment; | 66 bookmarks_experiment_state_before = kNoBookmarksExperiment; |
| 67 ForceFinchBookmarkExperimentIfNeeded(local_state, kNoBookmarksExperiment); | 67 ForceFinchBookmarkExperimentIfNeeded(local_state, kNoBookmarksExperiment); |
| 68 } | 68 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 bookmarks_experiment_new_state = kBookmarksExperimentEnabledUserOptOut; | 104 bookmarks_experiment_new_state = kBookmarksExperimentEnabledUserOptOut; |
| 105 } else { | 105 } else { |
| 106 // User opted in again. | 106 // User opted in again. |
| 107 bookmarks_experiment_new_state = kBookmarksExperimentEnabled; | 107 bookmarks_experiment_new_state = kBookmarksExperimentEnabled; |
| 108 } | 108 } |
| 109 } | 109 } |
| 110 | 110 |
| 111 UMA_HISTOGRAM_ENUMERATION("EnhancedBookmarks.SyncExperimentState", | 111 UMA_HISTOGRAM_ENUMERATION("EnhancedBookmarks.SyncExperimentState", |
| 112 bookmarks_experiment_new_state, | 112 bookmarks_experiment_new_state, |
| 113 kBookmarksExperimentEnumSize); | 113 kBookmarksExperimentEnumSize); |
| 114 user_prefs->SetInteger( |
| 115 sync_driver::prefs::kEnhancedBookmarksExperimentEnabled, |
| 116 bookmarks_experiment_new_state); |
| 114 if (bookmarks_experiment_state_before != bookmarks_experiment_new_state) | 117 if (bookmarks_experiment_state_before != bookmarks_experiment_new_state) |
| 115 ForceFinchBookmarkExperimentIfNeeded(local_state, | 118 ForceFinchBookmarkExperimentIfNeeded(local_state, |
| 116 bookmarks_experiment_new_state); | 119 bookmarks_experiment_new_state); |
| 117 } | 120 } |
| 118 | 121 |
| 119 void ForceFinchBookmarkExperimentIfNeeded( | 122 void ForceFinchBookmarkExperimentIfNeeded( |
| 120 PrefService* local_state, | 123 PrefService* local_state, |
| 121 BookmarksExperimentState bookmarks_experiment_state) { | 124 BookmarksExperimentState bookmarks_experiment_state) { |
| 122 // Chrome OS doesnt use local storage for experiments flags. | 125 // Chrome OS doesnt use local storage for experiments flags. |
| 123 #if !defined(OS_CHROMEOS) | 126 #if !defined(OS_CHROMEOS) |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 if (CommandLine::ForCurrentProcess()-> | 177 if (CommandLine::ForCurrentProcess()-> |
| 175 HasSwitch(switches::kEnableSyncArticles)) { | 178 HasSwitch(switches::kEnableSyncArticles)) { |
| 176 return true; | 179 return true; |
| 177 } | 180 } |
| 178 if (chrome_variations::GetVariationParamValue( | 181 if (chrome_variations::GetVariationParamValue( |
| 179 kFieldTrialName, "enable-sync-articles") == "1") | 182 kFieldTrialName, "enable-sync-articles") == "1") |
| 180 return true; | 183 return true; |
| 181 | 184 |
| 182 return false; | 185 return false; |
| 183 } | 186 } |
| OLD | NEW |