Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
chromium
GitHub Repository: chromium/chromium
Path: blob/main/components/omnibox/common/omnibox_features.cc
70072 views
1
// Copyright 2019 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/omnibox/common/omnibox_features.h"
6
7
#include "base/feature_list.h"
8
#include "build/build_config.h"
9
10
#if BUILDFLAG(IS_ANDROID)
11
#include "base/android/feature_map.h"
12
#include "base/no_destructor.h"
13
#include "components/omnibox/common/jni_headers/OmniboxFeatureMap_jni.h"
14
#endif
15
16
namespace omnibox {
17
namespace {
18
constexpr bool IS_ANDROID = !!BUILDFLAG(IS_ANDROID);
19
constexpr bool IS_IOS = !!BUILDFLAG(IS_IOS);
20
21
constexpr base::FeatureState DISABLED = base::FEATURE_DISABLED_BY_DEFAULT;
22
constexpr base::FeatureState ENABLED = base::FEATURE_ENABLED_BY_DEFAULT;
23
24
constexpr base::FeatureState enable_if(bool condition) {
25
return condition ? ENABLED : DISABLED;
26
}
27
} // namespace
28
29
// Feature to enable showing thumbnail in front of the Omnibox clipboard image
30
// search suggestion.
31
BASE_FEATURE(kImageSearchSuggestionThumbnail, enable_if(IS_ANDROID));
32
33
// Feature used to allow users to remove suggestions from clipboard.
34
BASE_FEATURE(kOmniboxRemoveSuggestionsFromClipboard, enable_if(IS_ANDROID));
35
36
// When enabled, uses the grouping framework with prefixed suggestions (i.e.
37
// autocomplete_grouper_sections.h) to limit and group (but not sort) matches.
38
BASE_FEATURE(kGroupingFrameworkForNonZPS,
39
"OmniboxGroupingFrameworkForNonZPS",
40
enable_if(IS_ANDROID));
41
42
// Feature used to cap max zero suggestions shown according to the param
43
// OmniboxMaxZeroSuggestMatches. If omitted,
44
// OmniboxUIExperimentMaxAutocompleteMatches will be used instead. If present,
45
// OmniboxMaxZeroSuggestMatches will override
46
// OmniboxUIExperimentMaxAutocompleteMatches when |from_omnibox_focus| is true.
47
BASE_FEATURE(kMaxZeroSuggestMatches, "OmniboxMaxZeroSuggestMatches", DISABLED);
48
49
// Feature used to cap max suggestions shown according to the params
50
// UIMaxAutocompleteMatches and UIMaxAutocompleteMatchesByProvider.
51
BASE_FEATURE(kUIExperimentMaxAutocompleteMatches,
52
"OmniboxUIExperimentMaxAutocompleteMatches",
53
DISABLED);
54
55
// Feature used to cap max suggestions to a dynamic limit based on how many URLs
56
// would be shown. E.g., show up to 10 suggestions if doing so would display no
57
// URLs; else show up to 8 suggestions if doing so would include 1 or more URLs.
58
BASE_FEATURE(kDynamicMaxAutocomplete,
59
"OmniboxDynamicMaxAutocomplete",
60
enable_if(!IS_IOS));
61
62
// Enables omnibox focus as a trigger for zero-prefix suggestions on web and
63
// SRP, subject to the same requirements and conditions as on-clobber
64
// suggestions.
65
BASE_FEATURE(kFocusTriggersWebAndSRPZeroSuggest,
66
"OmniboxFocusTriggersWebAndSRPZeroSuggest",
67
ENABLED);
68
69
// Enables on-clobber suggestions on iOS.
70
BASE_FEATURE(kOnClobberSuggestIOS, ENABLED);
71
72
// If enabled, contextual suggestion group headers in the Omnibox popup will
73
// be hidden (e.g. in order to minimize visual clutter in the zero-prefix
74
// state).
75
BASE_FEATURE(kHideContextualGroupHeaders, DISABLED);
76
77
// If enabled, suggestion group headers in the Omnibox popup will be hidden
78
// (e.g. in order to minimize visual clutter in the zero-prefix state).
79
BASE_FEATURE(kHideSuggestionGroupHeaders,
80
"OmniboxHideSuggestionGroupHeaders",
81
ENABLED);
82
83
// Enables local history zero-prefix suggestions in every context in which the
84
// remote zero-prefix suggestions are enabled.
85
BASE_FEATURE(kLocalHistoryZeroSuggestBeyondNTP, DISABLED);
86
87
// Enables the use of a request debouncer to throttle the number of ZPS prefetch
88
// requests initiated over a given period of time (to help minimize the
89
// performance impact of ZPS prefetching on the remote Suggest service).
90
BASE_FEATURE(kZeroSuggestPrefetchDebouncing, DISABLED);
91
92
// Enables prefetching of the zero prefix suggestions for eligible users on SRP.
93
BASE_FEATURE(kZeroSuggestPrefetchingOnSRP, enable_if(!IS_ANDROID));
94
95
// Enables prefetching of the zero prefix suggestions for eligible users on the
96
// Web (i.e. non-NTP and non-SRP URLs).
97
BASE_FEATURE(kZeroSuggestPrefetchingOnWeb, DISABLED);
98
99
// Features to provide head and tail non personalized search suggestion from
100
// compact on device models. More specifically, feature name with suffix
101
// Incognito / NonIncognito will only controls behaviors under incognito /
102
// non-incognito mode respectively.
103
BASE_FEATURE(kOnDeviceHeadProviderIncognito,
104
"OmniboxOnDeviceHeadProviderIncognito",
105
ENABLED);
106
BASE_FEATURE(kOnDeviceHeadProviderNonIncognito,
107
"OmniboxOnDeviceHeadProviderNonIncognito",
108
ENABLED);
109
BASE_FEATURE(kOnDeviceTailModel,
110
"OmniboxOnDeviceTailModel",
111
enable_if(IS_ANDROID || IS_IOS));
112
BASE_FEATURE(kOnDeviceTailEnableEnglishModel,
113
"OmniboxOnDeviceTailEnableEnglishModel",
114
ENABLED);
115
116
// Feature used to fetch document suggestions.
117
BASE_FEATURE(kDocumentProvider,
118
"OmniboxDocumentProvider",
119
enable_if(!IS_ANDROID && !IS_IOS));
120
121
// If enabled, the authentication requirement for Drive suggestions is based on
122
// whether the primary account is available, i.e., the user is signed into
123
// Chrome, rarther than checking if any signed in account is available in the
124
// cookie jar.
125
BASE_FEATURE(kDocumentProviderPrimaryAccountRequirement,
126
"OmniboxDocumentProviderPrimaryAccountRequirement",
127
ENABLED);
128
129
// If enabled, the primary account must be subject to enterprise policies in
130
// order to receive Drive suggestions.
131
BASE_FEATURE(kDocumentProviderEnterpriseEligibility,
132
"OmniboxDocumentProviderEnterpriseEligibility",
133
ENABLED);
134
135
// If enabled, the enterprise eligibility requirement for Drive suggestions
136
// is considered met even when the account capability is unknown. Has no effect
137
// if kDocumentProviderEnterpriseEligibility is disabled.
138
BASE_FEATURE(kDocumentProviderEnterpriseEligibilityWhenUnknown,
139
"OmniboxDocumentProviderEnterpriseEligibilityWhenUnknown",
140
DISABLED);
141
142
// If enabled, the requirement to be in an active Sync state is removed and
143
// Drive suggestions are available to all clients who meet the other
144
// requirements.
145
BASE_FEATURE(kDocumentProviderNoSyncRequirement,
146
"OmniboxDocumentProviderNoSyncRequirement",
147
ENABLED);
148
149
// If enabled, the omnibox popup is not presented until the mouse button is
150
// released.
151
BASE_FEATURE(kShowPopupOnMouseReleased,
152
"OmniboxShowPopupOnMouseReleased",
153
ENABLED);
154
155
// If enabled, makes Most Visited Tiles a Horizontal render group.
156
// Horizontal render group decomposes aggregate suggestions (such as old Most
157
// Visited Tiles), expecting individual AutocompleteMatch entry for every
158
// element in the carousel.
159
BASE_FEATURE(kMostVisitedTilesHorizontalRenderGroup,
160
"OmniboxMostVisitedTilesHorizontalRenderGroup",
161
enable_if(IS_ANDROID));
162
163
// If enabled, expands autocompletion to possibly (depending on params) include
164
// suggestion titles and non-prefixes as opposed to be restricted to URL
165
// prefixes. Will also adjust the location bar UI and omnibox text selection to
166
// accommodate the autocompletions.
167
BASE_FEATURE(kRichAutocompletion, "OmniboxRichAutocompletion", ENABLED);
168
169
// When enabled, the multimodal input button is shown in the Omnibox.
170
BASE_FEATURE(kOmniboxMultimodalInput, DISABLED);
171
172
// Whether the AI Mode entrypoint is shown in the Omnibox as a RHS button. Only
173
// used on desktop platforms.
174
BASE_FEATURE(kAiModeOmniboxEntryPoint, ENABLED);
175
176
// Hides the AIM entrypoint in the Omnibox when user input is in progress. Only
177
// used on desktop platforms.
178
BASE_FEATURE(kHideAimEntrypointOnUserInput,
179
"OmniboxHideAimEntrypointOnUserInput",
180
DISABLED);
181
182
183
// When enabled, removes the Search Ready Omnibox feature.
184
BASE_FEATURE(kRemoveSearchReadyOmnibox, DISABLED);
185
186
// Feature used to default typed navigations to use HTTPS instead of HTTP.
187
// This only applies to navigations that don't have a scheme such as
188
// "example.com". Presently, typing "example.com" in a clean browsing profile
189
// loads http://example.com. When this feature is enabled, it should load
190
// https://example.com instead, with fallback to http://example.com if
191
// necessary.
192
// TODO(crbug.com/375004882): On non-iOS platforms, this feature is now
193
// superseded by HTTPS-Upgrades and will be removed in the near future.
194
BASE_FEATURE(kDefaultTypedNavigationsToHttps,
195
"OmniboxDefaultTypedNavigationsToHttps",
196
enable_if(IS_IOS));
197
198
// Override the delay to create a spare renderer when the omnibox is focused
199
// on Android.
200
BASE_FEATURE(kOverrideAndroidOmniboxSpareRendererDelay, DISABLED);
201
202
// Parameter name used to look up the delay before falling back to the HTTP URL
203
// while trying an HTTPS URL. The parameter is treated as a TimeDelta, so the
204
// unit must be included in the value as well (e.g. 3s for 3 seconds).
205
// - If the HTTPS load finishes successfully during this time, the timer is
206
// cleared and no more work is done.
207
// - Otherwise, a new navigation to the the fallback HTTP URL is started.
208
const char kDefaultTypedNavigationsToHttpsTimeoutParam[] = "timeout";
209
210
// If enabled, logs Omnibox URL scoring signals to OmniboxEventProto for
211
// training the ML scoring models.
212
BASE_FEATURE(kLogUrlScoringSignals, DISABLED);
213
214
// If true, enables history scoring signal annotator for populating history
215
// scoring signals associated with Search suggestions. These signals will be
216
// empty for Search suggestions otherwise.
217
BASE_FEATURE(kEnableHistoryScoringSignalsAnnotatorForSearches, DISABLED);
218
219
// If enabled, (floating-point) ML model scores are mapped to (integral)
220
// relevance scores by means of a piecewise function. This allows for the
221
// integration of URL model scores with search traditional scores.
222
BASE_FEATURE(kMlUrlPiecewiseMappedSearchBlending, DISABLED);
223
224
// If enabled, the ML scoring service will make use of an in-memory ML score
225
// cache in order to speed up the overall scoring process.
226
BASE_FEATURE(kMlUrlScoreCaching, enable_if(!IS_ANDROID));
227
228
// If enabled, runs the ML scoring model to assign new relevance scores to the
229
// URL suggestions and reranks them.
230
BASE_FEATURE(kMlUrlScoring, enable_if(!IS_ANDROID));
231
232
// If enabled, specifies how URL model scores integrate with search traditional
233
// scores.
234
BASE_FEATURE(kMlUrlSearchBlending, DISABLED);
235
236
// If enabled, creates Omnibox autocomplete URL scoring model. Prerequisite for
237
// `kMlUrlScoring` & `kMlUrlSearchBlending`.
238
BASE_FEATURE(kUrlScoringModel, enable_if(!IS_ANDROID));
239
240
BASE_FEATURE(kAnimateSuggestionsListAppearance, ENABLED);
241
242
// If enabled, sends a signal when a user touches down on a search suggestion to
243
// |SearchPrefetchService|. |SearchPrefetchService| will then prefetch
244
// suggestion iff the SearchNavigationPrefetch feature and "touch_down" param
245
// are enabled.
246
BASE_FEATURE(kOmniboxTouchDownTriggerForPrefetch, enable_if(IS_ANDROID));
247
248
// Enables keyword-based site search functionality on Android devices.
249
BASE_FEATURE(kOmniboxSiteSearch, DISABLED);
250
251
// Enables additional site search providers for the Site search Starter Pack.
252
BASE_FEATURE(kStarterPackExpansion, enable_if(!IS_ANDROID && !IS_IOS));
253
254
// Enables an informational IPH message at the bottom of the Omnibox directing
255
// users to certain starter pack engines.
256
BASE_FEATURE(kStarterPackIPH, DISABLED);
257
258
// Enables an '@aimode' starter pack keyword for eligible users only.
259
BASE_FEATURE(kAiModeStartPack, DISABLED);
260
261
// If enabled, |SearchProvider| will not function in Zero Suggest.
262
BASE_FEATURE(kAblateSearchProviderWarmup, DISABLED);
263
264
// If enabled, hl= is reported in search requests (applicable to iOS only).
265
BASE_FEATURE(kReportApplicationLanguageInSearchRequest, ENABLED);
266
267
// Enable asynchronous Omnibox/Suggest view inflation.
268
BASE_FEATURE(kOmniboxAsyncViewInflation, DISABLED);
269
270
// Use FusedLocationProvider on Android to fetch device location.
271
BASE_FEATURE(kUseFusedLocationProvider, ENABLED);
272
273
// Updates various NTP/Omnibox assets and descriptions for visual alignment on
274
// iOS.
275
BASE_FEATURE(kOmniboxMobileParityUpdate, ENABLED);
276
277
// Updates various NTP/Omnibox assets and descriptions for visual alignment on
278
// Android and iOS, V2.
279
BASE_FEATURE(kOmniboxMobileParityUpdateV2, ENABLED);
280
281
// If enabled, the X-Geo header will include permission granularity.
282
BASE_FEATURE(kOmniboxXGeoPermissionGranularity, ENABLED);
283
284
// The features below allow tuning number of suggestions offered to users in
285
// specific contexts. These features are default enabled and are used to control
286
// related fieldtrial parameters.
287
BASE_FEATURE(kNumNtpZpsRecentSearches,
288
"OmniboxNumNtpZpsRecentSearches",
289
ENABLED);
290
BASE_FEATURE(kNumNtpZpsTrendingSearches,
291
"OmniboxNumNtpZpsTrendingSearches",
292
ENABLED);
293
BASE_FEATURE(kNumWebZpsRecentSearches,
294
"OmniboxNumWebZpsRecentSearches",
295
ENABLED);
296
BASE_FEATURE(kNumWebZpsRelatedSearches,
297
"OmniboxNumWebZpsRelatedSearches",
298
ENABLED);
299
BASE_FEATURE(kNumWebZpsMostVisitedUrls,
300
"OmniboxNumWebZpsMostVisitedUrls",
301
ENABLED);
302
BASE_FEATURE(kNumSrpZpsRecentSearches,
303
"OmniboxNumSrpZpsRecentSearches",
304
ENABLED);
305
BASE_FEATURE(kNumSrpZpsRelatedSearches,
306
"OmniboxNumSrpZpsRelatedSearches",
307
ENABLED);
308
309
// If enabled, search aggregators defined by the
310
// EnterpriseSearchAggregatorSettings policy are saved into prefs and available
311
// in the TemplateURLService, so that they can be accessed from the Omnibox and
312
// the Settings page.
313
BASE_FEATURE(kEnableSearchAggregatorPolicy, ENABLED);
314
315
BASE_FEATURE(kUseAgentspace25Logo, ENABLED);
316
317
// If enabled, site search engines, defined by the `SiteSearchSettings` policy,
318
// can be marked as user-overridable by administrators using an
319
// `allow_user_override` field. This setting is stored in preferences and
320
// determines if the engine can be overridden on the Settings page.
321
BASE_FEATURE(kEnableSiteSearchAllowUserOverridePolicy, ENABLED);
322
323
// Enables preconnecting to omnibox suggestions that are not only Search types.
324
BASE_FEATURE(kPreconnectNonSearchOmniboxSuggestions, ENABLED);
325
326
// When enabled, unblocks omnibox height on small form factor devices, allowing
327
// users to type in multiline / longer text.
328
BASE_FEATURE(kMultilineEditField, "OmniboxMultilineEditField", ENABLED);
329
330
// Controls whether the composebox
331
BASE_FEATURE(kComposeboxUsesChromeComposeClient, ENABLED);
332
333
// Controls whether or not contextual composebox should display suggestions.
334
BASE_FEATURE(kComposeboxAttachmentsTypedState, DISABLED);
335
336
// Enables passthrough params to be sent to the AIM eligibility service.
337
BASE_FEATURE(kAimUrlInterceptPassthrough, DISABLED);
338
339
BASE_FEATURE(kOmniboxDebugLogs, base::FEATURE_DISABLED_BY_DEFAULT);
340
341
BASE_FEATURE(kThinkingModelIconUpdate, base::FEATURE_DISABLED_BY_DEFAULT);
342
343
#if BUILDFLAG(IS_ANDROID)
344
// Accelerates time from cold start to focused Omnibox on low-end devices,
345
// prioritizing Omnibox focus and background initialization.
346
BASE_FEATURE(kJumpStartOmnibox, DISABLED);
347
348
// Prevents intermediate AutocompleteResult updates from being sent to Java on
349
// low-end devices. This aims at eliminating time spent on constructing,
350
// measuring, and laying out views that are about to be discarded, and reducing
351
// the volume of JNI jumps.
352
BASE_FEATURE(kSuppressIntermediateACUpdatesOnLowEndDevices, DISABLED);
353
354
// (Android only) Show tab groups via the search feature in the hub.
355
BASE_FEATURE(kAndroidHubSearchTabGroups, ENABLED);
356
357
// When enabled, delay focusTab to prioritize navigation
358
// (https://crbug.com/374852568).
359
BASE_FEATURE(kPostDelayedTaskFocusTab, ENABLED);
360
361
// Controls various Omnibox Diagnostics features.
362
BASE_FEATURE(kDiagnostics, "OmniboxDiagnostics", DISABLED);
363
364
// When enabled, offer a desktop-like omnibox UI enhancement on large form
365
// factors.
366
BASE_FEATURE(kOmniboxImprovementForLFF, DISABLED);
367
368
// If enabled, disables ligatures in the URL bar on Android.
369
BASE_FEATURE(kUrlBarWithoutLigatures, ENABLED);
370
371
namespace android {
372
static int64_t JNI_OmniboxFeatureMap_GetNativeMap(JNIEnv* env) {
373
static const base::Feature* const kFeaturesExposedToJava[] = {
374
&kDiagnostics,
375
&kAnimateSuggestionsListAppearance,
376
&kOmniboxTouchDownTriggerForPrefetch,
377
&kOmniboxAsyncViewInflation,
378
&kRichAutocompletion,
379
&kUrlBarWithoutLigatures,
380
&kUseFusedLocationProvider,
381
&kJumpStartOmnibox,
382
&kAndroidHubSearchTabGroups,
383
&kPostDelayedTaskFocusTab,
384
&kOmniboxMobileParityUpdateV2,
385
&kOmniboxXGeoPermissionGranularity,
386
&kOmniboxSiteSearch,
387
&kOmniboxMultimodalInput,
388
&kMultilineEditField,
389
&kOmniboxImprovementForLFF,
390
&kRemoveSearchReadyOmnibox};
391
static base::NoDestructor<base::android::FeatureMap> kFeatureMap(
392
kFeaturesExposedToJava);
393
return reinterpret_cast<int64_t>(kFeatureMap.get());
394
}
395
} // namespace android
396
#endif // BUILDFLAG(IS_ANDROID)
397
// Note: no new flags beyond this point.
398
399
namespace flag_descriptions {
400
const char kOmniboxDebugLogsName[] = "Omnibox debug logs";
401
const char kOmniboxDebugLogsDescription[] =
402
"Enables logging that can be read from an internals page.";
403
} // namespace flag_descriptions
404
405
} // namespace omnibox
406
407
#if BUILDFLAG(IS_ANDROID)
408
DEFINE_JNI(OmniboxFeatureMap)
409
#endif
410
411