#include "components/search_engines/search_engine_choice/search_engine_choice_utils.h"
#include <optional>
#include <string>
#include "base/check_deref.h"
#include "base/check_is_test.h"
#include "base/check_op.h"
#include "base/command_line.h"
#include "base/containers/fixed_flat_map.h"
#include "base/containers/to_vector.h"
#include "base/feature_list.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/user_metrics.h"
#include "base/strings/stringprintf.h"
#include "base/values.h"
#include "base/version.h"
#include "build/branding_buildflags.h"
#include "components/country_codes/country_codes.h"
#include "components/policy/core/common/policy_service.h"
#include "components/policy/policy_constants.h"
#include "components/prefs/pref_service.h"
#include "components/search_engines/eea_countries_ids.h"
#include "components/search_engines/search_engine_type.h"
#include "components/search_engines/search_engines_pref_names.h"
#include "components/search_engines/search_engines_switches.h"
#include "components/search_engines/search_terms_data.h"
#include "components/search_engines/template_url_data.h"
#include "components/search_engines/template_url_prepopulate_data.h"
#include "components/search_engines/template_url_service.h"
#include "components/signin/public/base/signin_switches.h"
#include "components/strings/grit/components_strings.h"
#include "ui/base/l10n/l10n_util.h"
#if !BUILDFLAG(IS_ANDROID)
#include "components/grit/components_scaled_resources.h"
#include "ui/resources/grit/ui_resources.h"
#endif
namespace search_engines {
namespace {
#if !BUILDFLAG(IS_ANDROID)
#include "components/search_engines/generated_search_engine_resource_ids-inc.cc"
#endif
constexpr char kDisplayStateCountryIdKey[] = …;
constexpr char kDisplayStateSearchEnginesKey[] = …;
constexpr char kDisplayStateSelectedEngineIndexKey[] = …;
}
const char kSearchEngineChoiceScreenNavigationConditionsHistogram[] = …;
const char kSearchEngineChoiceScreenProfileInitConditionsHistogram[] = …;
const char kSearchEngineChoiceScreenEventsHistogram[] = …;
const char kSearchEngineChoiceScreenDefaultSearchEngineTypeHistogram[] = …;
const char kSearchEngineChoiceScreenSelectedEngineIndexHistogram[] = …;
const char kSearchEngineChoiceScreenShowedEngineAtHistogramPattern[] = …;
const char kSearchEngineChoiceScreenShowedEngineAtCountryMismatchHistogram[] = …;
const char kSearchEngineChoiceWipeReasonHistogram[] = …;
const char kSearchEngineChoiceRepromptHistogram[] = …;
const char kSearchEngineChoiceRepromptWildcardHistogram[] = …;
const char kSearchEngineChoiceRepromptSpecificCountryHistogram[] = …;
const char kSearchEngineChoiceUnexpectedIdHistogram[] = …;
ChoiceScreenDisplayState::ChoiceScreenDisplayState(
std::vector<SearchEngineType> search_engines,
int country_id,
std::optional<int> selected_engine_index)
: … { … }
ChoiceScreenDisplayState::ChoiceScreenDisplayState(
const ChoiceScreenDisplayState& other) = default;
ChoiceScreenDisplayState::~ChoiceScreenDisplayState() = default;
base::Value::Dict ChoiceScreenDisplayState::ToDict() const { … }
std::optional<ChoiceScreenDisplayState> ChoiceScreenDisplayState::FromDict(
const base::Value::Dict& dict) { … }
ChoiceScreenData::ChoiceScreenData(
TemplateURL::OwnedTemplateURLVector owned_template_urls,
int country_id,
const SearchTermsData& search_terms_data)
: … { … }
ChoiceScreenData::~ChoiceScreenData() = default;
bool IsChoiceScreenFlagEnabled(ChoicePromo promo) { … }
bool IsEeaChoiceCountry(int country_id) { … }
void RecordChoiceScreenProfileInitCondition(
SearchEngineChoiceScreenConditions condition) { … }
void RecordChoiceScreenNavigationCondition(
SearchEngineChoiceScreenConditions condition) { … }
void RecordChoiceScreenEvent(SearchEngineChoiceScreenEvents event) { … }
void RecordChoiceScreenDefaultSearchProviderType(SearchEngineType engine_type) { … }
void RecordChoiceScreenSelectedIndex(int selected_engine_index) { … }
void RecordChoiceScreenPositionsCountryMismatch(bool has_mismatch) { … }
void RecordChoiceScreenPositions(
const std::vector<SearchEngineType>& displayed_search_engines) { … }
void RecordUnexpectedSearchProvider(const TemplateURLData& data) { … }
void WipeSearchEngineChoicePrefs(PrefService& profile_prefs,
WipeSearchEngineChoiceReason reason) { … }
std::optional<SearchEngineCountryOverride> GetSearchEngineCountryOverride() { … }
bool HasSearchEngineCountryListOverride() { … }
#if !BUILDFLAG(IS_ANDROID)
std::u16string GetMarketingSnippetString(
const TemplateURLData& template_url_data) { … }
int GetIconResourceId(const std::u16string& engine_keyword) { … }
#endif
}