1 // Copyright 2018 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.
5 #include "components/search/ntp_features.h"
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/time/time.h"
11 #include "build/build_config.h"
13 namespace ntp_features {
15 // If enabled, shows a confirm dialog before removing search suggestions from
16 // the New Tab page real search box ("realbox").
17 const base::Feature kConfirmSuggestionRemovals{
18 "ConfirmNtpSuggestionRemovals", base::FEATURE_DISABLED_BY_DEFAULT};
20 // If enabled, the OneGooleBar cached response is sent back to NTP.
21 const base::Feature kCacheOneGoogleBar{"CacheOneGoogleBar",
22 base::FEATURE_DISABLED_BY_DEFAULT};
24 // If enabled, "middle slot" promos on the bottom of the NTP will show a dismiss
25 // UI that allows users to close them and not see them again.
26 const base::Feature kDismissPromos{"DismissNtpPromos",
27 base::FEATURE_DISABLED_BY_DEFAULT};
29 // If enabled, queries that are frequently repeated by the user (and are
30 // expected to be issued again) are shown as most visited tiles.
31 const base::Feature kNtpRepeatableQueries{"NtpRepeatableQueries",
32 base::FEATURE_DISABLED_BY_DEFAULT};
34 // Depends on kRealbox being enabled. If enabled, the NTP "realbox" will be
35 // themed like the omnibox (same background/text/selected/hover colors).
36 const base::Feature kRealboxMatchOmniboxTheme{
37 "NtpRealboxMatchOmniboxTheme", base::FEATURE_DISABLED_BY_DEFAULT};
39 // If enabled, the real search box ("realbox") on the New Tab page will show a
40 // Google (g) icon instead of the typical magnifying glass (aka loupe).
41 const base::Feature kRealboxUseGoogleGIcon{"NtpRealboxUseGoogleGIcon",
42 base::FEATURE_DISABLED_BY_DEFAULT};
44 // If enabled, shows Vasco suggestion chips in the NTP below fakebox/realbox
45 // despite other config except DisableSearchSuggestChips below.
46 const base::Feature kSearchSuggestChips{"SearchSuggestChips",
47 base::FEATURE_DISABLED_BY_DEFAULT};
49 // If enabled, hides Vasco suggestion chips in the NTP below fakebox/realbox
50 // despite other config.
51 const base::Feature kDisableSearchSuggestChips{
52 "DisableSearchSuggestChips", base::FEATURE_DISABLED_BY_DEFAULT};
54 // If enabled, handles navigations from the Most Visited tiles explicitly and
55 // overrides the navigation's transition type to bookmark navigation before the
56 // navigation is issued.
57 // TODO(crbug.com/1147589): When removing this flag, also remove the workaround
58 // in ChromeContentBrowserClient::OverrideNavigationParams.
59 extern const base::Feature kNtpHandleMostVisitedNavigationExplicitly{
60 "HandleMostVisitedNavigationExplicitly", base::FEATURE_ENABLED_BY_DEFAULT};
62 // If enabled, logo will be shown.
63 const base::Feature kNtpLogo{"NtpLogo", base::FEATURE_ENABLED_BY_DEFAULT};
65 // If enabled, shortcuts will be shown.
66 const base::Feature kNtpShortcuts{"NtpShortcuts",
67 base::FEATURE_ENABLED_BY_DEFAULT};
69 // If enabled, middle slot promo will be shown.
70 const base::Feature kNtpMiddleSlotPromo{"NtpMiddleSlotPromo",
71 base::FEATURE_ENABLED_BY_DEFAULT};
73 // If enabled, modules will be shown.
74 const base::Feature kModules{"NtpModules", base::FEATURE_DISABLED_BY_DEFAULT};
76 // If enabled, modules will be loaded even if kModules is disabled. This is
77 // useful to determine if a user would have seen modules in order to
78 // counterfactually log or trigger.
79 const base::Feature kNtpModulesLoad{"NtpModulesLoad",
80 base::FEATURE_DISABLED_BY_DEFAULT};
82 // If enabled, recipe tasks module will be shown.
83 const base::Feature kNtpRecipeTasksModule{"NtpRecipeTasksModule",
84 base::FEATURE_DISABLED_BY_DEFAULT};
86 // If enabled, shopping tasks module will be shown.
87 const base::Feature kNtpShoppingTasksModule{"NtpShoppingTasksModule",
88 base::FEATURE_DISABLED_BY_DEFAULT};
90 // If enabled, chrome cart module will be shown.
91 const base::Feature kNtpChromeCartModule{"NtpChromeCartModule",
92 base::FEATURE_DISABLED_BY_DEFAULT};
94 // If enabled, redesigned modules will be shown.
95 const base::Feature kNtpModulesRedesigned{"NtpModulesRedesigned",
96 base::FEATURE_DISABLED_BY_DEFAULT};
98 // If enabled, Google Drive module will be shown.
99 const base::Feature kNtpDriveModule{"NtpDriveModule",
100 base::FEATURE_DISABLED_BY_DEFAULT};
102 // If enabled, Google Photos module will be shown.
103 const base::Feature kNtpPhotosModule{"NtpPhotosModule",
104 base::FEATURE_DISABLED_BY_DEFAULT};
106 // If enabled, modules will be able to be reordered via dragging and dropping
107 const base::Feature kNtpModulesDragAndDrop{"NtpModulesDragAndDrop",
108 base::FEATURE_DISABLED_BY_DEFAULT};
110 const char kNtpModulesLoadTimeoutMillisecondsParam[] =
111 "NtpModulesLoadTimeoutMillisecondsParam";
112 const char kNtpShoppingTasksModuleDataParam[] =
113 "NtpShoppingTasksModuleDataParam";
114 const char kNtpRecipeTasksModuleDataParam[] = "NtpRecipeTasksModuleDataParam";
115 const char kNtpShoppingTasksModuleCacheMaxAgeSParam[] =
116 "NtpShoppingTasksModuleCacheMaxAgeSParam";
117 const char kNtpRecipeTasksModuleCacheMaxAgeSParam[] =
118 "NtpRecipeTasksModuleCacheMaxAgeSParam";
119 const char kNtpChromeCartModuleDataParam[] = "NtpChromeCartModuleDataParam";
120 const char kNtpChromeCartModuleAbandonedCartDiscountParam[] =
121 "NtpChromeCartModuleAbandonedCartDiscountParam";
122 const char NtpChromeCartModuleAbandonedCartDiscountUseUtmParam[] =
123 "NtpChromeCartModuleAbandonedCartDiscountUseUtmParam";
124 const char kNtpChromeCartModuleHeuristicsImprovementParam[] =
125 "NtpChromeCartModuleHeuristicsImprovementParam";
126 const char kNtpDriveModuleDataParam[] = "NtpDriveModuleDataParam";
127 const char kNtpDriveModuleManagedUsersOnlyParam[] =
128 "NtpDriveModuleManagedUsersOnlyParam";
129 const char kNtpDriveModuleCacheMaxAgeSParam[] =
130 "NtpDriveModuleCacheMaxAgeSParam";
131 const char kNtpDriveModuleExperimentGroupParam[] =
132 "NtpDriveModuleExperimentGroupParam";
134 base::TimeDelta GetModulesLoadTimeout() {
135 std::string param_value = base::GetFieldTrialParamValueByFeature(
136 kModules, kNtpModulesLoadTimeoutMillisecondsParam);
137 // If the field trial param is not found or cannot be parsed to an unsigned
138 // integer, return the default value.
139 unsigned int param_value_as_int = 0;
140 if (!base::StringToUint(param_value, ¶m_value_as_int)) {
141 return base::TimeDelta::FromSeconds(3);
143 return base::TimeDelta::FromMilliseconds(param_value_as_int);
146 } // namespace ntp_features