1a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved.
2a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
3a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// found in the LICENSE file.
4a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
5a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#ifndef CHROME_BROWSER_BOOKMARKS_ENHANCED_BOOKMARKS_FEATURES_H_
6a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#define CHROME_BROWSER_BOOKMARKS_ENHANCED_BOOKMARKS_FEATURES_H_
7a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
8a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include <string>
9a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "extensions/common/extension.h"
115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
121320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccinamespace about_flags {
131320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciclass FlagsStorage;
141320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}  // namespace about_flags
151320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
16a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)class PrefService;
171320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciclass Profile;
18a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
19cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// States for bookmark experiment. They are set by Chrome sync into
20cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// sync_driver::prefs::kEnhancedBookmarksExperimentEnabled user preference and
21cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// used for UMA reporting as well.
22a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)enum BookmarksExperimentState {
2346d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  BOOKMARKS_EXPERIMENT_NONE,
2446d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  BOOKMARKS_EXPERIMENT_ENABLED,
2546d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  BOOKMARKS_EXPERIMENT_ENABLED_USER_OPT_OUT,
2646d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  BOOKMARKS_EXPERIMENT_ENABLED_FROM_FINCH,
2746d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  BOOKMARKS_EXPERIMENT_OPT_OUT_FROM_FINCH,
2846d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  BOOKMARKS_EXPERIMENT_ENABLED_FROM_FINCH_USER_SIGNEDIN,
2946d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  BOOKMARKS_EXPERIMENT_ENABLED_FROM_SYNC_UNKNOWN,
3046d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  BOOKMARKS_EXPERIMENT_ENUM_SIZE
31a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)};
32a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
33cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// Returns true and sets |extension_id| if bookmarks experiment enabled
34cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)//         false if no bookmark experiment or extension id is empty.
35cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)bool GetBookmarksExperimentExtensionID(const PrefService* user_prefs,
36cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)                                       std::string* extension_id);
37cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)
381320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// Updates bookmark experiment state based on information from Chrome sync,
391320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// Finch experiments, and command line flag.
40cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)void UpdateBookmarksExperimentState(
41cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    PrefService* user_prefs,
42cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    PrefService* local_state,
43cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    bool user_signed_in,
44cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    BookmarksExperimentState experiment_enabled_from_sync);
45cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)
461320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// Same as UpdateBookmarksExperimentState, but the last argument with
471320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// BOOKMARKS_EXPERIMENT_ENABLED_FROM_SYNC_UNKNOWN.
481320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// Intended for performing initial configuration of bookmarks experiments
491320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// when the browser is first initialized.
501320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccivoid InitBookmarksExperimentState(Profile* profile);
511320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
52a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Sets flag to opt-in user into Finch experiment.
53cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)void ForceFinchBookmarkExperimentIfNeeded(
54a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    PrefService* local_state,
55a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    BookmarksExperimentState bookmarks_experiment_state);
565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
571320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// Returns true if enhanced bookmarks experiment is running.
581320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// Experiment could run by Chrome sync or by Finch.
591320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// Note that this doesn't necessarily mean that enhanced bookmarks
601320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// is enabled, e.g., user can opt out using a flag.
611320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccibool IsEnhancedBookmarksExperimentEnabled(
621320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci    about_flags::FlagsStorage* flags_storage);
63a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
6446d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)#if defined(OS_ANDROID)
651320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// Returns true if enhanced bookmark salient image prefetching is enabled.
661320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// This can be controlled by field trial.
671320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccibool IsEnhancedBookmarkImageFetchingEnabled(const PrefService* user_prefs);
681320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
691320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// Returns true if enhanced bookmarks is enabled.
701320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccibool IsEnhancedBookmarksEnabled(const PrefService* user_prefs);
711320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
7246d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)#endif
7346d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)
74a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// Returns true when flag enable-dom-distiller is set or enabled from Finch.
75a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)bool IsEnableDomDistillerSet();
76a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
77a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// Returns true when flag enable-sync-articles is set or enabled from Finch.
78a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)bool IsEnableSyncArticlesSet();
79a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
80a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#endif  // CHROME_BROWSER_BOOKMARKS_ENHANCED_BOOKMARKS_FEATURES_H_
81