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