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" | 13 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/flags_storage.h" |
14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/signin/signin_manager_factory.h" | 16 #include "chrome/browser/signin/signin_manager_factory.h" |
16 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
17 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
18 #include "components/signin/core/browser/signin_manager.h" | 19 #include "components/signin/core/browser/signin_manager.h" |
19 #include "components/sync_driver/pref_names.h" | 20 #include "components/sync_driver/pref_names.h" |
20 #include "components/variations/variations_associated_data.h" | 21 #include "components/variations/variations_associated_data.h" |
21 #include "extensions/common/features/feature.h" | 22 #include "extensions/common/features/feature.h" |
22 #include "extensions/common/features/feature_provider.h" | 23 #include "extensions/common/features/feature_provider.h" |
23 | 24 |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 new base::StringValue(switches::kManualEnhancedBookmarks)); | 184 new base::StringValue(switches::kManualEnhancedBookmarks)); |
184 } else if (bookmarks_experiment_state == | 185 } else if (bookmarks_experiment_state == |
185 BOOKMARKS_EXPERIMENT_ENABLED_USER_OPT_OUT) { | 186 BOOKMARKS_EXPERIMENT_ENABLED_USER_OPT_OUT) { |
186 experiments_list->Remove( | 187 experiments_list->Remove( |
187 base::StringValue(switches::kManualEnhancedBookmarks), &index); | 188 base::StringValue(switches::kManualEnhancedBookmarks), &index); |
188 experiments_list->AppendIfNotPresent( | 189 experiments_list->AppendIfNotPresent( |
189 new base::StringValue(switches::kManualEnhancedBookmarksOptout)); | 190 new base::StringValue(switches::kManualEnhancedBookmarksOptout)); |
190 } | 191 } |
191 } | 192 } |
192 | 193 |
193 bool IsEnhancedBookmarksExperimentEnabled() { | 194 bool IsEnhancedBookmarksExperimentEnabled( |
| 195 about_flags::FlagsStorage* flags_storage) { |
| 196 #if defined(OS_CHROMEOS) |
| 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. |
| 199 const std::set<std::string> flags = flags_storage->GetFlags(); |
| 200 if (flags.find(switches::kManualEnhancedBookmarks) != flags.end()) |
| 201 return true; |
| 202 if (flags.find(switches::kManualEnhancedBookmarksOptout) != flags.end()) |
| 203 return true; |
| 204 #else |
194 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 205 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
195 if (command_line->HasSwitch(switches::kManualEnhancedBookmarks) || | 206 if (command_line->HasSwitch(switches::kManualEnhancedBookmarks) || |
196 command_line->HasSwitch(switches::kManualEnhancedBookmarksOptout)) { | 207 command_line->HasSwitch(switches::kManualEnhancedBookmarksOptout)) { |
197 return true; | 208 return true; |
198 } | 209 } |
| 210 #endif |
199 | 211 |
200 return IsEnhancedBookmarksExperimentEnabledFromFinch(); | 212 return IsEnhancedBookmarksExperimentEnabledFromFinch(); |
201 } | 213 } |
202 | 214 |
203 #if defined(OS_ANDROID) | 215 #if defined(OS_ANDROID) |
204 bool IsEnhancedBookmarkImageFetchingEnabled(const PrefService* user_prefs) { | 216 bool IsEnhancedBookmarkImageFetchingEnabled(const PrefService* user_prefs) { |
205 if (IsEnhancedBookmarksEnabled(user_prefs)) | 217 if (IsEnhancedBookmarksEnabled(user_prefs)) |
206 return true; | 218 return true; |
207 | 219 |
208 // Salient images are collected from visited bookmarked pages even if the | 220 // Salient images are collected from visited bookmarked pages even if the |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 if (CommandLine::ForCurrentProcess()-> | 252 if (CommandLine::ForCurrentProcess()-> |
241 HasSwitch(switches::kEnableSyncArticles)) { | 253 HasSwitch(switches::kEnableSyncArticles)) { |
242 return true; | 254 return true; |
243 } | 255 } |
244 if (variations::GetVariationParamValue( | 256 if (variations::GetVariationParamValue( |
245 kFieldTrialName, "enable-sync-articles") == "1") | 257 kFieldTrialName, "enable-sync-articles") == "1") |
246 return true; | 258 return true; |
247 | 259 |
248 return false; | 260 return false; |
249 } | 261 } |
OLD | NEW |