Path: blob/main/components/omnibox/common/omnibox_features.cc
41933 views
// Copyright 2019 The Chromium Authors1// Use of this source code is governed by a BSD-style license that can be2// found in the LICENSE file.34#include "components/omnibox/common/omnibox_features.h"56#include "base/feature_list.h"7#include "build/build_config.h"8#include "ui/base/ui_base_features.h"910#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#endif1516namespace omnibox {17namespace {18constexpr bool IS_ANDROID = !!BUILDFLAG(IS_ANDROID);19constexpr bool IS_IOS = !!BUILDFLAG(IS_IOS);2021constexpr base::FeatureState DISABLED = base::FEATURE_DISABLED_BY_DEFAULT;22constexpr base::FeatureState ENABLED = base::FEATURE_ENABLED_BY_DEFAULT;2324constexpr base::FeatureState enable_if(bool condition) {25return condition ? ENABLED : DISABLED;26}27} // namespace2829// Feature to enable showing thumbnail in front of the Omnibox clipboard image30// search suggestion.31BASE_FEATURE(kImageSearchSuggestionThumbnail,32"ImageSearchSuggestionThumbnail",33enable_if(IS_ANDROID));3435// Feature used to allow users to remove suggestions from clipboard.36BASE_FEATURE(kOmniboxRemoveSuggestionsFromClipboard,37"OmniboxRemoveSuggestionsFromClipboard",38enable_if(IS_ANDROID));3940// When enabled, uses the grouping framework with prefixed suggestions (i.e.41// autocomplete_grouper_sections.h) to limit and group (but not sort) matches.42BASE_FEATURE(kGroupingFrameworkForNonZPS,43"OmniboxGroupingFrameworkForNonZPS",44enable_if(IS_ANDROID));4546// Feature used to cap max zero suggestions shown according to the param47// OmniboxMaxZeroSuggestMatches. If omitted,48// OmniboxUIExperimentMaxAutocompleteMatches will be used instead. If present,49// OmniboxMaxZeroSuggestMatches will override50// OmniboxUIExperimentMaxAutocompleteMatches when |from_omnibox_focus| is true.51BASE_FEATURE(kMaxZeroSuggestMatches, "OmniboxMaxZeroSuggestMatches", DISABLED);5253// Feature used to cap max suggestions shown according to the params54// UIMaxAutocompleteMatches and UIMaxAutocompleteMatchesByProvider.55BASE_FEATURE(kUIExperimentMaxAutocompleteMatches,56"OmniboxUIExperimentMaxAutocompleteMatches",57DISABLED);5859// Feature used to cap the number of URL-type matches shown within the60// Omnibox. If enabled, the number of URL-type matches is limited (unless61// there are no more non-URL matches available.) If enabled, there is a62// companion parameter - OmniboxMaxURLMatches - which specifies the maximum63// desired number of URL-type matches.64BASE_FEATURE(kOmniboxMaxURLMatches, "OmniboxMaxURLMatches", ENABLED);6566// Feature used to cap max suggestions to a dynamic limit based on how many URLs67// would be shown. E.g., show up to 10 suggestions if doing so would display no68// URLs; else show up to 8 suggestions if doing so would include 1 or more URLs.69BASE_FEATURE(kDynamicMaxAutocomplete,70"OmniboxDynamicMaxAutocomplete",71enable_if(!IS_IOS));7273// If enabled, takes the search intent query params into account for triggering74// switch to tab actions on matches.75BASE_FEATURE(kDisambiguateTabMatchingForEntitySuggestions,76"DisambiguateTabMatchingForEntitySuggestions",77ENABLED);7879// Enables omnibox focus as a trigger for zero-prefix suggestions on web and80// SRP, subject to the same requirements and conditions as on-clobber81// suggestions.82BASE_FEATURE(kFocusTriggersWebAndSRPZeroSuggest,83"OmniboxFocusTriggersWebAndSRPZeroSuggest",84ENABLED);8586// If enabled, suggestion group headers in the Omnibox popup will be hidden87// (e.g. in order to minimize visual clutter in the zero-prefix state).88BASE_FEATURE(kHideSuggestionGroupHeaders,89"OmniboxHideSuggestionGroupHeaders",90ENABLED);9192// Enables local history zero-prefix suggestions in every context in which the93// remote zero-prefix suggestions are enabled.94BASE_FEATURE(kLocalHistoryZeroSuggestBeyondNTP,95"LocalHistoryZeroSuggestBeyondNTP",96DISABLED);9798// If enabled, zero prefix suggestions will be stored using an in-memory caching99// service, instead of using the existing prefs-based cache.100BASE_FEATURE(kZeroSuggestInMemoryCaching,101"ZeroSuggestInMemoryCaching",102DISABLED);103104// Enables the use of a request debouncer to throttle the number of ZPS prefetch105// requests initiated over a given period of time (to help minimize the106// performance impact of ZPS prefetching on the remote Suggest service).107BASE_FEATURE(kZeroSuggestPrefetchDebouncing,108"ZeroSuggestPrefetchDebouncing",109DISABLED);110111// Enables prefetching of the zero prefix suggestions for eligible users on NTP.112BASE_FEATURE(kZeroSuggestPrefetching, "ZeroSuggestPrefetching", ENABLED);113114// Enables prefetching of the zero prefix suggestions for eligible users on SRP.115BASE_FEATURE(kZeroSuggestPrefetchingOnSRP,116"ZeroSuggestPrefetchingOnSRP",117enable_if(!IS_ANDROID));118119// Enables prefetching of the zero prefix suggestions for eligible users on the120// Web (i.e. non-NTP and non-SRP URLs).121BASE_FEATURE(kZeroSuggestPrefetchingOnWeb,122"ZeroSuggestPrefetchingOnWeb",123DISABLED);124125// Features to provide head and tail non personalized search suggestion from126// compact on device models. More specifically, feature name with suffix127// Incognito / NonIncognito will only controls behaviors under incognito /128// non-incognito mode respectively.129BASE_FEATURE(kOnDeviceHeadProviderIncognito,130"OmniboxOnDeviceHeadProviderIncognito",131ENABLED);132BASE_FEATURE(kOnDeviceHeadProviderNonIncognito,133"OmniboxOnDeviceHeadProviderNonIncognito",134ENABLED);135BASE_FEATURE(kOnDeviceTailModel, "OmniboxOnDeviceTailModel", DISABLED);136BASE_FEATURE(kOnDeviceTailEnableEnglishModel,137"OmniboxOnDeviceTailEnableEnglishModel",138ENABLED);139140// Feature used to fetch document suggestions.141BASE_FEATURE(kDocumentProvider,142"OmniboxDocumentProvider",143enable_if(!IS_ANDROID && !IS_IOS));144145// If enabled, the authentication requirement for Drive suggestions is based on146// whether the primary account is available, i.e., the user is signed into147// Chrome, rarther than checking if any signed in account is available in the148// cookie jar.149BASE_FEATURE(kDocumentProviderPrimaryAccountRequirement,150"OmniboxDocumentProviderPrimaryAccountRequirement",151ENABLED);152153// If enabled, the primary account must be subject to enterprise policies in154// order to receive Drive suggestions.155BASE_FEATURE(kDocumentProviderEnterpriseEligibility,156"OmniboxDocumentProviderEnterpriseEligibility",157ENABLED);158159// If enabled, the enterprise eligibility requirement for Drive suggestions160// is considered met even when the account capability is unknown. Has no effect161// if kDocumentProviderEnterpriseEligibility is disabled.162BASE_FEATURE(kDocumentProviderEnterpriseEligibilityWhenUnknown,163"OmniboxDocumentProviderEnterpriseEligibilityWhenUnknown",164DISABLED);165166// If enabled, the requirement to be in an active Sync state is removed and167// Drive suggestions are available to all clients who meet the other168// requirements.169BASE_FEATURE(kDocumentProviderNoSyncRequirement,170"OmniboxDocumentProviderNoSyncRequirement",171ENABLED);172173// If enabled, the omnibox popup is not presented until the mouse button is174// released.175BASE_FEATURE(kShowPopupOnMouseReleased,176"OmniboxShowPopupOnMouseReleased",177ENABLED);178179// If enabled, makes Most Visited Tiles a Horizontal render group.180// Horizontal render group decomposes aggregate suggestions (such as old Most181// Visited Tiles), expecting individual AutocompleteMatch entry for every182// element in the carousel.183BASE_FEATURE(kMostVisitedTilesHorizontalRenderGroup,184"OmniboxMostVisitedTilesHorizontalRenderGroup",185enable_if(IS_ANDROID));186187// If enabled, expands autocompletion to possibly (depending on params) include188// suggestion titles and non-prefixes as opposed to be restricted to URL189// prefixes. Will also adjust the location bar UI and omnibox text selection to190// accommodate the autocompletions.191BASE_FEATURE(kRichAutocompletion, "OmniboxRichAutocompletion", ENABLED);192193// If enabled, shows the omnibox suggestions popup in WebUI.194BASE_FEATURE(kWebUIOmniboxPopup, "WebUIOmniboxPopup", DISABLED);195196// When enabled, use Assistant for omnibox voice query recognition instead of197// Android's built-in voice recognition service. Only works on Android.198BASE_FEATURE(kOmniboxAssistantVoiceSearch,199"OmniboxAssistantVoiceSearch",200DISABLED);201202// When enabled, the multimodal input button is shown in the Omnibox.203BASE_FEATURE(kOmniboxMultimodalInput, "OmniboxMultimodalInput", DISABLED);204205// Whether the AI Mode entrypoint is shown in the Omnibox as a RHS button.206BASE_FEATURE(kAiModeOmniboxEntryPoint, "AiModeOmniboxEntryPoint", DISABLED);207208// Feature used to default typed navigations to use HTTPS instead of HTTP.209// This only applies to navigations that don't have a scheme such as210// "example.com". Presently, typing "example.com" in a clean browsing profile211// loads http://example.com. When this feature is enabled, it should load212// https://example.com instead, with fallback to http://example.com if213// necessary.214// TODO(crbug.com/375004882): On non-iOS platforms, this feature is now215// superseded by HTTPS-Upgrades and will be removed in the near future.216BASE_FEATURE(kDefaultTypedNavigationsToHttps,217"OmniboxDefaultTypedNavigationsToHttps",218enable_if(IS_IOS));219220// Override the delay to create a spare renderer when the omnibox is focused221// on Android.222BASE_FEATURE(kOverrideAndroidOmniboxSpareRendererDelay,223"OverrideAndroidOmniboxSpareRendererDelay",224DISABLED);225226// Parameter name used to look up the delay before falling back to the HTTP URL227// while trying an HTTPS URL. The parameter is treated as a TimeDelta, so the228// unit must be included in the value as well (e.g. 3s for 3 seconds).229// - If the HTTPS load finishes successfully during this time, the timer is230// cleared and no more work is done.231// - Otherwise, a new navigation to the the fallback HTTP URL is started.232const char kDefaultTypedNavigationsToHttpsTimeoutParam[] = "timeout";233234// If enabled, logs Omnibox URL scoring signals to OmniboxEventProto for235// training the ML scoring models.236BASE_FEATURE(kLogUrlScoringSignals, "LogUrlScoringSignals", DISABLED);237238// If true, enables history scoring signal annotator for populating history239// scoring signals associated with Search suggestions. These signals will be240// empty for Search suggestions otherwise.241BASE_FEATURE(kEnableHistoryScoringSignalsAnnotatorForSearches,242"EnableHistoryScoringSignalsAnnotatorForSearches",243DISABLED);244245// If enabled, (floating-point) ML model scores are mapped to (integral)246// relevance scores by means of a piecewise function. This allows for the247// integration of URL model scores with search traditional scores.248BASE_FEATURE(kMlUrlPiecewiseMappedSearchBlending,249"MlUrlPiecewiseMappedSearchBlending",250DISABLED);251252// If enabled, the ML scoring service will make use of an in-memory ML score253// cache in order to speed up the overall scoring process.254BASE_FEATURE(kMlUrlScoreCaching, "MlUrlScoreCaching", enable_if(!IS_ANDROID));255256// If enabled, runs the ML scoring model to assign new relevance scores to the257// URL suggestions and reranks them.258BASE_FEATURE(kMlUrlScoring, "MlUrlScoring", enable_if(!IS_ANDROID));259260// If enabled, specifies how URL model scores integrate with search traditional261// scores.262BASE_FEATURE(kMlUrlSearchBlending, "MlUrlSearchBlending", DISABLED);263264// If enabled, creates Omnibox autocomplete URL scoring model. Prerequisite for265// `kMlUrlScoring` & `kMlUrlSearchBlending`.266BASE_FEATURE(kUrlScoringModel, "UrlScoringModel", enable_if(!IS_ANDROID));267268BASE_FEATURE(kAnimateSuggestionsListAppearance,269"AnimateSuggestionsListAppearance",270ENABLED);271272BASE_FEATURE(kOmniboxAnswerActions, "OmniboxAnswerActions", DISABLED);273274// If enabled, treats categorical suggestions just like the entity suggestions275// by reusing the `ACMatchType::SEARCH_SUGGEST_ENTITY` and reports the original276// `omnibox::TYPE_CATEGORICAL_QUERY` to the server.277BASE_FEATURE(kCategoricalSuggestions, "CategoricalSuggestions", ENABLED);278279// If enabled, sends a signal when a user touches down on a search suggestion to280// |SearchPrefetchService|. |SearchPrefetchService| will then prefetch281// suggestion iff the SearchNavigationPrefetch feature and "touch_down" param282// are enabled.283BASE_FEATURE(kOmniboxTouchDownTriggerForPrefetch,284"OmniboxTouchDownTriggerForPrefetch",285enable_if(IS_ANDROID));286287// Enables keyword-based site search functionality on Android devices.288BASE_FEATURE(kOmniboxSiteSearch, "OmniboxSiteSearch", DISABLED);289290// Enables additional site search providers for the Site search Starter Pack.291BASE_FEATURE(kStarterPackExpansion,292"StarterPackExpansion",293enable_if(!IS_ANDROID && !IS_IOS));294295// Enables an informational IPH message at the bottom of the Omnibox directing296// users to certain starter pack engines.297BASE_FEATURE(kStarterPackIPH, "StarterPackIPH", DISABLED);298299// If enabled, |SearchProvider| will not function in Zero Suggest.300BASE_FEATURE(kAblateSearchProviderWarmup,301"AblateSearchProviderWarmup",302DISABLED);303304// If enabled, hl= is reported in search requests (applicable to iOS only).305BASE_FEATURE(kReportApplicationLanguageInSearchRequest,306"ReportApplicationLanguageInSearchRequest",307ENABLED);308309// Enable asynchronous Omnibox/Suggest view inflation.310BASE_FEATURE(kOmniboxAsyncViewInflation, "OmniboxAsyncViewInflation", DISABLED);311312// Use FusedLocationProvider on Android to fetch device location.313BASE_FEATURE(kUseFusedLocationProvider, "UseFusedLocationProvider", ENABLED);314315// Enables storing successful query/match in the shortcut database On Android.316BASE_FEATURE(kOmniboxShortcutsAndroid, "OmniboxShortcutsAndroid", ENABLED);317318// Updates various NTP/Omnibox assets and descriptions for visual alignment on319// iOS.320BASE_FEATURE(kOmniboxMobileParityUpdate, "OmniboxMobileParityUpdate", ENABLED);321322// Updates various NTP/Omnibox assets and descriptions for visual alignment on323// Android and iOS, V2.324BASE_FEATURE(kOmniboxMobileParityUpdateV2,325"OmniboxMobileParityUpdateV2",326DISABLED);327328#if BUILDFLAG(IS_IOS)329// Updates the search engine logo on NTP. iOS only.330BASE_FEATURE(kOmniboxMobileParityUpdateV3,331"OmniboxMobileParityUpdateV3",332DISABLED);333#endif // BUILDFLAG(IS_IOS)334335// The features below allow tuning number of suggestions offered to users in336// specific contexts. These features are default enabled and are used to control337// related fieldtrial parameters.338BASE_FEATURE(kNumNtpZpsRecentSearches,339"OmniboxNumNtpZpsRecentSearches",340ENABLED);341BASE_FEATURE(kNumNtpZpsTrendingSearches,342"OmniboxNumNtpZpsTrendingSearches",343ENABLED);344BASE_FEATURE(kNumWebZpsRecentSearches,345"OmniboxNumWebZpsRecentSearches",346ENABLED);347BASE_FEATURE(kNumWebZpsRelatedSearches,348"OmniboxNumWebZpsRelatedSearches",349ENABLED);350BASE_FEATURE(kNumWebZpsMostVisitedUrls,351"OmniboxNumWebZpsMostVisitedUrls",352ENABLED);353BASE_FEATURE(kNumSrpZpsRecentSearches,354"OmniboxNumSrpZpsRecentSearches",355ENABLED);356BASE_FEATURE(kNumSrpZpsRelatedSearches,357"OmniboxNumSrpZpsRelatedSearches",358ENABLED);359360// If enabled, search aggregators defined by the361// EnterpriseSearchAggregatorSettings policy are saved into prefs and available362// in the TemplateURLService, so that they can be accessed from the Omnibox and363// the Settings page.364BASE_FEATURE(kEnableSearchAggregatorPolicy,365"EnableSearchAggregatorPolicy",366ENABLED);367368// If enabled, site search engines, defined by the `SiteSearchSettings` policy,369// can be marked as user-overridable by administrators using an370// `allow_user_override` field. This setting is stored in preferences and371// determines if the engine can be overridden on the Settings page.372BASE_FEATURE(kEnableSiteSearchAllowUserOverridePolicy,373"EnableSiteSearchAllowUserOverridePolicy",374ENABLED);375376// Enables preconnecting to omnibox suggestions that are not only Search types.377BASE_FEATURE(kPreconnectNonSearchOmniboxSuggestions,378"PreconnectNonSearchOmniboxSuggestions",379DISABLED);380381// Enables restricting omnibox focus restoration to only situations that involve382// "invisible focus".383BASE_FEATURE(kOmniboxRestoreInvisibleFocusOnly,384"OmniboxRestoreInvisibleFocusOnly",385DISABLED);386387// Enabls adding an aim shortcut in the typed state.388BASE_FEATURE(kOmniboxAimShortcutTypedState,389"OmniboxAimShortcutTypedState",390DISABLED);391392// When enabled, unblocks omnibox height on small form factor devices, allowing393// users to type in multiline / longer text.394BASE_FEATURE(kMultilineEditField, "OmniboxMultilineEditField", DISABLED);395396// Hides the AIM entrypoint in the Omnibox when user input is in progress.397BASE_FEATURE(kHideAimEntrypointOnUserInput,398"OmniboxHideAimEntrypointOnUserInput",399DISABLED);400401#if BUILDFLAG(IS_ANDROID)402// Accelerates time from cold start to focused Omnibox on low-end devices,403// prioritizing Omnibox focus and background initialization.404BASE_FEATURE(kJumpStartOmnibox, "JumpStartOmnibox", DISABLED);405406// Prevents intermediate AutocompleteResult updates from being sent to Java on407// low-end devices. This aims at eliminating time spent on constructing,408// measuring, and laying out views that are about to be discarded, and reducing409// the volume of JNI jumps.410BASE_FEATURE(kSuppressIntermediateACUpdatesOnLowEndDevices,411"SuppressIntermediateACUpdatesOnLowEndDevices",412DISABLED);413414// (Android only) Show tab groups via the search feature in the hub.415BASE_FEATURE(kAndroidHubSearchTabGroups, "AndroidHubSearchTabGroups", DISABLED);416417// When enabled, delay focusTab to prioritize navigation418// (https://crbug.com/374852568).419BASE_FEATURE(kPostDelayedTaskFocusTab, "PostDelayedTaskFocusTab", ENABLED);420421// Controls various Omnibox Diagnostics features.422BASE_FEATURE(kDiagnostics, "OmniboxDiagnostics", DISABLED);423424namespace android {425static jlong JNI_OmniboxFeatureMap_GetNativeMap(JNIEnv* env) {426static const base::Feature* const kFeaturesExposedToJava[] = {427&kDiagnostics,428&kOmniboxAnswerActions,429&kAnimateSuggestionsListAppearance,430&kOmniboxTouchDownTriggerForPrefetch,431&kOmniboxAsyncViewInflation,432&kRichAutocompletion,433&kUseFusedLocationProvider,434&kJumpStartOmnibox,435&kAndroidHubSearchTabGroups,436&kPostDelayedTaskFocusTab,437&kOmniboxMobileParityUpdateV2,438&kOmniboxSiteSearch,439&kOmniboxAimShortcutTypedState,440&kOmniboxMultimodalInput,441&kMultilineEditField};442static base::NoDestructor<base::android::FeatureMap> kFeatureMap(443kFeaturesExposedToJava);444return reinterpret_cast<jlong>(kFeatureMap.get());445}446} // namespace android447#endif // BUILDFLAG(IS_ANDROID)448// Note: no new flags beyond this point.449} // namespace omnibox450451452