// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/omnibox/common/omnibox_features.h"

#include "base/feature_list.h"
#include "build/android_buildflags.h"
#include "build/build_config.h"

#if BUILDFLAG(IS_ANDROID)
#include "base/android/feature_map.h"
#include "base/no_destructor.h"
#include "components/omnibox/common/jni_headers/OmniboxFeatureMap_jni.h"
#endif

namespace omnibox {
namespace {
constexpr bool IS_ANDROID = !!BUILDFLAG(IS_ANDROID);
constexpr bool IS_IOS = !!BUILDFLAG(IS_IOS);

constexpr base::FeatureState DISABLED = base::FEATURE_DISABLED_BY_DEFAULT;
constexpr base::FeatureState ENABLED = base::FEATURE_ENABLED_BY_DEFAULT;

constexpr base::FeatureState enable_if(bool condition) {
  return condition ? ENABLED : DISABLED;
}
}  // namespace

// Feature to enable showing thumbnail in front of the Omnibox clipboard image
// search suggestion.
BASE_FEATURE(kImageSearchSuggestionThumbnail, enable_if(IS_ANDROID));

// Feature used to allow users to remove suggestions from clipboard.
BASE_FEATURE(kOmniboxRemoveSuggestionsFromClipboard, enable_if(IS_ANDROID));

// When enabled, uses the grouping framework with prefixed suggestions (i.e.
// autocomplete_grouper_sections.h) to limit and group (but not sort) matches.
BASE_FEATURE(kGroupingFrameworkForNonZPS,
             "OmniboxGroupingFrameworkForNonZPS",
             enable_if(IS_ANDROID));

// Feature used to cap max suggestions shown according to the params
// UIMaxAutocompleteMatches and UIMaxAutocompleteMatchesByProvider.
BASE_FEATURE(kUIExperimentMaxAutocompleteMatches,
             "OmniboxUIExperimentMaxAutocompleteMatches",
             DISABLED);

// Feature used to cap max suggestions to a dynamic limit based on how many URLs
// would be shown. E.g., show up to 10 suggestions if doing so would display no
// URLs; else show up to 8 suggestions if doing so would include 1 or more URLs.
BASE_FEATURE(kDynamicMaxAutocomplete,
             "OmniboxDynamicMaxAutocomplete",
             enable_if(!IS_IOS));

// Enables omnibox focus as a trigger for zero-prefix suggestions on web and
// SRP, subject to the same requirements and conditions as on-clobber
// suggestions.
BASE_FEATURE(kFocusTriggersWebAndSRPZeroSuggest,
             "OmniboxFocusTriggersWebAndSRPZeroSuggest",
             ENABLED);

// Enables on-clobber suggestions on iOS.
BASE_FEATURE(kOnClobberSuggestIOS, ENABLED);

// If enabled, contextual suggestion group headers in the Omnibox popup will
// be hidden (e.g. in order to minimize visual clutter in the zero-prefix
// state).
BASE_FEATURE(kHideContextualGroupHeaders, DISABLED);

// If enabled, suggestion group headers in the Omnibox popup will be hidden
// (e.g. in order to minimize visual clutter in the zero-prefix state).
BASE_FEATURE(kHideSuggestionGroupHeaders,
             "OmniboxHideSuggestionGroupHeaders",
             ENABLED);

// Enables local history zero-prefix suggestions in every context in which the
// remote zero-prefix suggestions are enabled.
BASE_FEATURE(kLocalHistoryZeroSuggestBeyondNTP, DISABLED);

// Enables showing tabs from other devices in zero-prefix suggest.
BASE_FEATURE(kOmniboxCrossDeviceTabZeroSuggest, DISABLED);
BASE_FEATURE_PARAM(int,
                   kOmniboxCrossDeviceTabZeroSuggestMaxAgeMinutes,
                   &kOmniboxCrossDeviceTabZeroSuggest,
                   5);
BASE_FEATURE_PARAM(
    int,
    kOmniboxCrossDeviceTabZeroSuggestDelayedContinuationMaxAgeMinutes,
    &kOmniboxCrossDeviceTabZeroSuggest,
    720);
BASE_FEATURE_PARAM(
    int,
    kOmniboxCrossDeviceTabZeroSuggestMaxDelayedContinuationUptimeMinutes,
    &kOmniboxCrossDeviceTabZeroSuggest,
    5);

// Enables the use of a request debouncer to throttle the number of ZPS prefetch
// requests initiated over a given period of time (to help minimize the
// performance impact of ZPS prefetching on the remote Suggest service).
BASE_FEATURE(kZeroSuggestPrefetchDebouncing, DISABLED);

// Enables prefetching of the zero prefix suggestions for composebox contexts.
BASE_FEATURE(kZeroSuggestPrefetchingForComposebox, DISABLED);

// Enables prefetching of the zero prefix suggestions for eligible users on SRP.
BASE_FEATURE(kZeroSuggestPrefetchingOnSRP, enable_if(!IS_ANDROID));

// Enables prefetching of the zero prefix suggestions for eligible users on the
// Web (i.e. non-NTP and non-SRP URLs).
BASE_FEATURE(kZeroSuggestPrefetchingOnWeb, DISABLED);

// Features to provide head and tail non personalized search suggestion from
// compact on device models. More specifically, feature name with suffix
// Incognito / NonIncognito  will only controls behaviors under incognito /
// non-incognito mode respectively.
BASE_FEATURE(kOnDeviceHeadProviderIncognito,
             "OmniboxOnDeviceHeadProviderIncognito",
             ENABLED);
BASE_FEATURE(kOnDeviceHeadProviderNonIncognito,
             "OmniboxOnDeviceHeadProviderNonIncognito",
             ENABLED);
BASE_FEATURE(kOnDeviceTailModel,
             "OmniboxOnDeviceTailModel",
             enable_if(IS_ANDROID || IS_IOS));
BASE_FEATURE(kOnDeviceTailEnableEnglishModel,
             "OmniboxOnDeviceTailEnableEnglishModel",
             ENABLED);

// Feature used to fetch document suggestions.
BASE_FEATURE(kDocumentProvider, "OmniboxDocumentProvider", enable_if(!IS_IOS));

// If enabled, the authentication requirement for Drive suggestions is based on
// whether the primary account is available, i.e., the user is signed into
// Chrome, rarther than checking if any signed in account is available in the
// cookie jar.
BASE_FEATURE(kDocumentProviderPrimaryAccountRequirement,
             "OmniboxDocumentProviderPrimaryAccountRequirement",
             ENABLED);

// If enabled, the primary account must be subject to enterprise policies in
// order to receive Drive suggestions.
BASE_FEATURE(kDocumentProviderEnterpriseEligibility,
             "OmniboxDocumentProviderEnterpriseEligibility",
             ENABLED);

// If enabled, the enterprise eligibility requirement for Drive suggestions
// is considered met even when the account capability is unknown. Has no effect
// if kDocumentProviderEnterpriseEligibility is disabled.
BASE_FEATURE(kDocumentProviderEnterpriseEligibilityWhenUnknown,
             "OmniboxDocumentProviderEnterpriseEligibilityWhenUnknown",
             DISABLED);

// If enabled, the omnibox popup is not presented until the mouse button is
// released.
BASE_FEATURE(kShowPopupOnMouseReleased,
             "OmniboxShowPopupOnMouseReleased",
             ENABLED);

// If enabled, makes Most Visited Tiles a Horizontal render group.
// Horizontal render group decomposes aggregate suggestions (such as old Most
// Visited Tiles), expecting individual AutocompleteMatch entry for every
// element in the carousel.
BASE_FEATURE(kMostVisitedTilesHorizontalRenderGroup,
             "OmniboxMostVisitedTilesHorizontalRenderGroup",
             enable_if(IS_ANDROID));

// If enabled, expands autocompletion to possibly (depending on params) include
// suggestion titles and non-prefixes as opposed to be restricted to URL
// prefixes. Will also adjust the location bar UI and omnibox text selection to
// accommodate the autocompletions.
BASE_FEATURE(kRichAutocompletion, "OmniboxRichAutocompletion", ENABLED);

// Enables the AIM eligibility diagnostic component extension.
BASE_FEATURE(kAimEligibilityComponentExtension, DISABLED);

// Whether the aim button should dynamically change to portray the submission
// type.
BASE_FEATURE(kDynamicAimSubmit, DISABLED);

const base::FeatureParam<bool> kShowRhsAimHint{&kDynamicAimSubmit,
                                               "Omnibox_ShowRhsAimHint", false};

// Hides the AIM entrypoint in the Omnibox when user input is in progress. Only
// used on desktop platforms.
BASE_FEATURE(kHideAimEntrypointOnUserInput,
             "OmniboxHideAimEntrypointOnUserInput",
             DISABLED);

// Hides the AIM entrypoint in the Omnibox when the default suggestion is a URL.
// Only used on desktop platforms.
BASE_FEATURE(kHideAimEntrypointForUrlSuggestions, ENABLED);

// When enabled, the multimodal input button is shown in the Omnibox.
BASE_FEATURE(kOmniboxMultimodalInput, ENABLED);

// An additional gate to the behavior of OmniboxMultimodalInput on desktop.
BASE_FEATURE(kAndroidDesktopAimGate, ENABLED);

// Enables the AIM entrypoint for third party search engines.
BASE_FEATURE(kAim3pEntrypoint, ENABLED);
const base::FeatureParam<bool> kAim3pEntrypointDebug{
    &kAim3pEntrypoint, "Aim3pEntrypointDebug", false};

// When enabled, AI mode will remove verbatim suggestions from the suggestions
// list.
BASE_FEATURE(kAIMSuppressVerbatimMatch, ENABLED);

// When enabled, the AIM WebUI popup will defer showing until the WebUI has
// painted a clean frame, avoiding the issue of the popup being shown with a
// stale frame.
BASE_FEATURE(kOmniboxAimDeferShowUntilVisualStateReady, ENABLED);
// When enabled, the Omnibox WebUI popup will defer showing until the WebUI has
// painted a clean frame, avoiding the issue of the popup being shown with a
// stale frame.
BASE_FEATURE(kOmniboxWebUIDeferShowUntilVisualStateReady, DISABLED);
// When enabled, the Omnibox Full WebUI popup will defer showing until the
// WebUI has painted a clean frame, avoiding the issue of the popup being shown
// with a stale frame.
// TODO(b/549125538): Figure out why timeout is consistently being hit.
BASE_FEATURE(kOmniboxFullWebUIDeferShowUntilVisualStateReady, DISABLED);
// When enabled, the Omnibox WebUI popup will debounce auto-resize events.
BASE_FEATURE(kOmniboxWebUIDebounceResize, ENABLED);
// When enabled, the AIM WebUI popup will debounce auto-resize events.
BASE_FEATURE(kOmniboxAimDebounceResize, DISABLED);
// When enabled, the Omnibox Full WebUI popup will debounce auto-resize events.
BASE_FEATURE(kOmniboxFullWebUIDebounceResize, ENABLED);
// If enabled, stabilizes the popup showing behavior on startup by forcing
// layout with a 1px height and hiding it initially to avoid visual artifacts.
BASE_FEATURE(kOmniboxWebUIPopupStabilizeStartupShow, ENABLED);
// When enabled, the AIM WebUI popup will detach its web contents when hidden.
BASE_FEATURE(kOmniboxAimDetachWebContentsOnHide, ENABLED);
// When enabled, the Omnibox WebUI popup will detach its web contents when
// hidden.
BASE_FEATURE(kOmniboxWebUIDetachWebContentsOnHide, ENABLED);
// When enabled, the Omnibox Full WebUI popup will detach its web contents
// when hidden.
BASE_FEATURE(kOmniboxFullWebUIDetachWebContentsOnHide, ENABLED);

// When enabled, the Omnibox WebUI popup will mark its web contents as hidden
// when hidden, to unlock frames from compositor cache.
BASE_FEATURE(kOmniboxWebUIPopupMarkAsHidden, ENABLED);

// When enabled, the WebUI searchbox will bypass OmniboxController and
// OmniboxEditModel.
BASE_FEATURE(kWebUISearchboxWithoutModelController, DISABLED);

// If enabled, debounces soft keyboard show/hide transitions in the Omnibox.
BASE_FEATURE(kOmniboxDebounceKeyboardVisibility, DISABLED);

// Feature used to default typed navigations to use HTTPS instead of HTTP.
// This only applies to navigations that don't have a scheme such as
// "example.com". Presently, typing "example.com" in a clean browsing profile
// loads http://example.com. When this feature is enabled, it should load
// https://example.com instead, with fallback to http://example.com if
// necessary.
// TODO(crbug.com/375004882): On non-iOS platforms, this feature is now
// superseded by HTTPS-Upgrades and will be removed in the near future.
BASE_FEATURE(kDefaultTypedNavigationsToHttps,
             "OmniboxDefaultTypedNavigationsToHttps",
             enable_if(IS_IOS));

// Override the delay to create a spare renderer when the omnibox is focused
// on Android.
BASE_FEATURE(kOverrideAndroidOmniboxSpareRendererDelay, DISABLED);

// Parameter name used to look up the delay before falling back to the HTTP URL
// while trying an HTTPS URL. The parameter is treated as a TimeDelta, so the
// unit must be included in the value as well (e.g. 3s for 3 seconds).
// - If the HTTPS load finishes successfully during this time, the timer is
//   cleared and no more work is done.
// - Otherwise, a new navigation to the the fallback HTTP URL is started.
const char kDefaultTypedNavigationsToHttpsTimeoutParam[] = "timeout";

// If enabled, logs Omnibox URL scoring signals to OmniboxEventProto for
// training the ML scoring models.
BASE_FEATURE(kLogUrlScoringSignals, DISABLED);

// If true, enables history scoring signal annotator for populating history
// scoring signals associated with Search suggestions. These signals will be
// empty for Search suggestions otherwise.
BASE_FEATURE(kEnableHistoryScoringSignalsAnnotatorForSearches, DISABLED);

// If enabled, (floating-point) ML model scores are mapped to (integral)
// relevance scores by means of a piecewise function. This allows for the
// integration of URL model scores with search traditional scores.
BASE_FEATURE(kMlUrlPiecewiseMappedSearchBlending, DISABLED);

// If enabled, the ML scoring service will make use of an in-memory ML score
// cache in order to speed up the overall scoring process.
BASE_FEATURE(kMlUrlScoreCaching, enable_if(!IS_ANDROID));

// If enabled, runs the ML scoring model to assign new relevance scores to the
// URL suggestions and reranks them.
BASE_FEATURE(kMlUrlScoring, enable_if(!IS_ANDROID));

// If enabled, specifies how URL model scores integrate with search traditional
// scores.
BASE_FEATURE(kMlUrlSearchBlending, DISABLED);

// If enabled, creates Omnibox autocomplete URL scoring model. Prerequisite for
// `kMlUrlScoring` & `kMlUrlSearchBlending`.
BASE_FEATURE(kUrlScoringModel, enable_if(!IS_ANDROID));

// If enabled, sends a signal when a user touches down on a search suggestion to
// |SearchPrefetchService|. |SearchPrefetchService| will then prefetch
// suggestion iff the SearchNavigationPrefetch feature and "touch_down" param
// are enabled.
BASE_FEATURE(kOmniboxTouchDownTriggerForPrefetch, enable_if(IS_ANDROID));

// If enabled, sets up an off-main-thread (OMT) input receiver on Android to
// trigger prefetch requests immediately on touch down.
BASE_FEATURE(kOmniboxPrefetchSelectedSuggestionsOmtAndroid, DISABLED);

// Enables simultaneous prefetch and navigation on Enter KeyDown in Omnibox.
BASE_FEATURE(kOmniboxSearchPrefetchOnEnterKeyDown, DISABLED);

// Enables keyword-based site search functionality on Android devices.
BASE_FEATURE(kOmniboxSiteSearch, DISABLED);

// Enables additional site search providers for the Site search Starter Pack.
BASE_FEATURE(kStarterPackExpansion, enable_if(!IS_IOS));

// Enables an informational IPH message at the bottom of the Omnibox directing
// users to certain starter pack engines.
BASE_FEATURE(kStarterPackIPH, DISABLED);

// Enables an '@aimode' starter pack keyword for eligible users only.
BASE_FEATURE(kAiModeStartPack, DISABLED);

// If enabled, |SearchProvider| will not function in Zero Suggest.
BASE_FEATURE(kAblateSearchProviderWarmup, DISABLED);

// If enabled, hl= is reported in search requests (applicable to iOS only).
BASE_FEATURE(kReportApplicationLanguageInSearchRequest, ENABLED);

// When enabled, appends the invocation source parameter to search URLs.
BASE_FEATURE(kOmniboxAppendInvocationSource, DISABLED);

// Enable asynchronous Omnibox/Suggest view inflation.
BASE_FEATURE(kOmniboxAsyncViewInflation, DISABLED);

// Enable asynchronous Fusebox view inflation.
BASE_FEATURE(kOmniboxFuseboxAsyncInflation, DISABLED);

// When enabled, AIM image attachments will be downscaled on load before
// reaching the C++ side.
BASE_FEATURE(kOmniboxAimImageDownscaling, DISABLED);

// Use FusedLocationProvider on Android to fetch device location.
BASE_FEATURE(kUseFusedLocationProvider, ENABLED);

// Updates various NTP/Omnibox assets and descriptions for visual alignment on
// iOS.
BASE_FEATURE(kOmniboxMobileParityUpdate, ENABLED);

// Updates various NTP/Omnibox assets and descriptions for visual alignment on
// Android and iOS, V2.
BASE_FEATURE(kOmniboxMobileParityUpdateV2, ENABLED);

// If enabled, the X-Geo header will include permission granularity.
BASE_FEATURE(kOmniboxXGeoPermissionGranularity, ENABLED);

// When the first suggestion is a url, the favicon is shown in the status view.
BASE_FEATURE(kExactMatchFavicons, DISABLED);

// The features below allow tuning number of suggestions offered to users in
// specific contexts. These features are default enabled and are used to control
// related fieldtrial parameters.
BASE_FEATURE(kNumNtpZpsRecentSearches,
             "OmniboxNumNtpZpsRecentSearches",
             ENABLED);
BASE_FEATURE(kNumNtpZpsTrendingSearches,
             "OmniboxNumNtpZpsTrendingSearches",
             ENABLED);
BASE_FEATURE(kNumWebZpsRecentSearches,
             "OmniboxNumWebZpsRecentSearches",
             ENABLED);
BASE_FEATURE(kNumWebZpsRelatedSearches,
             "OmniboxNumWebZpsRelatedSearches",
             ENABLED);
BASE_FEATURE(kNumWebZpsMostVisitedUrls,
             "OmniboxNumWebZpsMostVisitedUrls",
             ENABLED);
BASE_FEATURE(kNumSrpZpsRecentSearches,
             "OmniboxNumSrpZpsRecentSearches",
             ENABLED);
BASE_FEATURE(kNumSrpZpsRelatedSearches,
             "OmniboxNumSrpZpsRelatedSearches",
             ENABLED);

// If enabled, search aggregators defined by the
// EnterpriseSearchAggregatorSettings policy are saved into prefs and available
// in the TemplateURLService, so that they can be accessed from the Omnibox and
// the Settings page.
BASE_FEATURE(kEnableSearchAggregatorPolicy, ENABLED);

BASE_FEATURE(kUseAgentspace25Logo, ENABLED);

// Enables preconnecting to omnibox suggestions that are not only Search types.
BASE_FEATURE(kPreconnectNonSearchOmniboxSuggestions, ENABLED);

// Controls whether the composebox
BASE_FEATURE(kComposeboxUsesChromeComposeClient, ENABLED);

// Controls whether or not contextual composebox should display suggestions.
BASE_FEATURE(kComposeboxAttachmentsTypedState, DISABLED);

// Whether to enable Google Drive context menu option in the composebox.
BASE_FEATURE(kComposeboxDriveContextMenuOption, DISABLED);
const base::FeatureParam<bool> kComposeboxDriveIdentityFallback{
    &kComposeboxDriveContextMenuOption, "enable_identity_fallback", true};

// Whether to enable Google Drive context menu option's disclaimer flow in the
// composebox.
BASE_FEATURE(kComposeboxDriveContextMenuOptionDisclaimer, DISABLED);

// For Workspace AIM, the Flow ID is the ConsentKit frontend identifier
// (e.g. CHOICEFLOW_PCONTEXT_WORKSPACE_AIM) and the Product ID is the
// Footprints ConsentVariant ID (e.g.
// CHOICEFLOW_VARIANT_PCONTEXT_WORKSPACE_AIM_DEFAULT)
const base::FeatureParam<int> kComposeboxDriveConsentFlowId{
    &kComposeboxDriveContextMenuOptionDisclaimer, "flow_id", 76};

const base::FeatureParam<int> kComposeboxDriveConsentProductId{
    &kComposeboxDriveContextMenuOptionDisclaimer, "product_id", 89978449};
const base::FeatureParam<int> kComposeboxDriveConsentProductSurface{
    &kComposeboxDriveContextMenuOptionDisclaimer, "product_surface", 29};
const base::FeatureParam<std::string> kComposeboxDriveConsentEntrypointId{
    &kComposeboxDriveContextMenuOptionDisclaimer, "entrypoint_id", "aim-drive"};

// Whether to enable the signin promo for the Google Drive context menu option.
BASE_FEATURE(kComposeboxDriveContextMenuOptionSigninPromo, DISABLED);

// Whether to force the Google Drive disclaimer to be accepted. This flag is
// only used for testing purposes since dasher accounts are not allowed to
// consent via pContext.
BASE_FEATURE(kForceDriveDisclaimerAccepted,
             DISABLED);

// Whether the composebox should show a verbatim match for context in
// zero-suggest.
BASE_FEATURE(kComposeboxVerbatimMatchZeroSuggest, ENABLED);

// Whether to disable warmup requests for the composebox.
BASE_FEATURE(kDisableComposeboxWarmupRequests, DISABLED);

// Enables passthrough params to be sent to the AIM eligibility service.
BASE_FEATURE(kAimUrlInterceptPassthrough, DISABLED);

BASE_FEATURE(kOmniboxDebugLogs, base::FEATURE_DISABLED_BY_DEFAULT);

// Kill switch - Enables voice search coherence across composeboxes in NTP,
// cobrowsing, omnibox by default, unless feature param overrides.
//  - Submit and stop buttons in voice search mode.
//  - New voice recording animation.
//  - New metrics for voice search across composeboxes.
//  - No live transcription below the new recording animation.
BASE_FEATURE(kVoiceSearchCoherenceComposeboxes,
             base::FEATURE_ENABLED_BY_DEFAULT);

BASE_FEATURE(kDrivePickerV2Scope, base::FEATURE_ENABLED_BY_DEFAULT);

// Enables voice search coherence (as described above) only for cobrowsing.
// Overrides the default (default was all surfaces enabled).
const base::FeatureParam<bool> kVoiceSearchCoherenceComposeboxCobrowsingOnly{
    &kVoiceSearchCoherenceComposeboxes,
    "VoiceSearchCoherenceComposeboxCobrowsingOnly", false};

// Enables voice search live experiment for NTP searchbox, (arm 1):
//  - Submit and stop buttons in voice search mode.
//  - New voice recording animation.
//  - New metrics for voice search across searchbox.
//  - NO live transcription below the new recording animation.
BASE_FEATURE(kVoiceSearchCoherenceSearchbox, base::FEATURE_DISABLED_BY_DEFAULT);

// Enables voice search live experiment for NTP searchbox, (arm 2):
//  - Submit and stop buttons in voice search mode.
//  - New voice recording animation.
//  - New metrics for voice search for NTP searchbox.
//  - DIFF: adds live transcription below the new recording animation.
const base::FeatureParam<bool>
    kVoiceSearchCoherenceSearchboxWithLiveTranscription{
        &kVoiceSearchCoherenceSearchbox,
        "VoiceSearchCoherenceSearchboxWithLiveTranscription", false};

#if BUILDFLAG(IS_ANDROID)
// Accelerates time from cold start to focused Omnibox on low-end devices,
// prioritizing Omnibox focus and background initialization.
BASE_FEATURE(kJumpStartOmnibox, DISABLED);

// Prevents intermediate AutocompleteResult updates from being sent to Java on
// low-end devices. This aims at eliminating time spent on constructing,
// measuring, and laying out views that are about to be discarded, and reducing
// the volume of JNI jumps.
BASE_FEATURE(kSuppressIntermediateACUpdatesOnLowEndDevices, DISABLED);

// When enabled, delay focusTab to prioritize navigation
// (https://crbug.com/374852568).
BASE_FEATURE(kPostDelayedTaskFocusTab, ENABLED);

// Controls various Omnibox Diagnostics features.
BASE_FEATURE(kDiagnostics, "OmniboxDiagnostics", DISABLED);

// Force the realbox on Android regardless of platform/configuration checks.
BASE_FEATURE(kForceAndroidRealbox, DISABLED);

// If enabled, disables ligatures in the URL bar on Android.
BASE_FEATURE(kUrlBarWithoutLigatures, ENABLED);

// If enabled, Java-cached ZPS will be served.
// The cached ZPS made sense on sub-4GB Android Go devices
BASE_FEATURE(kServeJavaCachedZeroSuggest, ENABLED);

// If enabled, OmniboxSuggestionsDropdown will force reset the scroll position
// of the Omnibox suggestion list to the top during any re-layout.
BASE_FEATURE(kResetSuggestionsScroll, DISABLED);

// Kill switch for special handling for session-less voice search queries
// (e.g. from NTP fakebox). This special case was added to address b/541295247.
BASE_FEATURE(kOmniboxSessionlessVoiceSearch, ENABLED);

namespace android {
static int64_t JNI_OmniboxFeatureMap_GetNativeMap(JNIEnv* env) {
  static const base::Feature* const kFeaturesExposedToJava[] = {
      &kDiagnostics,
      &kForceAndroidRealbox,
      &kOmniboxTouchDownTriggerForPrefetch,
      &kOmniboxPrefetchSelectedSuggestionsOmtAndroid,
      &kOmniboxAsyncViewInflation,
      &kOmniboxFuseboxAsyncInflation,
      &kRichAutocompletion,
      &kUrlBarWithoutLigatures,
      &kUseFusedLocationProvider,
      &kJumpStartOmnibox,
      &kPostDelayedTaskFocusTab,
      &kOmniboxMobileParityUpdateV2,
      &kOmniboxXGeoPermissionGranularity,
      &kPlatformAgnosticXGeo,
      &kInlineLocationSignaling,
      &kOmniboxSiteSearch,
      &kOmniboxMultimodalInput,
      &kAndroidDesktopAimGate,
      &kServeJavaCachedZeroSuggest,
      &kAIMSuppressVerbatimMatch,
      &kResetSuggestionsScroll,
      &kExactMatchFavicons,
      &kStarterPackExpansion,
      &kOmniboxSearchPrefetchOnEnterKeyDown,
      &kOmniboxAimImageDownscaling,
      &kOmniboxDebounceKeyboardVisibility,
      &kOmniboxSessionlessVoiceSearch};
  static base::NoDestructor<base::android::FeatureMap> kFeatureMap(
      kFeaturesExposedToJava);
  return reinterpret_cast<int64_t>(kFeatureMap.get());
}
}  // namespace android
#endif  // BUILDFLAG(IS_ANDROID)

// If enabled, X-Geo headers are sent using the platform-agnostic C++
// implementation. On Android, enabling this flag will disable the legacy Java
// implementation.
BASE_FEATURE(kPlatformAgnosticXGeo, DISABLED);

// If enabled, Inline Location Signaling is enabled gating all development
// and experimentation for the feature.
BASE_FEATURE(kInlineLocationSignaling, DISABLED);

constexpr base::FeatureParam<InlineLocationSignalingDisplayOrder>::Option
    kInlineLocationSignalingDisplayOrderOptions[] = {
        {InlineLocationSignalingDisplayOrder::kDisplayBelow, "DisplayBelow"},
        {InlineLocationSignalingDisplayOrder::kDisplayAbove, "DisplayAbove"},
};

const base::FeatureParam<InlineLocationSignalingDisplayOrder>
    kInlineLocationSignalingDisplayOrder{
        &kInlineLocationSignaling, "display_order",
        InlineLocationSignalingDisplayOrder::kDisplayBelow,
        &kInlineLocationSignalingDisplayOrderOptions};

constexpr base::FeatureParam<InlineLocationSignalingWording>::Option
    kInlineLocationSignalingWordingOptions[] = {
        {InlineLocationSignalingWording::kUseApproximateLocation,
         "UseApproximateLocation"},
        {InlineLocationSignalingWording::kUseLocation, "UseLocation"},
};

const base::FeatureParam<InlineLocationSignalingWording>
    kInlineLocationSignalingWording{
        &kInlineLocationSignaling, "wording",
        InlineLocationSignalingWording::kUseApproximateLocation,
        &kInlineLocationSignalingWordingOptions};

// If enabled, the "Ask Google about this page" action will route to cobrowse.
BASE_FEATURE(kWebUIOmniboxAskGAboutThisPage, DISABLED);

const base::FeatureParam<bool> kAskGCoBrowse{
    &kWebUIOmniboxAskGAboutThisPage, "Omnibox_AskGCoBrowse", false};
const base::FeatureParam<bool> kAskGCoBrowseWithVisualSelection{
    &kWebUIOmniboxAskGAboutThisPage,
    "Omnibox_AskGCoBrowseWithVisualSelection", false};
const base::FeatureParam<bool> kAskGComposeBox{
    &kWebUIOmniboxAskGAboutThisPage, "Omnibox_AskGComposeBox", false};
const base::FeatureParam<bool> kAskGLensChipRoute{
    &kWebUIOmniboxAskGAboutThisPage, "Omnibox_AskGLensChipRoute", false};
const base::FeatureParam<bool> kAskGSwapIcon{
    &kWebUIOmniboxAskGAboutThisPage, "Omnibox_AskGSwapIcon", false};
const base::FeatureParam<bool> kAskGSwapSuggestionIcon{
    &kWebUIOmniboxAskGAboutThisPage, "Omnibox_AskGSwapSuggestionIcon", false};
const base::FeatureParam<bool> kAskGCurrentTabChip{
    &kWebUIOmniboxAskGAboutThisPage, "Omnibox_AskGCurrentTabChip", false};
const base::FeatureParam<bool> kAskGLensIcon{
    &kWebUIOmniboxAskGAboutThisPage, "Omnibox_AskGLensIcon", false};
const base::FeatureParam<bool> kAskGLensSearchHintText{
    &kWebUIOmniboxAskGAboutThisPage, "Omnibox_AskGLensSearchHintText", false};
const base::FeatureParam<bool> kAskGShowFirstDescription{
    &kWebUIOmniboxAskGAboutThisPage, "Omnibox_AskGShowFirstDescription", false};
const base::FeatureParam<bool> kAskGComposeboxLensChip{
    &kWebUIOmniboxAskGAboutThisPage, "Omnibox_AskGComposeboxLensChip", false};
const base::FeatureParam<bool> kAskGBlockAutoTabZeroStateSuggestions{
    &kWebUIOmniboxAskGAboutThisPage,
    "Omnibox_AskGBlockAutoTabZeroStateSuggestions", false};
const base::FeatureParam<bool> kAskGComposeboxPlaceholder{
    &kWebUIOmniboxAskGAboutThisPage, "Omnibox_AskGComposeboxPlaceholder", false};
const base::FeatureParam<bool> kAskGBypassPrivacyNotice{
    &kWebUIOmniboxAskGAboutThisPage, "Omnibox_AskGBypassPrivacyNotice", false};

// Note: no new flags beyond this point.

namespace flag_descriptions {
const char kOmniboxDebugLogsName[] = "Omnibox debug logs";
const char kOmniboxDebugLogsDescription[] =
    "Enables logging that can be read from an internals page.";
}  // namespace flag_descriptions

}  // namespace omnibox

#if BUILDFLAG(IS_ANDROID)
DEFINE_JNI(OmniboxFeatureMap)
#endif
