blob: 69369e1d4c0ca9db7a3f75dc068b7d853ac23610 [file] [log] [blame]
treibec8f3302016-08-04 11:05:201// Copyright 2016 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 COMPONENTS_NTP_SNIPPETS_FEATURES_H_
6#define COMPONENTS_NTP_SNIPPETS_FEATURES_H_
7
vitaliiia64fb41f2017-01-04 07:40:298#include <memory>
skym9e961db2016-09-19 19:02:089#include <string>
10
treibec8f3302016-08-04 11:05:2011#include "base/feature_list.h"
vitaliiia64fb41f2017-01-04 07:40:2912#include "components/ntp_snippets/category_rankers/category_ranker.h"
13#include "components/prefs/pref_service.h"
treibec8f3302016-08-04 11:05:2014
vitaliii1e8492aea2017-01-04 10:53:1315namespace base {
16class Clock;
17}
18
treibec8f3302016-08-04 11:05:2019namespace ntp_snippets {
20
sfiera429f3122017-04-24 16:17:5721//
22// Null-terminated list of all features related to content suggestions.
23//
24// If you add a base::Feature below, you must add it to this list. It is used in
25// internal pages to list relevant parameters and settings.
26//
Andrew Grieved1978b0e2017-07-28 15:53:4127extern const base::Feature* const kAllFeatures[];
sfiera429f3122017-04-24 16:17:5728
Vitalii Iarkocdf7fe6d32017-09-26 10:42:1029////////////////////////////////////////////////////////////////////////////////
30// Dependent features.
31// DO NOT check directly whether these features are enabled (i.e. do
32// not use base::FeatureList::IsEnabled()). They are enabled conditionally. Use
33// helpers in chrome/browser/ntp_snippets/dependent_features.h instead.
34
pke2f529e9c2016-08-05 11:52:0735extern const base::Feature kBookmarkSuggestionsFeature;
sfierae8969bc2017-03-26 18:38:4136extern const base::Feature kForeignSessionsSuggestionsFeature;
treib5bc62a82016-08-09 11:30:1537
Vitalii Iarkocdf7fe6d32017-09-26 10:42:1038////////////////////////////////////////////////////////////////////////////////
39// Independent features. Treat as normal
40
Becky Zhoua7f11d62018-02-01 16:02:5341// Feature to allow show/hide article suggestions by clicking the header.
42extern const base::Feature kArticleSuggestionsExpandableHeader;
43
Vitalii Iarkocdf7fe6d32017-09-26 10:42:1044extern const base::Feature kArticleSuggestionsFeature;
45
peconn9883eff2016-11-04 18:54:1846// Feature to allow UI as specified here: https://crbug.com/660837.
47extern const base::Feature kIncreasedVisibility;
48
mamire15e8c22017-06-01 18:43:3349// Feature to listen for GCM push updates from the server.
Mohamed Amir Yosef2dbc30c2017-06-22 15:43:1050extern const base::Feature kBreakingNewsPushFeature;
mamire15e8c22017-06-01 18:43:3351
vitaliiia64fb41f2017-01-04 07:40:2952// Feature to choose a category ranker.
53extern const base::Feature kCategoryRanker;
54
jkrcal18514e662017-03-30 06:12:2855// Feature to allow the new Google favicon server for fetching publisher icons.
56extern const base::Feature kPublisherFaviconsFromNewServerFeature;
57
Vitalii Iarko1eb02f62017-09-12 13:57:1058// Feature for simple experimental comparison and validation of changes since
Jan Krcaleb0742d2017-06-02 14:02:3159// M58: enabling this brings back the M58 Stable fetching schedule (which is
60// suitable for Holdback groups).
Vitalii Iarko1eb02f62017-09-12 13:57:1061// TODO(jkrcal): Remove when the comparison is done (probably after M62).
Jan Krcaleb0742d2017-06-02 14:02:3162extern const base::Feature kRemoteSuggestionsEmulateM58FetchingSchedule;
63
vitaliii90790eb2017-02-14 15:45:5864// Parameter and its values for the kCategoryRanker feature flag.
vitaliiia64fb41f2017-01-04 07:40:2965extern const char kCategoryRankerParameter[];
vitaliiia64fb41f2017-01-04 07:40:2966extern const char kCategoryRankerConstantRanker[];
67extern const char kCategoryRankerClickBasedRanker[];
68
69enum class CategoryRankerChoice {
70 CONSTANT,
71 CLICK_BASED,
72};
73
Vitalii Iarkoc2f92b2d2017-09-21 08:02:1374// Returns which CategoryRanker to use according to kCategoryRanker feature and
75// Chrome Home.
76CategoryRankerChoice GetSelectedCategoryRanker(bool is_chrome_home_enabled);
vitaliiia64fb41f2017-01-04 07:40:2977
Vitalii Iarkoc2f92b2d2017-09-21 08:02:1378// Builds a CategoryRanker according to kCategoryRanker feature and Chrome Home.
vitaliiia64fb41f2017-01-04 07:40:2979std::unique_ptr<CategoryRanker> BuildSelectedCategoryRanker(
vitaliii1e8492aea2017-01-04 10:53:1380 PrefService* pref_service,
tzikc00f529a2017-12-04 12:48:2981 base::Clock* clock,
Vitalii Iarkoc2f92b2d2017-09-21 08:02:1382 bool is_chrome_home_enabled);
vitaliiia64fb41f2017-01-04 07:40:2983
vitaliii90790eb2017-02-14 15:45:5884// Feature to choose a default category order.
85extern const base::Feature kCategoryOrder;
86
87// Parameter and its values for the kCategoryOrder feature flag.
88extern const char kCategoryOrderParameter[];
89extern const char kCategoryOrderGeneral[];
90extern const char kCategoryOrderEmergingMarketsOriented[];
91
92enum class CategoryOrderChoice {
93 GENERAL,
94 EMERGING_MARKETS_ORIENTED,
95};
96
97// Returns which category order to use according to kCategoryOrder feature.
98CategoryOrderChoice GetSelectedCategoryOrder();
99
sfiera429f3122017-04-24 16:17:57100// Enables and configures notifications for content suggestions on Android.
101extern const base::Feature kNotificationsFeature;
102
103// An integer. The priority of the notification, ranging from -2 (PRIORITY_MIN)
104// to 2 (PRIORITY_MAX). Vibrates and makes sound if >= 0.
105extern const char kNotificationsPriorityParam[];
106constexpr int kNotificationsDefaultPriority = -1;
107
108// "publisher": use article's publisher as notification's text (default).
109// "snippet": use article's snippet as notification's text.
110// "and_more": use "From $1. Read this article and $2 more." as text.
111extern const char kNotificationsTextParam[];
112extern const char kNotificationsTextValuePublisher[];
113extern const char kNotificationsTextValueSnippet[];
114extern const char kNotificationsTextValueAndMore[];
115
116// "true": when Chrome becomes frontmost, leave notifications open.
117// "false": automatically dismiss notification when Chrome becomes frontmost.
118extern const char kNotificationsKeepWhenFrontmostParam[];
119
120// "true": notifications link to chrome://newtab, with appropriate text.
121// "false": notifications link to URL of notifying article.
122extern const char kNotificationsOpenToNTPParam[];
123
124// An integer. The maximum number of notifications that will be shown in 1 day.
125extern const char kNotificationsDailyLimit[];
126constexpr int kNotificationsDefaultDailyLimit = 1;
127
128// An integer. The number of notifications that can be ignored. If the user
129// ignores this many notifications or more, we stop sending them.
130extern const char kNotificationsIgnoredLimitParam[];
131constexpr int kNotificationsIgnoredDefaultLimit = 3;
132
Vitalii Iarko112f9182017-06-20 11:59:55133// Whether to keep some prefetched content suggestions even when new suggestions
134// have been fetched.
135extern const base::Feature kKeepPrefetchedContentSuggestions;
136
Vitalii Iarkof52ff802017-09-14 12:34:24137// Enables debug logging accessible through snippets-internals.
138extern const base::Feature kContentSuggestionsDebugLog;
139
Brandon Wylie40c6f212018-05-16 19:28:32140// Return all the features as a vector.
141std::vector<const base::Feature*> GetAllFeatures();
142
treibec8f3302016-08-04 11:05:20143} // namespace ntp_snippets
144
145#endif // COMPONENTS_NTP_SNIPPETS_FEATURES_H_