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 #ifndef CHROME_BROWSER_BOOKMARKS_ENHANCED_BOOKMARKS_FEATURES_H_ | 5 #ifndef CHROME_BROWSER_BOOKMARKS_ENHANCED_BOOKMARKS_FEATURES_H_ |
6 #define CHROME_BROWSER_BOOKMARKS_ENHANCED_BOOKMARKS_FEATURES_H_ | 6 #define CHROME_BROWSER_BOOKMARKS_ENHANCED_BOOKMARKS_FEATURES_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "extensions/common/extension.h" | 10 #include "extensions/common/extension.h" |
11 | 11 |
12 class PrefService; | 12 class PrefService; |
| 13 class Profile; |
13 | 14 |
14 // States for bookmark experiment. They are set by Chrome sync into | 15 // States for bookmark experiment. They are set by Chrome sync into |
15 // sync_driver::prefs::kEnhancedBookmarksExperimentEnabled user preference and | 16 // sync_driver::prefs::kEnhancedBookmarksExperimentEnabled user preference and |
16 // used for UMA reporting as well. | 17 // used for UMA reporting as well. |
17 enum BookmarksExperimentState { | 18 enum BookmarksExperimentState { |
18 BOOKMARKS_EXPERIMENT_NONE, | 19 BOOKMARKS_EXPERIMENT_NONE, |
19 BOOKMARKS_EXPERIMENT_ENABLED, | 20 BOOKMARKS_EXPERIMENT_ENABLED, |
20 BOOKMARKS_EXPERIMENT_ENABLED_USER_OPT_OUT, | 21 BOOKMARKS_EXPERIMENT_ENABLED_USER_OPT_OUT, |
21 BOOKMARKS_EXPERIMENT_ENABLED_FROM_FINCH, | 22 BOOKMARKS_EXPERIMENT_ENABLED_FROM_FINCH, |
22 BOOKMARKS_EXPERIMENT_OPT_OUT_FROM_FINCH, | 23 BOOKMARKS_EXPERIMENT_OPT_OUT_FROM_FINCH, |
23 BOOKMARKS_EXPERIMENT_ENABLED_FROM_FINCH_USER_SIGNEDIN, | 24 BOOKMARKS_EXPERIMENT_ENABLED_FROM_FINCH_USER_SIGNEDIN, |
24 BOOKMARKS_EXPERIMENT_ENABLED_FROM_SYNC_UNKNOWN, | 25 BOOKMARKS_EXPERIMENT_ENABLED_FROM_SYNC_UNKNOWN, |
25 BOOKMARKS_EXPERIMENT_ENUM_SIZE | 26 BOOKMARKS_EXPERIMENT_ENUM_SIZE |
26 }; | 27 }; |
27 | 28 |
28 // Returns true and sets |extension_id| if bookmarks experiment enabled | 29 // Returns true and sets |extension_id| if bookmarks experiment enabled |
29 // false if no bookmark experiment or extension id is empty. | 30 // false if no bookmark experiment or extension id is empty. |
30 bool GetBookmarksExperimentExtensionID(const PrefService* user_prefs, | 31 bool GetBookmarksExperimentExtensionID(const PrefService* user_prefs, |
31 std::string* extension_id); | 32 std::string* extension_id); |
32 | 33 |
33 // Updates bookmark experiment state based on information from Chrome sync | 34 // Updates bookmark experiment state based on information from Chrome sync, |
34 // and Finch experiments. | 35 // Finch experiments, and command line flag. |
35 void UpdateBookmarksExperimentState( | 36 void UpdateBookmarksExperimentState( |
36 PrefService* user_prefs, | 37 PrefService* user_prefs, |
37 PrefService* local_state, | 38 PrefService* local_state, |
38 bool user_signed_in, | 39 bool user_signed_in, |
39 BookmarksExperimentState experiment_enabled_from_sync); | 40 BookmarksExperimentState experiment_enabled_from_sync); |
40 | 41 |
| 42 // Same as UpdateBookmarksExperimentState, but the last argument with |
| 43 // BOOKMARKS_EXPERIMENT_ENABLED_FROM_SYNC_UNKNOWN. |
| 44 // Intended for performing initial configuration of bookmarks experiments |
| 45 // when the browser is first initialized. |
| 46 void InitBookmarksExperimentState(Profile* profile); |
| 47 |
41 // Sets flag to opt-in user into Finch experiment. | 48 // Sets flag to opt-in user into Finch experiment. |
42 void ForceFinchBookmarkExperimentIfNeeded( | 49 void ForceFinchBookmarkExperimentIfNeeded( |
43 PrefService* local_state, | 50 PrefService* local_state, |
44 BookmarksExperimentState bookmarks_experiment_state); | 51 BookmarksExperimentState bookmarks_experiment_state); |
45 | 52 |
46 // Returns true if enhanced bookmarks experiment is running. | 53 // Returns true if enhanced bookmarks experiment is running. |
47 // Experiment could run by Chrome sync or by Finch. | 54 // Experiment could run by Chrome sync or by Finch. |
48 // Note that this doesn't necessarily mean that enhanced bookmarks | 55 // Note that this doesn't necessarily mean that enhanced bookmarks |
49 // is enabled, e.g., user can opt out using a flag. | 56 // is enabled, e.g., user can opt out using a flag. |
50 bool IsEnhancedBookmarksExperimentEnabled(); | 57 bool IsEnhancedBookmarksExperimentEnabled(); |
51 | 58 |
52 #if defined(OS_ANDROID) | 59 #if defined(OS_ANDROID) |
53 // Returns true if enhanced bookmark salient image prefetching is enabled. | 60 // Returns true if enhanced bookmark salient image prefetching is enabled. |
54 // This can be controlled by field trial. | 61 // This can be controlled by field trial. |
55 bool IsEnhancedBookmarkImageFetchingEnabled(const PrefService* user_prefs); | 62 bool IsEnhancedBookmarkImageFetchingEnabled(const PrefService* user_prefs); |
56 | 63 |
57 // Returns true if enhanced bookmarks is enabled. | 64 // Returns true if enhanced bookmarks is enabled. |
58 bool IsEnhancedBookmarksEnabled(const PrefService* user_prefs); | 65 bool IsEnhancedBookmarksEnabled(const PrefService* user_prefs); |
59 | 66 |
60 #endif | 67 #endif |
61 | 68 |
62 // Returns true when flag enable-dom-distiller is set or enabled from Finch. | 69 // Returns true when flag enable-dom-distiller is set or enabled from Finch. |
63 bool IsEnableDomDistillerSet(); | 70 bool IsEnableDomDistillerSet(); |
64 | 71 |
65 // Returns true when flag enable-sync-articles is set or enabled from Finch. | 72 // Returns true when flag enable-sync-articles is set or enabled from Finch. |
66 bool IsEnableSyncArticlesSet(); | 73 bool IsEnableSyncArticlesSet(); |
67 | 74 |
68 #endif // CHROME_BROWSER_BOOKMARKS_ENHANCED_BOOKMARKS_FEATURES_H_ | 75 #endif // CHROME_BROWSER_BOOKMARKS_ENHANCED_BOOKMARKS_FEATURES_H_ |
OLD | NEW |