1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/search/ntp_features.h"
#include "base/feature_list.h"
#include "base/strings/string_number_conversions.h"
#include "base/time/time.h"
#include "build/build_config.h"
namespace ntp_features {
// If enabled, shows a confirm dialog before removing search suggestions from
// the New Tab page real search box ("realbox").
const base::Feature kConfirmSuggestionRemovals{
"ConfirmNtpSuggestionRemovals", base::FEATURE_DISABLED_BY_DEFAULT};
// If enabled, "middle slot" promos on the bottom of the NTP will show a dismiss
// UI that allows users to close them and not see them again.
const base::Feature kDismissPromos{"DismissNtpPromos",
base::FEATURE_DISABLED_BY_DEFAULT};
// If enabled, the OneGooleBar is loaded in an iframe. Otherwise, it is inlined.
const base::Feature kIframeOneGoogleBar{"IframeOneGoogleBar",
base::FEATURE_DISABLED_BY_DEFAULT};
// If enabled, queries that are frequently repeated by the user (and are
// expected to be issued again) are shown as most visited tiles.
const base::Feature kNtpRepeatableQueries{"NtpRepeatableQueries",
base::FEATURE_DISABLED_BY_DEFAULT};
// If enabled, the iframed OneGooleBar shows the overlays modally with a
// backdrop.
const base::Feature kOneGoogleBarModalOverlays{
"OneGoogleBarModalOverlays", base::FEATURE_DISABLED_BY_DEFAULT};
// Depends on kRealbox being enabled. If enabled, the NTP "realbox" will be
// themed like the omnibox (same background/text/selected/hover colors).
const base::Feature kRealboxMatchOmniboxTheme{
"NtpRealboxMatchOmniboxTheme", base::FEATURE_DISABLED_BY_DEFAULT};
// If enabled, the real search box ("realbox") on the New Tab page will show a
// Google (g) icon instead of the typical magnifying glass (aka loupe).
const base::Feature kRealboxUseGoogleGIcon{"NtpRealboxUseGoogleGIcon",
base::FEATURE_DISABLED_BY_DEFAULT};
// If enabled, shows Vasco suggestion chips in the NTP below fakebox/realbox
// despite other config except DisableSearchSuggestChips below.
const base::Feature kSearchSuggestChips{"SearchSuggestChips",
base::FEATURE_DISABLED_BY_DEFAULT};
// If enabled, hides Vasco suggestion chips in the NTP below fakebox/realbox
// despite other config.
const base::Feature kDisableSearchSuggestChips{
"DisableSearchSuggestChips", base::FEATURE_DISABLED_BY_DEFAULT};
// If enabled, handles navigations from the Most Visited tiles explicitly and
// overrides the navigation's transition type to bookmark navigation before the
// navigation is issued.
// TODO(crbug.com/1147589): When removing this flag, also remove the workaround
// in ChromeContentBrowserClient::OverrideNavigationParams.
extern const base::Feature kNtpHandleMostVisitedNavigationExplicitly{
"HandleMostVisitedNavigationExplicitly", base::FEATURE_ENABLED_BY_DEFAULT};
// If enabled, the WebUI new tab page will load when a new tab is created
// instead of the local NTP.
const base::Feature kWebUI{"NtpWebUI", base::FEATURE_ENABLED_BY_DEFAULT};
// If enabled, the Doodle will be shown on themed and dark mode NTPs.
const base::Feature kWebUIThemeModeDoodles{"WebUIThemeModeDoodles",
base::FEATURE_ENABLED_BY_DEFAULT};
// If enabled, modules will be shown.
const base::Feature kModules{"NtpModules", base::FEATURE_DISABLED_BY_DEFAULT};
// If enabled, recipe tasks module will be shown.
const base::Feature kNtpRecipeTasksModule{"NtpRecipeTasksModule",
base::FEATURE_DISABLED_BY_DEFAULT};
// If enabled, shopping tasks module will be shown.
const base::Feature kNtpShoppingTasksModule{"NtpShoppingTasksModule",
base::FEATURE_DISABLED_BY_DEFAULT};
const char kNtpRepeatableQueriesAgeThresholdDaysParam[] =
"NtpRepeatableQueriesAgeThresholdDays";
const char kNtpRepeatableQueriesRecencyHalfLifeSecondsParam[] =
"NtpRepeatableQueriesRecencyHalfLifeSeconds";
const char kNtpRepeatableQueriesFrequencyExponentParam[] =
"NtpRepeatableQueriesFrequencyExponent";
const char kNtpRepeatableQueriesInsertPositionParam[] =
"NtpRepeatableQueriesInsertPosition";
const char kNtpStatefulTasksModuleDataParam[] =
"NtpStatefulTasksModuleDataParam";
base::Time GetLocalHistoryRepeatableQueriesAgeThreshold() {
const base::TimeDelta kLocalHistoryRepeatableQueriesAgeThreshold =
base::TimeDelta::FromDays(180); // Six months.
std::string param_value = base::GetFieldTrialParamValueByFeature(
kNtpRepeatableQueries, kNtpRepeatableQueriesAgeThresholdDaysParam);
// If the field trial param is not found or cannot be parsed to an unsigned
// integer, return the default value.
unsigned int param_value_as_int = 0;
if (!base::StringToUint(param_value, ¶m_value_as_int)) {
return base::Time::Now() - kLocalHistoryRepeatableQueriesAgeThreshold;
}
return (base::Time::Now() - base::TimeDelta::FromDays(param_value_as_int));
}
int GetLocalHistoryRepeatableQueriesRecencyHalfLifeSeconds() {
const base::TimeDelta kLocalHistoryRepeatableQueriesRecencyHalfLife =
base::TimeDelta::FromDays(7); // One week.
std::string param_value = base::GetFieldTrialParamValueByFeature(
kNtpRepeatableQueries, kNtpRepeatableQueriesRecencyHalfLifeSecondsParam);
// If the field trial param is not found or cannot be parsed to an unsigned
// integer, return the default value.
unsigned int param_value_as_int = 0;
if (!base::StringToUint(param_value, ¶m_value_as_int)) {
return kLocalHistoryRepeatableQueriesRecencyHalfLife.InSeconds();
}
return param_value_as_int;
}
double GetLocalHistoryRepeatableQueriesFrequencyExponent() {
const double kLocalHistoryRepeatableQueriesFrequencyExponent = 2.0;
std::string param_value = base::GetFieldTrialParamValueByFeature(
kNtpRepeatableQueries, kNtpRepeatableQueriesFrequencyExponentParam);
// If the field trial param is not found or cannot be parsed to an unsigned
// integer, return the default value.
double param_value_as_double = 0;
if (!base::StringToDouble(param_value, ¶m_value_as_double)) {
return kLocalHistoryRepeatableQueriesFrequencyExponent;
}
return param_value_as_double;
}
RepeatableQueriesInsertPosition GetRepeatableQueriesInsertPosition() {
std::string param_value = base::GetFieldTrialParamValueByFeature(
kNtpRepeatableQueries, kNtpRepeatableQueriesInsertPositionParam);
return param_value == "end" ? RepeatableQueriesInsertPosition::kEnd
: RepeatableQueriesInsertPosition::kStart;
}
} // namespace ntp_features
|