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