Path: blob/main/components/omnibox/common/omnibox_features.cc
70072 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"89#if BUILDFLAG(IS_ANDROID)10#include "base/android/feature_map.h"11#include "base/no_destructor.h"12#include "components/omnibox/common/jni_headers/OmniboxFeatureMap_jni.h"13#endif1415namespace omnibox {16namespace {17constexpr bool IS_ANDROID = !!BUILDFLAG(IS_ANDROID);18constexpr bool IS_IOS = !!BUILDFLAG(IS_IOS);1920constexpr base::FeatureState DISABLED = base::FEATURE_DISABLED_BY_DEFAULT;21constexpr base::FeatureState ENABLED = base::FEATURE_ENABLED_BY_DEFAULT;2223constexpr base::FeatureState enable_if(bool condition) {24return condition ? ENABLED : DISABLED;25}26} // namespace2728// Feature to enable showing thumbnail in front of the Omnibox clipboard image29// search suggestion.30BASE_FEATURE(kImageSearchSuggestionThumbnail, enable_if(IS_ANDROID));3132// Feature used to allow users to remove suggestions from clipboard.33BASE_FEATURE(kOmniboxRemoveSuggestionsFromClipboard, enable_if(IS_ANDROID));3435// When enabled, uses the grouping framework with prefixed suggestions (i.e.36// autocomplete_grouper_sections.h) to limit and group (but not sort) matches.37BASE_FEATURE(kGroupingFrameworkForNonZPS,38"OmniboxGroupingFrameworkForNonZPS",39enable_if(IS_ANDROID));4041// Feature used to cap max zero suggestions shown according to the param42// OmniboxMaxZeroSuggestMatches. If omitted,43// OmniboxUIExperimentMaxAutocompleteMatches will be used instead. If present,44// OmniboxMaxZeroSuggestMatches will override45// OmniboxUIExperimentMaxAutocompleteMatches when |from_omnibox_focus| is true.46BASE_FEATURE(kMaxZeroSuggestMatches, "OmniboxMaxZeroSuggestMatches", DISABLED);4748// Feature used to cap max suggestions shown according to the params49// UIMaxAutocompleteMatches and UIMaxAutocompleteMatchesByProvider.50BASE_FEATURE(kUIExperimentMaxAutocompleteMatches,51"OmniboxUIExperimentMaxAutocompleteMatches",52DISABLED);5354// Feature used to cap max suggestions to a dynamic limit based on how many URLs55// would be shown. E.g., show up to 10 suggestions if doing so would display no56// URLs; else show up to 8 suggestions if doing so would include 1 or more URLs.57BASE_FEATURE(kDynamicMaxAutocomplete,58"OmniboxDynamicMaxAutocomplete",59enable_if(!IS_IOS));6061// Enables omnibox focus as a trigger for zero-prefix suggestions on web and62// SRP, subject to the same requirements and conditions as on-clobber63// suggestions.64BASE_FEATURE(kFocusTriggersWebAndSRPZeroSuggest,65"OmniboxFocusTriggersWebAndSRPZeroSuggest",66ENABLED);6768// Enables on-clobber suggestions on iOS.69BASE_FEATURE(kOnClobberSuggestIOS, ENABLED);7071// If enabled, contextual suggestion group headers in the Omnibox popup will72// be hidden (e.g. in order to minimize visual clutter in the zero-prefix73// state).74BASE_FEATURE(kHideContextualGroupHeaders, DISABLED);7576// If enabled, suggestion group headers in the Omnibox popup will be hidden77// (e.g. in order to minimize visual clutter in the zero-prefix state).78BASE_FEATURE(kHideSuggestionGroupHeaders,79"OmniboxHideSuggestionGroupHeaders",80ENABLED);8182// Enables local history zero-prefix suggestions in every context in which the83// remote zero-prefix suggestions are enabled.84BASE_FEATURE(kLocalHistoryZeroSuggestBeyondNTP, DISABLED);8586// Enables the use of a request debouncer to throttle the number of ZPS prefetch87// requests initiated over a given period of time (to help minimize the88// performance impact of ZPS prefetching on the remote Suggest service).89BASE_FEATURE(kZeroSuggestPrefetchDebouncing, DISABLED);9091// Enables prefetching of the zero prefix suggestions for eligible users on SRP.92BASE_FEATURE(kZeroSuggestPrefetchingOnSRP, enable_if(!IS_ANDROID));9394// Enables prefetching of the zero prefix suggestions for eligible users on the95// Web (i.e. non-NTP and non-SRP URLs).96BASE_FEATURE(kZeroSuggestPrefetchingOnWeb, DISABLED);9798// Features to provide head and tail non personalized search suggestion from99// compact on device models. More specifically, feature name with suffix100// Incognito / NonIncognito will only controls behaviors under incognito /101// non-incognito mode respectively.102BASE_FEATURE(kOnDeviceHeadProviderIncognito,103"OmniboxOnDeviceHeadProviderIncognito",104ENABLED);105BASE_FEATURE(kOnDeviceHeadProviderNonIncognito,106"OmniboxOnDeviceHeadProviderNonIncognito",107ENABLED);108BASE_FEATURE(kOnDeviceTailModel,109"OmniboxOnDeviceTailModel",110enable_if(IS_ANDROID || IS_IOS));111BASE_FEATURE(kOnDeviceTailEnableEnglishModel,112"OmniboxOnDeviceTailEnableEnglishModel",113ENABLED);114115// Feature used to fetch document suggestions.116BASE_FEATURE(kDocumentProvider,117"OmniboxDocumentProvider",118enable_if(!IS_ANDROID && !IS_IOS));119120// If enabled, the authentication requirement for Drive suggestions is based on121// whether the primary account is available, i.e., the user is signed into122// Chrome, rarther than checking if any signed in account is available in the123// cookie jar.124BASE_FEATURE(kDocumentProviderPrimaryAccountRequirement,125"OmniboxDocumentProviderPrimaryAccountRequirement",126ENABLED);127128// If enabled, the primary account must be subject to enterprise policies in129// order to receive Drive suggestions.130BASE_FEATURE(kDocumentProviderEnterpriseEligibility,131"OmniboxDocumentProviderEnterpriseEligibility",132ENABLED);133134// If enabled, the enterprise eligibility requirement for Drive suggestions135// is considered met even when the account capability is unknown. Has no effect136// if kDocumentProviderEnterpriseEligibility is disabled.137BASE_FEATURE(kDocumentProviderEnterpriseEligibilityWhenUnknown,138"OmniboxDocumentProviderEnterpriseEligibilityWhenUnknown",139DISABLED);140141// If enabled, the requirement to be in an active Sync state is removed and142// Drive suggestions are available to all clients who meet the other143// requirements.144BASE_FEATURE(kDocumentProviderNoSyncRequirement,145"OmniboxDocumentProviderNoSyncRequirement",146ENABLED);147148// If enabled, the omnibox popup is not presented until the mouse button is149// released.150BASE_FEATURE(kShowPopupOnMouseReleased,151"OmniboxShowPopupOnMouseReleased",152ENABLED);153154// If enabled, makes Most Visited Tiles a Horizontal render group.155// Horizontal render group decomposes aggregate suggestions (such as old Most156// Visited Tiles), expecting individual AutocompleteMatch entry for every157// element in the carousel.158BASE_FEATURE(kMostVisitedTilesHorizontalRenderGroup,159"OmniboxMostVisitedTilesHorizontalRenderGroup",160enable_if(IS_ANDROID));161162// If enabled, expands autocompletion to possibly (depending on params) include163// suggestion titles and non-prefixes as opposed to be restricted to URL164// prefixes. Will also adjust the location bar UI and omnibox text selection to165// accommodate the autocompletions.166BASE_FEATURE(kRichAutocompletion, "OmniboxRichAutocompletion", ENABLED);167168// When enabled, the multimodal input button is shown in the Omnibox.169BASE_FEATURE(kOmniboxMultimodalInput, DISABLED);170171// Whether the AI Mode entrypoint is shown in the Omnibox as a RHS button. Only172// used on desktop platforms.173BASE_FEATURE(kAiModeOmniboxEntryPoint, ENABLED);174175// Hides the AIM entrypoint in the Omnibox when user input is in progress. Only176// used on desktop platforms.177BASE_FEATURE(kHideAimEntrypointOnUserInput,178"OmniboxHideAimEntrypointOnUserInput",179DISABLED);180181182// When enabled, removes the Search Ready Omnibox feature.183BASE_FEATURE(kRemoveSearchReadyOmnibox, DISABLED);184185// Feature used to default typed navigations to use HTTPS instead of HTTP.186// This only applies to navigations that don't have a scheme such as187// "example.com". Presently, typing "example.com" in a clean browsing profile188// loads http://example.com. When this feature is enabled, it should load189// https://example.com instead, with fallback to http://example.com if190// necessary.191// TODO(crbug.com/375004882): On non-iOS platforms, this feature is now192// superseded by HTTPS-Upgrades and will be removed in the near future.193BASE_FEATURE(kDefaultTypedNavigationsToHttps,194"OmniboxDefaultTypedNavigationsToHttps",195enable_if(IS_IOS));196197// Override the delay to create a spare renderer when the omnibox is focused198// on Android.199BASE_FEATURE(kOverrideAndroidOmniboxSpareRendererDelay, DISABLED);200201// Parameter name used to look up the delay before falling back to the HTTP URL202// while trying an HTTPS URL. The parameter is treated as a TimeDelta, so the203// unit must be included in the value as well (e.g. 3s for 3 seconds).204// - If the HTTPS load finishes successfully during this time, the timer is205// cleared and no more work is done.206// - Otherwise, a new navigation to the the fallback HTTP URL is started.207const char kDefaultTypedNavigationsToHttpsTimeoutParam[] = "timeout";208209// If enabled, logs Omnibox URL scoring signals to OmniboxEventProto for210// training the ML scoring models.211BASE_FEATURE(kLogUrlScoringSignals, DISABLED);212213// If true, enables history scoring signal annotator for populating history214// scoring signals associated with Search suggestions. These signals will be215// empty for Search suggestions otherwise.216BASE_FEATURE(kEnableHistoryScoringSignalsAnnotatorForSearches, DISABLED);217218// If enabled, (floating-point) ML model scores are mapped to (integral)219// relevance scores by means of a piecewise function. This allows for the220// integration of URL model scores with search traditional scores.221BASE_FEATURE(kMlUrlPiecewiseMappedSearchBlending, DISABLED);222223// If enabled, the ML scoring service will make use of an in-memory ML score224// cache in order to speed up the overall scoring process.225BASE_FEATURE(kMlUrlScoreCaching, enable_if(!IS_ANDROID));226227// If enabled, runs the ML scoring model to assign new relevance scores to the228// URL suggestions and reranks them.229BASE_FEATURE(kMlUrlScoring, enable_if(!IS_ANDROID));230231// If enabled, specifies how URL model scores integrate with search traditional232// scores.233BASE_FEATURE(kMlUrlSearchBlending, DISABLED);234235// If enabled, creates Omnibox autocomplete URL scoring model. Prerequisite for236// `kMlUrlScoring` & `kMlUrlSearchBlending`.237BASE_FEATURE(kUrlScoringModel, enable_if(!IS_ANDROID));238239BASE_FEATURE(kAnimateSuggestionsListAppearance, ENABLED);240241// If enabled, sends a signal when a user touches down on a search suggestion to242// |SearchPrefetchService|. |SearchPrefetchService| will then prefetch243// suggestion iff the SearchNavigationPrefetch feature and "touch_down" param244// are enabled.245BASE_FEATURE(kOmniboxTouchDownTriggerForPrefetch, enable_if(IS_ANDROID));246247// Enables keyword-based site search functionality on Android devices.248BASE_FEATURE(kOmniboxSiteSearch, DISABLED);249250// Enables additional site search providers for the Site search Starter Pack.251BASE_FEATURE(kStarterPackExpansion, enable_if(!IS_ANDROID && !IS_IOS));252253// Enables an informational IPH message at the bottom of the Omnibox directing254// users to certain starter pack engines.255BASE_FEATURE(kStarterPackIPH, DISABLED);256257// Enables an '@aimode' starter pack keyword for eligible users only.258BASE_FEATURE(kAiModeStartPack, DISABLED);259260// If enabled, |SearchProvider| will not function in Zero Suggest.261BASE_FEATURE(kAblateSearchProviderWarmup, DISABLED);262263// If enabled, hl= is reported in search requests (applicable to iOS only).264BASE_FEATURE(kReportApplicationLanguageInSearchRequest, ENABLED);265266// Enable asynchronous Omnibox/Suggest view inflation.267BASE_FEATURE(kOmniboxAsyncViewInflation, DISABLED);268269// Use FusedLocationProvider on Android to fetch device location.270BASE_FEATURE(kUseFusedLocationProvider, ENABLED);271272// Updates various NTP/Omnibox assets and descriptions for visual alignment on273// iOS.274BASE_FEATURE(kOmniboxMobileParityUpdate, ENABLED);275276// Updates various NTP/Omnibox assets and descriptions for visual alignment on277// Android and iOS, V2.278BASE_FEATURE(kOmniboxMobileParityUpdateV2, ENABLED);279280// If enabled, the X-Geo header will include permission granularity.281BASE_FEATURE(kOmniboxXGeoPermissionGranularity, ENABLED);282283// The features below allow tuning number of suggestions offered to users in284// specific contexts. These features are default enabled and are used to control285// related fieldtrial parameters.286BASE_FEATURE(kNumNtpZpsRecentSearches,287"OmniboxNumNtpZpsRecentSearches",288ENABLED);289BASE_FEATURE(kNumNtpZpsTrendingSearches,290"OmniboxNumNtpZpsTrendingSearches",291ENABLED);292BASE_FEATURE(kNumWebZpsRecentSearches,293"OmniboxNumWebZpsRecentSearches",294ENABLED);295BASE_FEATURE(kNumWebZpsRelatedSearches,296"OmniboxNumWebZpsRelatedSearches",297ENABLED);298BASE_FEATURE(kNumWebZpsMostVisitedUrls,299"OmniboxNumWebZpsMostVisitedUrls",300ENABLED);301BASE_FEATURE(kNumSrpZpsRecentSearches,302"OmniboxNumSrpZpsRecentSearches",303ENABLED);304BASE_FEATURE(kNumSrpZpsRelatedSearches,305"OmniboxNumSrpZpsRelatedSearches",306ENABLED);307308// If enabled, search aggregators defined by the309// EnterpriseSearchAggregatorSettings policy are saved into prefs and available310// in the TemplateURLService, so that they can be accessed from the Omnibox and311// the Settings page.312BASE_FEATURE(kEnableSearchAggregatorPolicy, ENABLED);313314BASE_FEATURE(kUseAgentspace25Logo, ENABLED);315316// If enabled, site search engines, defined by the `SiteSearchSettings` policy,317// can be marked as user-overridable by administrators using an318// `allow_user_override` field. This setting is stored in preferences and319// determines if the engine can be overridden on the Settings page.320BASE_FEATURE(kEnableSiteSearchAllowUserOverridePolicy, ENABLED);321322// Enables preconnecting to omnibox suggestions that are not only Search types.323BASE_FEATURE(kPreconnectNonSearchOmniboxSuggestions, ENABLED);324325// When enabled, unblocks omnibox height on small form factor devices, allowing326// users to type in multiline / longer text.327BASE_FEATURE(kMultilineEditField, "OmniboxMultilineEditField", ENABLED);328329// Controls whether the composebox330BASE_FEATURE(kComposeboxUsesChromeComposeClient, ENABLED);331332// Controls whether or not contextual composebox should display suggestions.333BASE_FEATURE(kComposeboxAttachmentsTypedState, DISABLED);334335// Enables passthrough params to be sent to the AIM eligibility service.336BASE_FEATURE(kAimUrlInterceptPassthrough, DISABLED);337338BASE_FEATURE(kOmniboxDebugLogs, base::FEATURE_DISABLED_BY_DEFAULT);339340BASE_FEATURE(kThinkingModelIconUpdate, base::FEATURE_DISABLED_BY_DEFAULT);341342#if BUILDFLAG(IS_ANDROID)343// Accelerates time from cold start to focused Omnibox on low-end devices,344// prioritizing Omnibox focus and background initialization.345BASE_FEATURE(kJumpStartOmnibox, DISABLED);346347// Prevents intermediate AutocompleteResult updates from being sent to Java on348// low-end devices. This aims at eliminating time spent on constructing,349// measuring, and laying out views that are about to be discarded, and reducing350// the volume of JNI jumps.351BASE_FEATURE(kSuppressIntermediateACUpdatesOnLowEndDevices, DISABLED);352353// (Android only) Show tab groups via the search feature in the hub.354BASE_FEATURE(kAndroidHubSearchTabGroups, ENABLED);355356// When enabled, delay focusTab to prioritize navigation357// (https://crbug.com/374852568).358BASE_FEATURE(kPostDelayedTaskFocusTab, ENABLED);359360// Controls various Omnibox Diagnostics features.361BASE_FEATURE(kDiagnostics, "OmniboxDiagnostics", DISABLED);362363// When enabled, offer a desktop-like omnibox UI enhancement on large form364// factors.365BASE_FEATURE(kOmniboxImprovementForLFF, DISABLED);366367// If enabled, disables ligatures in the URL bar on Android.368BASE_FEATURE(kUrlBarWithoutLigatures, ENABLED);369370namespace android {371static int64_t JNI_OmniboxFeatureMap_GetNativeMap(JNIEnv* env) {372static const base::Feature* const kFeaturesExposedToJava[] = {373&kDiagnostics,374&kAnimateSuggestionsListAppearance,375&kOmniboxTouchDownTriggerForPrefetch,376&kOmniboxAsyncViewInflation,377&kRichAutocompletion,378&kUrlBarWithoutLigatures,379&kUseFusedLocationProvider,380&kJumpStartOmnibox,381&kAndroidHubSearchTabGroups,382&kPostDelayedTaskFocusTab,383&kOmniboxMobileParityUpdateV2,384&kOmniboxXGeoPermissionGranularity,385&kOmniboxSiteSearch,386&kOmniboxMultimodalInput,387&kMultilineEditField,388&kOmniboxImprovementForLFF,389&kRemoveSearchReadyOmnibox};390static base::NoDestructor<base::android::FeatureMap> kFeatureMap(391kFeaturesExposedToJava);392return reinterpret_cast<int64_t>(kFeatureMap.get());393}394} // namespace android395#endif // BUILDFLAG(IS_ANDROID)396// Note: no new flags beyond this point.397398namespace flag_descriptions {399const char kOmniboxDebugLogsName[] = "Omnibox debug logs";400const char kOmniboxDebugLogsDescription[] =401"Enables logging that can be read from an internals page.";402} // namespace flag_descriptions403404} // namespace omnibox405406#if BUILDFLAG(IS_ANDROID)407DEFINE_JNI(OmniboxFeatureMap)408#endif409410411