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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
122 BOOKMARKS_EXPERIMENT_ENABLED_USER_OPT_OUT) { | 122 BOOKMARKS_EXPERIMENT_ENABLED_USER_OPT_OUT) { |
123 if (opt_out) { | 123 if (opt_out) { |
124 bookmarks_experiment_new_state = | 124 bookmarks_experiment_new_state = |
125 BOOKMARKS_EXPERIMENT_ENABLED_USER_OPT_OUT; | 125 BOOKMARKS_EXPERIMENT_ENABLED_USER_OPT_OUT; |
126 } else { | 126 } else { |
127 // User opted in again. | 127 // User opted in again. |
128 bookmarks_experiment_new_state = BOOKMARKS_EXPERIMENT_ENABLED; | 128 bookmarks_experiment_new_state = BOOKMARKS_EXPERIMENT_ENABLED; |
129 } | 129 } |
130 } | 130 } |
131 | 131 |
132 #if defined(OS_ANDROID) | |
133 bool opt_in = !opt_out | |
134 && CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | |
135 switches::kEnhancedBookmarksExperiment) == "1"; | |
136 if (opt_in && bookmarks_experiment_new_state == BOOKMARKS_EXPERIMENT_NONE) | |
137 bookmarks_experiment_new_state = BOOKMARKS_EXPERIMENT_ENABLED; | |
138 #endif | |
139 | |
132 UMA_HISTOGRAM_ENUMERATION("EnhancedBookmarks.SyncExperimentState", | 140 UMA_HISTOGRAM_ENUMERATION("EnhancedBookmarks.SyncExperimentState", |
133 bookmarks_experiment_new_state, | 141 bookmarks_experiment_new_state, |
134 BOOKMARKS_EXPERIMENT_ENUM_SIZE); | 142 BOOKMARKS_EXPERIMENT_ENUM_SIZE); |
135 user_prefs->SetInteger( | 143 user_prefs->SetInteger( |
136 sync_driver::prefs::kEnhancedBookmarksExperimentEnabled, | 144 sync_driver::prefs::kEnhancedBookmarksExperimentEnabled, |
137 bookmarks_experiment_new_state); | 145 bookmarks_experiment_new_state); |
138 ForceFinchBookmarkExperimentIfNeeded(flags_storage, | 146 ForceFinchBookmarkExperimentIfNeeded(flags_storage, |
139 bookmarks_experiment_new_state); | 147 bookmarks_experiment_new_state); |
140 } | 148 } |
141 | 149 |
(...skipping 19 matching lines...) Expand all Loading... | |
161 new base::StringValue(switches::kManualEnhancedBookmarks)); | 169 new base::StringValue(switches::kManualEnhancedBookmarks)); |
162 } else if (bookmarks_experiment_state == | 170 } else if (bookmarks_experiment_state == |
163 BOOKMARKS_EXPERIMENT_ENABLED_USER_OPT_OUT) { | 171 BOOKMARKS_EXPERIMENT_ENABLED_USER_OPT_OUT) { |
164 experiments_list->Remove( | 172 experiments_list->Remove( |
165 base::StringValue(switches::kManualEnhancedBookmarks), &index); | 173 base::StringValue(switches::kManualEnhancedBookmarks), &index); |
166 experiments_list->AppendIfNotPresent( | 174 experiments_list->AppendIfNotPresent( |
167 new base::StringValue(switches::kManualEnhancedBookmarksOptout)); | 175 new base::StringValue(switches::kManualEnhancedBookmarksOptout)); |
168 } | 176 } |
169 } | 177 } |
170 | 178 |
171 bool IsEnhancedBookmarksExperimentEnabled() { | 179 #if defined(OS_ANDROID) |
172 CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
173 if (command_line->HasSwitch(switches::kManualEnhancedBookmarks) || | |
174 command_line->HasSwitch(switches::kManualEnhancedBookmarksOptout)) { | |
175 return true; | |
176 } | |
177 | 180 |
178 return IsEnhancedBookmarksExperimentEnabledFromFinch(); | 181 bool IsEnhancedBookmarkImageFetchingEnabled(const PrefService* user_prefs) { |
179 } | 182 if (IsEnhancedBookmarksExperimentEnabled(user_prefs)) |
180 | |
181 #if defined(OS_ANDROID) | |
182 bool IsEnhancedBookmarkImageFetchingEnabled() { | |
183 if (IsEnhancedBookmarksExperimentEnabled()) | |
184 return true; | 183 return true; |
185 | 184 |
186 // Salient images are collected from visited bookmarked pages even if the | 185 // Salient images are collected from visited bookmarked pages even if the |
187 // enhanced bookmark feature is turned off. This is to have some images | 186 // enhanced bookmark feature is turned off. This is to have some images |
188 // available so that in the future, when the feature is turned on, the user | 187 // available so that in the future, when the feature is turned on, the user |
189 // experience is not a big list of flat colors. However as a precautionary | 188 // experience is not a big list of flat colors. However as a precautionary |
190 // measure it is possible to disable this collection of images from finch. | 189 // measure it is possible to disable this collection of images from finch. |
191 std::string disable_fetching = variations::GetVariationParamValue( | 190 std::string disable_fetching = variations::GetVariationParamValue( |
192 kFieldTrialName, "DisableImagesFetching"); | 191 kFieldTrialName, "DisableImagesFetching"); |
193 return disable_fetching.empty(); | 192 return disable_fetching.empty(); |
194 } | 193 } |
194 | |
195 bool IsEnhancedBookmarksExperimentEnabled(const PrefService* user_prefs) { | |
196 BookmarksExperimentState bookmarks_experiment_state = | |
197 static_cast<BookmarksExperimentState>(user_prefs->GetInteger( | |
198 sync_driver::prefs::kEnhancedBookmarksExperimentEnabled)); | |
199 return bookmarks_experiment_state == BOOKMARKS_EXPERIMENT_ENABLED | |
Yaron
2014/08/27 20:42:15
Why can't you use the switches variant? Isn't that
Kibeom Kim (inactive)
2014/08/27 21:11:41
I see.
I was following the logic here https://chr
| |
200 || bookmarks_experiment_state == BOOKMARKS_EXPERIMENT_ENABLED_FROM_FINCH; | |
201 } | |
202 | |
203 #else | |
204 | |
205 bool IsEnhancedBookmarksExperimentEnabled() { | |
206 CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
207 if (command_line->HasSwitch(switches::kManualEnhancedBookmarks) || | |
208 command_line->HasSwitch(switches::kManualEnhancedBookmarksOptout)) { | |
209 return true; | |
210 } | |
211 | |
212 return IsEnhancedBookmarksExperimentEnabledFromFinch(); | |
213 } | |
214 | |
195 #endif | 215 #endif |
196 | 216 |
197 bool IsEnableDomDistillerSet() { | 217 bool IsEnableDomDistillerSet() { |
198 if (CommandLine::ForCurrentProcess()-> | 218 if (CommandLine::ForCurrentProcess()-> |
199 HasSwitch(switches::kEnableDomDistiller)) { | 219 HasSwitch(switches::kEnableDomDistiller)) { |
200 return true; | 220 return true; |
201 } | 221 } |
202 if (variations::GetVariationParamValue( | 222 if (variations::GetVariationParamValue( |
203 kFieldTrialName, "enable-dom-distiller") == "1") | 223 kFieldTrialName, "enable-dom-distiller") == "1") |
204 return true; | 224 return true; |
205 | 225 |
206 return false; | 226 return false; |
207 } | 227 } |
208 | 228 |
209 bool IsEnableSyncArticlesSet() { | 229 bool IsEnableSyncArticlesSet() { |
210 if (CommandLine::ForCurrentProcess()-> | 230 if (CommandLine::ForCurrentProcess()-> |
211 HasSwitch(switches::kEnableSyncArticles)) { | 231 HasSwitch(switches::kEnableSyncArticles)) { |
212 return true; | 232 return true; |
213 } | 233 } |
214 if (variations::GetVariationParamValue( | 234 if (variations::GetVariationParamValue( |
215 kFieldTrialName, "enable-sync-articles") == "1") | 235 kFieldTrialName, "enable-sync-articles") == "1") |
216 return true; | 236 return true; |
217 | 237 |
218 return false; | 238 return false; |
219 } | 239 } |
OLD | NEW |