Fix emulator build error
[platform/framework/web/chromium-efl.git] / components / search / ntp_features.cc
1 // Copyright 2018 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "components/search/ntp_features.h"
6
7 #include "base/feature_list.h"
8 #include "base/metrics/field_trial_params.h"
9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_split.h"
11 #include "base/time/time.h"
12 #include "build/build_config.h"
13
14 namespace ntp_features {
15
16 // If enabled, shows a confirm dialog before removing search suggestions from
17 // the New Tab page real search box ("realbox").
18 BASE_FEATURE(kConfirmSuggestionRemovals,
19              "ConfirmNtpSuggestionRemovals",
20              base::FEATURE_DISABLED_BY_DEFAULT);
21
22 // If enabled, the OneGooleBar cached response is sent back to NTP.
23 BASE_FEATURE(kCacheOneGoogleBar,
24              "CacheOneGoogleBar",
25              base::FEATURE_DISABLED_BY_DEFAULT);
26
27 // If enabled, Chrome theme color will be set to match the NTP background
28 // on NTP Customize Chrome background change.
29 BASE_FEATURE(kCustomizeChromeColorExtraction,
30              "CustomizeChromeColorExtraction",
31              base::FEATURE_ENABLED_BY_DEFAULT);
32
33 // If enabled, shows an extension card within the Customize Chrome Side
34 // Panel for access to the Chrome Web Store extensions.
35 BASE_FEATURE(kCustomizeChromeSidePanelExtensionsCard,
36              "CustomizeChromeSidePanelExtensionsCard",
37              base::FEATURE_DISABLED_BY_DEFAULT);
38
39 // If enabled, shows wallpaper search within the Cusotmize Chrome Side Panel.
40 BASE_FEATURE(kCustomizeChromeWallpaperSearch,
41              "CustomizeChromeWallpaperSearch",
42              base::FEATURE_DISABLED_BY_DEFAULT);
43
44 // Forces a dark Google logo for a specific subset of Chrome Web Store themes
45 // (see crbug.com/1329552). This is enabled by default to allow finch to disable
46 // this NTP treatment in the case of unexpected regressions.
47 BASE_FEATURE(kCwsDarkLogo, "CwsDarkLogo", base::FEATURE_ENABLED_BY_DEFAULT);
48
49 // If enabled, "middle slot" promos on the bottom of the NTP will show a dismiss
50 // UI that allows users to close them and not see them again.
51 BASE_FEATURE(kDismissPromos,
52              "DismissNtpPromos",
53              base::FEATURE_DISABLED_BY_DEFAULT);
54
55 // If enabled, all NTP "realbox" Chrome Refresh features will be enabled
56 BASE_FEATURE(kRealboxCr23All,
57              "NtpRealboxCr23All",
58              base::FEATURE_DISABLED_BY_DEFAULT);
59
60 // If enabled, the NTP "realbox" will have same border/drop shadow in hover
61 // state as searchbox.
62 BASE_FEATURE(kRealboxMatchSearchboxTheme,
63              "NtpRealboxMatchSearchboxTheme",
64              base::FEATURE_DISABLED_BY_DEFAULT);
65
66 // Determines the behavior of the width of the realbox in relation to the width
67 // for secondary column.
68 BASE_FEATURE(kRealboxWidthBehavior,
69              "NtpRealboxWidthBehavior",
70              base::FEATURE_DISABLED_BY_DEFAULT);
71
72 // If enabled, the realbox will be taller.
73 BASE_FEATURE(kRealboxIsTall,
74              "NtpRealboxIsTall",
75              base::FEATURE_DISABLED_BY_DEFAULT);
76
77 // If enabled, the real search box ("realbox") on the New Tab page will show a
78 // Google (g) icon instead of the typical magnifying glass (aka loupe).
79 BASE_FEATURE(kRealboxUseGoogleGIcon,
80              "NtpRealboxUseGoogleGIcon",
81              base::FEATURE_DISABLED_BY_DEFAULT);
82
83 // If enabled, alpha NTP backgrounds will show in Customize Chrome.
84 BASE_FEATURE(kNtpAlphaBackgroundCollections,
85              "NtpAlphaBackgroundCollections",
86              base::FEATURE_DISABLED_BY_DEFAULT);
87
88 // If enabled, NTP background image links will be checked for HTTP status
89 // errors."
90 BASE_FEATURE(kNtpBackgroundImageErrorDetection,
91              "NtpBackgroundImageErrorDetection",
92              base::FEATURE_DISABLED_BY_DEFAULT);
93
94 // If enabled, chrome cart module will be shown.
95 BASE_FEATURE(kNtpChromeCartModule,
96              "NtpChromeCartModule",
97              base::FEATURE_ENABLED_BY_DEFAULT);
98
99 // If enabled, Comprehensive Theming color changes will be applied to the
100 // Realbox on the New Tab Page.
101 BASE_FEATURE(kNtpComprehensiveThemeRealbox,
102              "NtpComprehensiveThemeRealbox",
103              base::FEATURE_DISABLED_BY_DEFAULT);
104
105 #if !defined(OFFICIAL_BUILD)
106 // If enabled, dummy modules will be shown.
107 BASE_FEATURE(kNtpDummyModules,
108              "NtpDummyModules",
109              base::FEATURE_DISABLED_BY_DEFAULT);
110 #endif
111
112 // If enabled, Google Drive module will be shown.
113 BASE_FEATURE(kNtpDriveModule,
114              "NtpDriveModule",
115              base::FEATURE_ENABLED_BY_DEFAULT);
116
117 // If enabled, segmentation data will be collected to decide whether or not to
118 // show the Drive module.
119 BASE_FEATURE(kNtpDriveModuleSegmentation,
120              "NtpDriveModuleSegmentation",
121              base::FEATURE_DISABLED_BY_DEFAULT);
122
123 // If enabled, six files show in the NTP Drive module, instead of three.
124 BASE_FEATURE(kNtpDriveModuleShowSixFiles,
125              "NtpDriveModuleShowSixFiles",
126              base::FEATURE_DISABLED_BY_DEFAULT);
127
128 // If enabled, handles navigations from the Most Visited tiles explicitly and
129 // overrides the navigation's transition type to bookmark navigation before the
130 // navigation is issued.
131 // TODO(crbug.com/1147589): When removing this flag, also remove the workaround
132 // in ChromeContentBrowserClient::OverrideNavigationParams.
133 BASE_FEATURE(kNtpHandleMostVisitedNavigationExplicitly,
134              "HandleMostVisitedNavigationExplicitly",
135              base::FEATURE_ENABLED_BY_DEFAULT);
136
137 // If enabled, logo will be shown.
138 BASE_FEATURE(kNtpLogo, "NtpLogo", base::FEATURE_ENABLED_BY_DEFAULT);
139
140 // If enabled, logo will fill up less vertical space.
141 BASE_FEATURE(kNtpReducedLogoSpace,
142              "NtpReducedLogoSpace",
143              base::FEATURE_ENABLED_BY_DEFAULT);
144
145 // If enabled, middle slot promo will be shown.
146 BASE_FEATURE(kNtpMiddleSlotPromo,
147              "NtpMiddleSlotPromo",
148              base::FEATURE_ENABLED_BY_DEFAULT);
149
150 // If enabled, middle slot promo will be dismissed from New Tab Page until new
151 // promo message is populated
152 BASE_FEATURE(kNtpMiddleSlotPromoDismissal,
153              "NtpMiddleSlotPromoDismissal",
154              base::FEATURE_ENABLED_BY_DEFAULT);
155
156 // Dummy feature to set param "NtpModulesLoadTimeoutMillisecondsParam".
157 BASE_FEATURE(kNtpModulesLoadTimeoutMilliseconds,
158              "NtpModulesLoadTimeoutMilliseconds",
159              base::FEATURE_DISABLED_BY_DEFAULT);
160
161 // If true, extends width of modules if space allows.
162 BASE_FEATURE(kNtpWideModules,
163              "NtpWideModules",
164              base::FEATURE_ENABLED_BY_DEFAULT);
165
166 // Dummy feature to set param "NtpModulesOrderParam".
167 BASE_FEATURE(kNtpModulesOrder,
168              "NtpModulesOrder",
169              base::FEATURE_DISABLED_BY_DEFAULT);
170
171 // Dummy feature to set param "NtpModulesMaxColumnCountParam".
172 BASE_FEATURE(kNtpModulesMaxColumnCount,
173              "NtpModulesMaxColumnCount",
174              base::FEATURE_DISABLED_BY_DEFAULT);
175
176 // Dummy feature to set param "NtpModulesLoadedWithOtherModulesMaxInstanceCount"
177 BASE_FEATURE(kNtpModulesLoadedWithOtherModulesMaxInstanceCount,
178              "NtpModulesLoadedWithOtherModulesMaxInstanceCount",
179              base::FEATURE_DISABLED_BY_DEFAULT);
180
181 // If true, displays a horizontal scrollbar on overflowing modules.
182 BASE_FEATURE(kNtpModulesOverflowScrollbar,
183              "NtpModulesOverflowScrollbar",
184              base::FEATURE_ENABLED_BY_DEFAULT);
185
186 // If enabled, modules will be able to be reordered via dragging and dropping
187 BASE_FEATURE(kNtpModulesDragAndDrop,
188              "NtpModulesDragAndDrop",
189              base::FEATURE_DISABLED_BY_DEFAULT);
190
191 // If enabled, the first run experience for Modular NTP Desktop v1 will show.
192 BASE_FEATURE(kNtpModulesFirstRunExperience,
193              "NtpModulesFirstRunExperience",
194              base::FEATURE_DISABLED_BY_DEFAULT);
195
196 // If enabled, modules will be loaded but not shown. This is useful to determine
197 // if a user would have seen modules in order to counterfactually log or
198 // trigger.
199 BASE_FEATURE(kNtpModulesLoad,
200              "NtpModulesLoad",
201              base::FEATURE_DISABLED_BY_DEFAULT);
202
203 // If enabled, redesigned modules will be shown.
204 BASE_FEATURE(kNtpModulesRedesigned,
205              "NtpModulesRedesigned",
206              base::FEATURE_DISABLED_BY_DEFAULT);
207
208 // If enabled, MostVisited tiles will reflow when overflowing.
209 BASE_FEATURE(kNtpMostVisitedReflowOnOverflow,
210              "NtpMostVisitedReflowOnOverflow",
211              base::FEATURE_ENABLED_BY_DEFAULT);
212
213 // If enabled, OneGoogleBar will be shown.
214 BASE_FEATURE(kNtpOneGoogleBar,
215              "NtpOneGoogleBar",
216              base::FEATURE_ENABLED_BY_DEFAULT);
217
218 // If enabled, Google Photos module will be shown.
219 BASE_FEATURE(kNtpPhotosModule,
220              "NtpPhotosModule",
221              base::FEATURE_DISABLED_BY_DEFAULT);
222
223 // If enabled, a customized title will be shown on the opt-in card.
224 BASE_FEATURE(kNtpPhotosModuleCustomizedOptInTitle,
225              "NtpPhotosModuleCustomizedOptInTitle",
226              base::FEATURE_DISABLED_BY_DEFAULT);
227
228 // If enabled, a customized art work will be shown on the opt-in card.
229 BASE_FEATURE(kNtpPhotosModuleCustomizedOptInArtWork,
230              "NtpPhotosModuleCustomizedOptInArtWork",
231              base::FEATURE_DISABLED_BY_DEFAULT);
232
233 // If enabled, Google Photos opt-in card will show a button to soft opt-out.
234 BASE_FEATURE(kNtpPhotosModuleSoftOptOut,
235              "NtpPhotosModuleSoftOptOut",
236              base::FEATURE_DISABLED_BY_DEFAULT);
237
238 // If enabled, the single svg image show in Photos opt-in screen will be
239 // replaced by constituent images to support i18n.
240 BASE_FEATURE(kNtpPhotosModuleSplitSvgOptInArtWork,
241              "NtpPhotosModuleSplitSvgOptInArtWork",
242              base::FEATURE_DISABLED_BY_DEFAULT);
243
244 // If enabled, Following Feed module will be shown.
245 BASE_FEATURE(kNtpFeedModule,
246              "NtpFeedModule",
247              base::FEATURE_DISABLED_BY_DEFAULT);
248
249 // If enabled, Google Lens image search will be shown in the NTP Realbox.
250 BASE_FEATURE(kNtpRealboxLensSearch,
251              "NtpRealboxLensSearch",
252              base::FEATURE_ENABLED_BY_DEFAULT);
253
254 // If enabled, Google Lens image search will call Lens v3 direct upload
255 // endpoint instead of uploading to Scotty.
256 BASE_FEATURE(kNtpLensDirectUpload,
257              "NtpLensDirectUpload",
258              base::FEATURE_DISABLED_BY_DEFAULT);
259
260 // If enabled, recipe tasks module will be shown.
261 BASE_FEATURE(kNtpRecipeTasksModule,
262              "NtpRecipeTasksModule",
263              base::FEATURE_DISABLED_BY_DEFAULT);
264
265 // If enabled, SafeBrowsing module will be shown to a target user.
266 BASE_FEATURE(kNtpSafeBrowsingModule,
267              "NtpSafeBrowsingModule",
268              base::FEATURE_DISABLED_BY_DEFAULT);
269
270 // If enabled, shortcuts will be shown.
271 BASE_FEATURE(kNtpShortcuts, "NtpShortcuts", base::FEATURE_ENABLED_BY_DEFAULT);
272
273 // If enabled, shortcuts will be shown in a wide single row.
274 BASE_FEATURE(kNtpSingleRowShortcuts,
275              "NtpSingleRowShortcuts",
276              base::FEATURE_ENABLED_BY_DEFAULT);
277
278 // If enabled, the History clusters module will be shown.
279 BASE_FEATURE(kNtpHistoryClustersModule,
280              "NtpHistoryClustersModule",
281              base::FEATURE_ENABLED_BY_DEFAULT);
282
283 // Dummy feature to set kNtpHistoryClustersModuleBeginTimeDurationHoursParam.
284 BASE_FEATURE(kNtpHistoryClustersModuleBeginTimeDuration,
285              "NtpHistoryClustersModuleBeginTimeDuration",
286              base::FEATURE_DISABLED_BY_DEFAULT);
287
288 // Dummy feature to set kNtpHistoryClustersModuleMinimumVisitsRequiredParam.
289 BASE_FEATURE(kNtpHistoryClustersModuleMinimumVisitsRequired,
290              "NtpHistoryClustersModuleMinimumVisitsRequired",
291              base::FEATURE_DISABLED_BY_DEFAULT);
292
293 // Dummy feature to set kNtpHistoryClustersModuleMinimumImagesRequiredParam.
294 BASE_FEATURE(kNtpHistoryClustersModuleMinimumImagesRequired,
295              "NtpHistoryClustersModuleMinimumImagesRequired",
296              base::FEATURE_DISABLED_BY_DEFAULT);
297
298 // Dummy feature to set kNtpHistoryClustersModuleCategoriesParam.
299 BASE_FEATURE(kNtpHistoryClustersModuleCategories,
300              "NtpHistoryClustersModuleCategories",
301              base::FEATURE_DISABLED_BY_DEFAULT);
302
303 // If enabled, the history clusters module will be loaded but not shown. This is
304 // useful to determine if a user would have seen modules in order to
305 // counterfactually log or trigger.
306 BASE_FEATURE(kNtpHistoryClustersModuleLoad,
307              "NtpHistoryClustersModuleLoad",
308              base::FEATURE_DISABLED_BY_DEFAULT);
309
310 // Dummy feature to set kNtpHistoryClustersModuleMaxClustersParam.
311 BASE_FEATURE(kNtpHistoryClustersModuleMaxClusters,
312              "NtpHistoryClustersMaxClusters",
313              base::FEATURE_DISABLED_BY_DEFAULT);
314
315 // If enabled, module headers will display an associated icon.
316 BASE_FEATURE(kNtpModulesHeaderIcon,
317              "NtpModulesHeaderIcon",
318              base::FEATURE_ENABLED_BY_DEFAULT);
319
320 // If enabled a suggestion chip will show in the header for Quests V2.
321 BASE_FEATURE(kNtpHistoryClustersModuleSuggestionChipHeader,
322              "NtpHistoryClustersModuleSuggestionChipHeader",
323              base::FEATURE_DISABLED_BY_DEFAULT);
324
325 // If enabled, Discounts badge will show on the visit tile in the History
326 // clusters module when available.
327 BASE_FEATURE(kNtpHistoryClustersModuleDiscounts,
328              "NtpHistoryClustersModuleDiscounts",
329              base::FEATURE_DISABLED_BY_DEFAULT);
330
331 // If enabled, ChromeCart tile will show in the History clusters module when
332 // available.
333 BASE_FEATURE(kNtpChromeCartInHistoryClusterModule,
334              "NtpChromeCartInHistoryClusterModule",
335              base::FEATURE_ENABLED_BY_DEFAULT);
336
337 BASE_FEATURE(kNtpHistoryClustersModuleUseModelRanking,
338              "NtpHistoryClustersModuleUseModelRanking",
339              base::FEATURE_ENABLED_BY_DEFAULT);
340
341 BASE_FEATURE(kNtpHistoryClustersModuleTextOnly,
342              "NtpHistoryClustersModuleTextOnly",
343              base::FEATURE_DISABLED_BY_DEFAULT);
344
345 // If enabled, ChromeCart module will show together with ChromeCart+History
346 // cluster module when available.
347 BASE_FEATURE(kNtpChromeCartHistoryClusterCoexist,
348              "NtpChromeCartHistoryClusterCoexist",
349              base::FEATURE_DISABLED_BY_DEFAULT);
350
351 // If enabled, the History Clusters module will attempt to fetch clusters until
352 // it has enough clusters for the module or the History Clusters service says
353 // that all visits have been exhausted.
354 BASE_FEATURE(kNtpHistoryClustersModuleFetchClustersUntilExhausted,
355              "NtpHistoryClustersModuleFetchClustersUntilExhausted",
356              base::FEATURE_ENABLED_BY_DEFAULT);
357
358 // If enabled, the History clusters module will contain visits from other
359 // devices.
360 BASE_FEATURE(kNtpHistoryClustersModuleIncludeSyncedVisits,
361              "NtpHistoryClustersModuleIncludeSyncedVisits",
362              base::FEATURE_DISABLED_BY_DEFAULT);
363
364 // If enabled, the History clsuters module will enable content clustering for
365 // the displayed clusters.
366 BASE_FEATURE(kNtpHistoryClustersModuleEnableContentClustering,
367              "HistoryClustersModuleEnableContentClustering",
368              base::FEATURE_DISABLED_BY_DEFAULT);
369
370 BASE_FEATURE(kNtpTabResumptionModule,
371              "NtpTabResumptionModule",
372              base::FEATURE_DISABLED_BY_DEFAULT);
373
374 const char kNtpModulesEligibleForHappinessTrackingSurveyParam[] =
375     "NtpModulesEligibleForHappinessTrackingSurveyParam";
376 const char kNtpModulesLoadTimeoutMillisecondsParam[] =
377     "NtpModulesLoadTimeoutMillisecondsParam";
378 const char kNtpModulesLoadedWithOtherModulesMaxInstanceCountParam[] =
379     "NtpModulesLoadedWithOtherModulesMaxInstanceCountParam";
380 const char kNtpModulesMaxColumnCountParam[] = "NtpModulesMaxColumnCountParam";
381 const char kNtpModulesOrderParam[] = "NtpModulesOrderParam";
382 const char kNtpChromeCartModuleDataParam[] = "NtpChromeCartModuleDataParam";
383 const char kNtpChromeCartModuleAbandonedCartDiscountParam[] =
384     "NtpChromeCartModuleAbandonedCartDiscountParam";
385 const char kNtpChromeCartModuleAbandonedCartDiscountUseUtmParam[] =
386     "NtpChromeCartModuleAbandonedCartDiscountUseUtmParam";
387 const char kNtpChromeCartModuleHeuristicsImprovementParam[] =
388     "NtpChromeCartModuleHeuristicsImprovementParam";
389 const char kNtpChromeCartModuleCouponParam[] = "NtpChromeCartModuleCouponParam";
390 const char kNtpDriveModuleDataParam[] = "NtpDriveModuleDataParam";
391 const char kNtpDriveModuleManagedUsersOnlyParam[] =
392     "NtpDriveModuleManagedUsersOnlyParam";
393 const char kNtpDriveModuleCacheMaxAgeSParam[] =
394     "NtpDriveModuleCacheMaxAgeSParam";
395 const char kNtpDriveModuleExperimentGroupParam[] =
396     "NtpDriveModuleExperimentGroupParam";
397 const char kNtpHistoryClustersModuleDataParam[] =
398     "NtpHistoryClustersModuleDataParam";
399 const char kNtpChromeCartInHistoryClustersModuleDataParam[] =
400     "NtpChromeCartInHistoryClustersModuleDataParam";
401 const char kNtpMiddleSlotPromoDismissalParam[] =
402     "NtpMiddleSlotPromoDismissalParam";
403 const char kNtpPhotosModuleDataParam[] = "NtpPhotosModuleDataParam";
404 const char kNtpPhotosModuleOptInTitleParam[] = "NtpPhotosModuleOptInTitleParam";
405 const char kNtpPhotosModuleOptInArtWorkParam[] =
406     "NtpPhotosModuleOptInArtWorkParam";
407 const char kNtpSafeBrowsingModuleCooldownPeriodDaysParam[] =
408     "NtpSafeBrowsingModuleCooldownPeriodDaysParam";
409 const char kNtpSafeBrowsingModuleCountMaxParam[] =
410     "NtpSafeBrowsingModuleCountMaxParam";
411 const char kNtpRecipeTasksModuleDataParam[] = "NtpRecipeTasksModuleDataParam";
412 const char kNtpRecipeTasksModuleCacheMaxAgeSParam[] =
413     "NtpRecipeTasksModuleCacheMaxAgeSParam";
414 const char kNtpRecipeTasksModuleExperimentGroupParam[] =
415     "NtpRecipeTasksModuleExperimentGroupParam";
416 const char kNtpHistoryClustersModuleBeginTimeDurationHoursParam[] =
417     "NtpHistoryClustersModuleBeginTimeDurationHoursParam";
418 const char kNtpHistoryClustersModuleMinimumVisitsRequiredParam[] =
419     "NtpHistoryClustersModuleMinimumVisitsRequiredParam";
420 const char kNtpHistoryClustersModuleMinimumImagesRequiredParam[] =
421     "NtpHistoryClustersModuleMinimumImagesRequiredParam";
422 const char kNtpHistoryClustersModuleCategoriesAllowlistParam[] =
423     "NtpHistoryClustersModuleCategoriesParam";
424 const char kNtpHistoryClustersModuleCategoriesBlocklistParam[] =
425     "NtpHistoryClustersModuleCategoriesBlocklistParam";
426 const char kNtpHistoryClustersModuleCategoriesBoostlistParam[] =
427     "NtpHistoryClustersModuleCategoriesBoostlistParam";
428 const char kNtpHistoryClustersModuleMaxClustersParam[] =
429     "NtpHistoryClustersModuleMaxClustersParam";
430 const char kNtpRealboxWidthBehaviorParam[] = "NtpRealboxWidthBehaviorParam";
431
432 base::TimeDelta GetModulesLoadTimeout() {
433   std::string param_value = base::GetFieldTrialParamValueByFeature(
434       kNtpModulesLoadTimeoutMilliseconds,
435       kNtpModulesLoadTimeoutMillisecondsParam);
436   // If the field trial param is not found or cannot be parsed to an unsigned
437   // integer, return the default value.
438   unsigned int param_value_as_int = 0;
439   if (!base::StringToUint(param_value, &param_value_as_int)) {
440     return base::Seconds(3);
441   }
442   return base::Milliseconds(param_value_as_int);
443 }
444
445 int GetModulesMaxColumnCount() {
446   return base::GetFieldTrialParamByFeatureAsInt(
447       kNtpModulesMaxColumnCount, kNtpModulesMaxColumnCountParam, 3);
448 }
449
450 int GetMultipleLoadedModulesMaxModuleInstanceCount() {
451   return base::GetFieldTrialParamByFeatureAsInt(
452       kNtpModulesLoadedWithOtherModulesMaxInstanceCount,
453       kNtpModulesLoadedWithOtherModulesMaxInstanceCountParam, 2);
454 }
455
456 std::vector<std::string> GetModulesOrder() {
457   return base::SplitString(base::GetFieldTrialParamValueByFeature(
458                                kNtpModulesOrder, kNtpModulesOrderParam),
459                            ",:;", base::WhitespaceHandling::TRIM_WHITESPACE,
460                            base::SplitResult::SPLIT_WANT_NONEMPTY);
461 }
462
463 }  // namespace ntp_features