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/flags_storage.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/signin/signin_manager_factory.h" | 16 #include "chrome/browser/signin/signin_manager_factory.h" |
17 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
18 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
19 #include "components/signin/core/browser/signin_manager.h" | 19 #include "components/signin/core/browser/signin_manager.h" |
20 #include "components/sync_driver/pref_names.h" | 20 #include "components/sync_driver/pref_names.h" |
21 #include "components/variations/variations_associated_data.h" | 21 #include "components/variations/variations_associated_data.h" |
22 #include "extensions/common/features/feature.h" | 22 #include "extensions/common/features/feature.h" |
23 #include "extensions/common/features/feature_provider.h" | 23 #include "extensions/common/features/feature_provider.h" |
24 #include "ui/base/device_form_factor.h" | |
25 | 24 |
26 namespace { | 25 namespace { |
27 | 26 |
28 const char kFieldTrialName[] = "EnhancedBookmarks"; | 27 const char kFieldTrialName[] = "EnhancedBookmarks"; |
29 | 28 |
30 // Get extension id from Finch EnhancedBookmarks group parameters. | 29 // Get extension id from Finch EnhancedBookmarks group parameters. |
31 std::string GetEnhancedBookmarksExtensionIdFromFinch() { | 30 std::string GetEnhancedBookmarksExtensionIdFromFinch() { |
32 return variations::GetVariationParamValue(kFieldTrialName, "id"); | 31 return variations::GetVariationParamValue(kFieldTrialName, "id"); |
33 } | 32 } |
34 | 33 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 if (!user_signed_in) { | 82 if (!user_signed_in) { |
84 bookmarks_experiment_state_before = BOOKMARKS_EXPERIMENT_NONE; | 83 bookmarks_experiment_state_before = BOOKMARKS_EXPERIMENT_NONE; |
85 ForceFinchBookmarkExperimentIfNeeded(flags_storage, | 84 ForceFinchBookmarkExperimentIfNeeded(flags_storage, |
86 BOOKMARKS_EXPERIMENT_NONE); | 85 BOOKMARKS_EXPERIMENT_NONE); |
87 } | 86 } |
88 | 87 |
89 // kEnhancedBookmarksExperiment flag could have values "", "1" and "0". | 88 // kEnhancedBookmarksExperiment flag could have values "", "1" and "0". |
90 // "0" - user opted out. | 89 // "0" - user opted out. |
91 bool opt_out = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 90 bool opt_out = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
92 switches::kEnhancedBookmarksExperiment) == "0"; | 91 switches::kEnhancedBookmarksExperiment) == "0"; |
93 #if defined(OS_ANDROID) | |
94 // Tablets automagically do opt out. | |
95 opt_out = | |
96 opt_out || ui::GetDeviceFormFactor() == ui::DEVICE_FORM_FACTOR_TABLET; | |
97 #endif // defined(OS_ANDROID) | |
98 | 92 |
99 BookmarksExperimentState bookmarks_experiment_new_state = | 93 BookmarksExperimentState bookmarks_experiment_new_state = |
100 BOOKMARKS_EXPERIMENT_NONE; | 94 BOOKMARKS_EXPERIMENT_NONE; |
101 | 95 |
102 if (IsEnhancedBookmarksExperimentEnabledFromFinch() && !user_signed_in) { | 96 if (IsEnhancedBookmarksExperimentEnabledFromFinch() && !user_signed_in) { |
103 if (opt_out) { | 97 if (opt_out) { |
104 // Experiment enabled but user opted out. | 98 // Experiment enabled but user opted out. |
105 bookmarks_experiment_new_state = BOOKMARKS_EXPERIMENT_OPT_OUT_FROM_FINCH; | 99 bookmarks_experiment_new_state = BOOKMARKS_EXPERIMENT_OPT_OUT_FROM_FINCH; |
106 } else { | 100 } else { |
107 // Experiment enabled. | 101 // Experiment enabled. |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 if (CommandLine::ForCurrentProcess()-> | 252 if (CommandLine::ForCurrentProcess()-> |
259 HasSwitch(switches::kEnableSyncArticles)) { | 253 HasSwitch(switches::kEnableSyncArticles)) { |
260 return true; | 254 return true; |
261 } | 255 } |
262 if (variations::GetVariationParamValue( | 256 if (variations::GetVariationParamValue( |
263 kFieldTrialName, "enable-sync-articles") == "1") | 257 kFieldTrialName, "enable-sync-articles") == "1") |
264 return true; | 258 return true; |
265 | 259 |
266 return false; | 260 return false; |
267 } | 261 } |
OLD | NEW |