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

#ifndef COMPONENTS_SEARCH_ENGINES_SEARCH_ENGINES_SWITCHES_H_
#define COMPONENTS_SEARCH_ENGINES_SEARCH_ENGINES_SWITCHES_H_

#include <string>

#include "base/component_export.h"
#include "base/feature_list.h"
#include "base/metrics/field_trial_params.h"
#include "build/build_config.h"

namespace switches {

COMPONENT_EXPORT(SEARCH_ENGINES_SWITCHES)
extern const char kExtraSearchQueryParams[];

COMPONENT_EXPORT(SEARCH_ENGINES_SWITCHES)
extern const char kIgnoreNoFirstRunForSearchEngineChoiceScreen[];

COMPONENT_EXPORT(SEARCH_ENGINES_SWITCHES)
extern const char kDisableSearchEngineChoiceScreen[];

COMPONENT_EXPORT(SEARCH_ENGINES_SWITCHES)
extern const char kForceSearchEngineChoiceScreen[];

// Quickens the site search expiration time for testing purposes. When this flag
// is set, the site search expiration time is 20 seconds instead of 2 days.
COMPONENT_EXPORT(SEARCH_ENGINES_SWITCHES)
extern const char kQuickenSiteSearchExpiryForTesting[];

// When enabled, a custom search engine's last_visited time is updated when it
// is unset as the default search engine.
COMPONENT_EXPORT(SEARCH_ENGINES_SWITCHES)
BASE_DECLARE_FEATURE(kVisitCustomSearchOnUndefaulting);

// When enabled, prefs-based search provider overrides are ignored and
// prepopulated engines will always be the regional built-in ones. If a user
// previously had an overridden search engine as DSE, this flag will cause that
// engine to be ignored, and the default search engine will be picked from the
// regional set instead.
COMPONENT_EXPORT(SEARCH_ENGINES_SWITCHES)
BASE_DECLARE_FEATURE(kIgnoreSearchProviderOverrides);

COMPONENT_EXPORT(SEARCH_ENGINES_SWITCHES)
BASE_DECLARE_FEATURE(kInvalidateSearchEngineChoiceOnDeviceRestoreDetection);

COMPONENT_EXPORT(SEARCH_ENGINES_SWITCHES)
extern const base::FeatureParam<bool> kInvalidateChoiceOnRestoreIsRetroactive;

// The string that's passed to
// `switches::kSearchEngineChoiceTriggerRepromptParams` so that we don't
// reprompt users with the choice screen.
inline constexpr char kSearchEngineChoiceNoRepromptString[] = "NO_REPROMPT";

// Reprompt params for the search engine choice.
// This is a JSON dictionary where keys are country codes, and values are Chrome
// version strings. The wildcard country '*' represents all countries.
// When a specific country is specified, it takes precedence over the wildcard.
//
// Example: {"*": "2.0.0.0", "BE": "5.0.0.0"}
// This reprompts users in Belgium who made the choice strictly before version
// 5, and users in all other countries who made the choice strictly before
// version 2.
COMPONENT_EXPORT(SEARCH_ENGINES_SWITCHES)
BASE_DECLARE_FEATURE(kSearchEngineChoiceTriggerReprompt);
COMPONENT_EXPORT(SEARCH_ENGINES_SWITCHES)
extern const base::FeatureParam<std::string>
    kSearchEngineChoiceTriggerRepromptParams;


// Whether state consistency across choice metadata and DSE pref state should
// be enforced.
// The presence of DSE choice metadata implies that a DSE choice was made,
// and in this case we also expect a DSE to be set in prefs. There are some
// flows that can cause the DSE pref to be cleared, like pref tampering
// detection. When this happens, we also wipe the DSE choice metadata to
// trigger a new choice prompt.
COMPONENT_EXPORT(SEARCH_ENGINES_SWITCHES)
BASE_DECLARE_FEATURE(kWipeChoicePrefsOnMissingDefaultSearchEngine);

// Kill switch to revert the fix of using assistedQueryStats for prefetch source
// component. See crbug.com/345275145.
COMPONENT_EXPORT(SEARCH_ENGINES_SWITCHES)
BASE_DECLARE_FEATURE(kPrefetchParameterFix);

// Kill switch to revert the fix of dropping searchbox stats (gs_lcrp) from
// prefetch requests. See crbug.com/350939001.
COMPONENT_EXPORT(SEARCH_ENGINES_SWITCHES)
BASE_DECLARE_FEATURE(kRemoveSearchboxStatsParamFromPrefetchRequests);

// Switch guarding TemplateURL syncing of untouched autogenerated search
// engines.
COMPONENT_EXPORT(SEARCH_ENGINES_SWITCHES)
BASE_DECLARE_FEATURE(kDisableSyncAutogeneratedSearchEngines);

// When enabled, resets the Default Search Engine if tampering is detected on
// startup.
COMPONENT_EXPORT(SEARCH_ENGINES_SWITCHES)
BASE_DECLARE_FEATURE(kResetTamperedDefaultSearchEngine);

// Switch guarding a 1p API to retrieve the default search provider from chrome.
COMPONENT_EXPORT(SEARCH_ENGINES_SWITCHES)
BASE_DECLARE_FEATURE(kClankDefaultSearchApi);

// Whether DumpWithoutCrashing-based debugging should be enabled on
// some select keyword database refresh code paths.
COMPONENT_EXPORT(SEARCH_ENGINES_SWITCHES)
BASE_DECLARE_FEATURE(kKwdbRefreshDebugging);

#if BUILDFLAG(IS_ANDROID)
// Whether the renewal of an already-imported search engine choice should result
// in re-applying the choice, instead of skipping it as a no-op.
COMPONENT_EXPORT(SEARCH_ENGINES_SWITCHES)
BASE_DECLARE_FEATURE(kApplyDeviceChoiceRenewal);
#endif  // BUILDFLAG(IS_ANDROID)

#if !BUILDFLAG(IS_ANDROID)
// Restructuring of the search settings pages.
COMPONENT_EXPORT(SEARCH_ENGINES_SWITCHES)
BASE_DECLARE_FEATURE(kSearchSettingsUpdate);
#endif  // !BUILDFLAG(IS_ANDROID)

#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS)
// Refactoring of search engine sorting and filtering in the settings page.
COMPONENT_EXPORT(SEARCH_ENGINES_SWITCHES)
BASE_DECLARE_FEATURE(kSearchSettingsUpdateV2);
#endif  // BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS)

#if BUILDFLAG(IS_WIN)
// When enabled, will reject encrypted keyword table hashes that are weakly
// encrypted.
COMPONENT_EXPORT(SEARCH_ENGINES_SWITCHES)
BASE_DECLARE_FEATURE(kRejectWeakKeywordHashes);
#endif  // BUILDFLAG(IS_WIN)

}  // namespace switches

#endif  // COMPONENTS_SEARCH_ENGINES_SEARCH_ENGINES_SWITCHES_H_
