treib | ec8f330 | 2016-08-04 11:05:20 | [diff] [blame] | 1 | // 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 | |
vitaliii | a64fb41f | 2017-01-04 07:40:29 | [diff] [blame] | 8 | #include <memory> |
skym | 9e961db | 2016-09-19 19:02:08 | [diff] [blame] | 9 | #include <string> |
| 10 | |
treib | ec8f330 | 2016-08-04 11:05:20 | [diff] [blame] | 11 | #include "base/feature_list.h" |
vitaliii | a64fb41f | 2017-01-04 07:40:29 | [diff] [blame] | 12 | #include "components/ntp_snippets/category_rankers/category_ranker.h" |
| 13 | #include "components/prefs/pref_service.h" |
treib | ec8f330 | 2016-08-04 11:05:20 | [diff] [blame] | 14 | |
vitaliii | 1e8492aea | 2017-01-04 10:53:13 | [diff] [blame] | 15 | namespace base { |
| 16 | class Clock; |
| 17 | } |
| 18 | |
treib | ec8f330 | 2016-08-04 11:05:20 | [diff] [blame] | 19 | namespace ntp_snippets { |
| 20 | |
sfiera | 429f312 | 2017-04-24 16:17:57 | [diff] [blame] | 21 | // |
| 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 Grieve | d1978b0e | 2017-07-28 15:53:41 | [diff] [blame] | 27 | extern const base::Feature* const kAllFeatures[]; |
sfiera | 429f312 | 2017-04-24 16:17:57 | [diff] [blame] | 28 | |
Vitalii Iarko | cdf7fe6d3 | 2017-09-26 10:42:10 | [diff] [blame] | 29 | //////////////////////////////////////////////////////////////////////////////// |
| 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 | |
pke | 2f529e9c | 2016-08-05 11:52:07 | [diff] [blame] | 35 | extern const base::Feature kBookmarkSuggestionsFeature; |
sfiera | e8969bc | 2017-03-26 18:38:41 | [diff] [blame] | 36 | extern const base::Feature kForeignSessionsSuggestionsFeature; |
treib | 5bc62a8 | 2016-08-09 11:30:15 | [diff] [blame] | 37 | |
Vitalii Iarko | cdf7fe6d3 | 2017-09-26 10:42:10 | [diff] [blame] | 38 | //////////////////////////////////////////////////////////////////////////////// |
| 39 | // Independent features. Treat as normal |
| 40 | |
Becky Zhou | a7f11d6 | 2018-02-01 16:02:53 | [diff] [blame] | 41 | // Feature to allow show/hide article suggestions by clicking the header. |
| 42 | extern const base::Feature kArticleSuggestionsExpandableHeader; |
| 43 | |
Vitalii Iarko | cdf7fe6d3 | 2017-09-26 10:42:10 | [diff] [blame] | 44 | extern const base::Feature kArticleSuggestionsFeature; |
| 45 | |
peconn | 9883eff | 2016-11-04 18:54:18 | [diff] [blame] | 46 | // Feature to allow UI as specified here: https://crbug.com/660837. |
| 47 | extern const base::Feature kIncreasedVisibility; |
| 48 | |
mamir | e15e8c2 | 2017-06-01 18:43:33 | [diff] [blame] | 49 | // Feature to listen for GCM push updates from the server. |
Mohamed Amir Yosef | 2dbc30c | 2017-06-22 15:43:10 | [diff] [blame] | 50 | extern const base::Feature kBreakingNewsPushFeature; |
mamir | e15e8c2 | 2017-06-01 18:43:33 | [diff] [blame] | 51 | |
vitaliii | a64fb41f | 2017-01-04 07:40:29 | [diff] [blame] | 52 | // Feature to choose a category ranker. |
| 53 | extern const base::Feature kCategoryRanker; |
| 54 | |
jkrcal | 18514e66 | 2017-03-30 06:12:28 | [diff] [blame] | 55 | // Feature to allow the new Google favicon server for fetching publisher icons. |
| 56 | extern const base::Feature kPublisherFaviconsFromNewServerFeature; |
| 57 | |
Vitalii Iarko | 1eb02f6 | 2017-09-12 13:57:10 | [diff] [blame] | 58 | // Feature for simple experimental comparison and validation of changes since |
Jan Krcal | eb0742d | 2017-06-02 14:02:31 | [diff] [blame] | 59 | // M58: enabling this brings back the M58 Stable fetching schedule (which is |
| 60 | // suitable for Holdback groups). |
Vitalii Iarko | 1eb02f6 | 2017-09-12 13:57:10 | [diff] [blame] | 61 | // TODO(jkrcal): Remove when the comparison is done (probably after M62). |
Jan Krcal | eb0742d | 2017-06-02 14:02:31 | [diff] [blame] | 62 | extern const base::Feature kRemoteSuggestionsEmulateM58FetchingSchedule; |
| 63 | |
vitaliii | 90790eb | 2017-02-14 15:45:58 | [diff] [blame] | 64 | // Parameter and its values for the kCategoryRanker feature flag. |
vitaliii | a64fb41f | 2017-01-04 07:40:29 | [diff] [blame] | 65 | extern const char kCategoryRankerParameter[]; |
vitaliii | a64fb41f | 2017-01-04 07:40:29 | [diff] [blame] | 66 | extern const char kCategoryRankerConstantRanker[]; |
| 67 | extern const char kCategoryRankerClickBasedRanker[]; |
| 68 | |
| 69 | enum class CategoryRankerChoice { |
| 70 | CONSTANT, |
| 71 | CLICK_BASED, |
| 72 | }; |
| 73 | |
Vitalii Iarko | c2f92b2d | 2017-09-21 08:02:13 | [diff] [blame] | 74 | // Returns which CategoryRanker to use according to kCategoryRanker feature and |
| 75 | // Chrome Home. |
| 76 | CategoryRankerChoice GetSelectedCategoryRanker(bool is_chrome_home_enabled); |
vitaliii | a64fb41f | 2017-01-04 07:40:29 | [diff] [blame] | 77 | |
Vitalii Iarko | c2f92b2d | 2017-09-21 08:02:13 | [diff] [blame] | 78 | // Builds a CategoryRanker according to kCategoryRanker feature and Chrome Home. |
vitaliii | a64fb41f | 2017-01-04 07:40:29 | [diff] [blame] | 79 | std::unique_ptr<CategoryRanker> BuildSelectedCategoryRanker( |
vitaliii | 1e8492aea | 2017-01-04 10:53:13 | [diff] [blame] | 80 | PrefService* pref_service, |
tzik | c00f529a | 2017-12-04 12:48:29 | [diff] [blame] | 81 | base::Clock* clock, |
Vitalii Iarko | c2f92b2d | 2017-09-21 08:02:13 | [diff] [blame] | 82 | bool is_chrome_home_enabled); |
vitaliii | a64fb41f | 2017-01-04 07:40:29 | [diff] [blame] | 83 | |
vitaliii | 90790eb | 2017-02-14 15:45:58 | [diff] [blame] | 84 | // Feature to choose a default category order. |
| 85 | extern const base::Feature kCategoryOrder; |
| 86 | |
| 87 | // Parameter and its values for the kCategoryOrder feature flag. |
| 88 | extern const char kCategoryOrderParameter[]; |
| 89 | extern const char kCategoryOrderGeneral[]; |
| 90 | extern const char kCategoryOrderEmergingMarketsOriented[]; |
| 91 | |
| 92 | enum class CategoryOrderChoice { |
| 93 | GENERAL, |
| 94 | EMERGING_MARKETS_ORIENTED, |
| 95 | }; |
| 96 | |
| 97 | // Returns which category order to use according to kCategoryOrder feature. |
| 98 | CategoryOrderChoice GetSelectedCategoryOrder(); |
| 99 | |
sfiera | 429f312 | 2017-04-24 16:17:57 | [diff] [blame] | 100 | // Enables and configures notifications for content suggestions on Android. |
| 101 | extern 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. |
| 105 | extern const char kNotificationsPriorityParam[]; |
| 106 | constexpr 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. |
| 111 | extern const char kNotificationsTextParam[]; |
| 112 | extern const char kNotificationsTextValuePublisher[]; |
| 113 | extern const char kNotificationsTextValueSnippet[]; |
| 114 | extern const char kNotificationsTextValueAndMore[]; |
| 115 | |
| 116 | // "true": when Chrome becomes frontmost, leave notifications open. |
| 117 | // "false": automatically dismiss notification when Chrome becomes frontmost. |
| 118 | extern const char kNotificationsKeepWhenFrontmostParam[]; |
| 119 | |
| 120 | // "true": notifications link to chrome://newtab, with appropriate text. |
| 121 | // "false": notifications link to URL of notifying article. |
| 122 | extern const char kNotificationsOpenToNTPParam[]; |
| 123 | |
| 124 | // An integer. The maximum number of notifications that will be shown in 1 day. |
| 125 | extern const char kNotificationsDailyLimit[]; |
| 126 | constexpr 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. |
| 130 | extern const char kNotificationsIgnoredLimitParam[]; |
| 131 | constexpr int kNotificationsIgnoredDefaultLimit = 3; |
| 132 | |
Vitalii Iarko | 112f918 | 2017-06-20 11:59:55 | [diff] [blame] | 133 | // Whether to keep some prefetched content suggestions even when new suggestions |
| 134 | // have been fetched. |
| 135 | extern const base::Feature kKeepPrefetchedContentSuggestions; |
| 136 | |
Vitalii Iarko | f52ff80 | 2017-09-14 12:34:24 | [diff] [blame] | 137 | // Enables debug logging accessible through snippets-internals. |
| 138 | extern const base::Feature kContentSuggestionsDebugLog; |
| 139 | |
Brandon Wylie | 40c6f21 | 2018-05-16 19:28:32 | [diff] [blame^] | 140 | // Return all the features as a vector. |
| 141 | std::vector<const base::Feature*> GetAllFeatures(); |
| 142 | |
treib | ec8f330 | 2016-08-04 11:05:20 | [diff] [blame] | 143 | } // namespace ntp_snippets |
| 144 | |
| 145 | #endif // COMPONENTS_NTP_SNIPPETS_FEATURES_H_ |