#include "components/omnibox/browser/omnibox_field_trial.h"
#include <algorithm>
#include <cmath>
#include <functional>
#include <string>
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/field_trial_params.h"
#include "base/no_destructor.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/system/sys_info.h"
#include "base/time/time.h"
#include "base/trace_event/memory_usage_estimator.h"
#include "build/build_config.h"
#include "components/history/core/browser/url_database.h"
#include "components/omnibox/browser/autocomplete_provider.h"
#include "components/omnibox/browser/page_classification_functions.h"
#include "components/omnibox/browser/url_index_private_data.h"
#include "components/omnibox/common/omnibox_features.h"
#include "components/optimization_guide/machine_learning_tflite_buildflags.h"
#include "components/search/search.h"
#include "components/variations/active_field_trials.h"
#include "components/variations/hashing.h"
#include "components/variations/variations_associated_data.h"
#include "third_party/metrics_proto/omnibox_event.pb.h"
#include "ui/base/ui_base_features.h"
OmniboxEventProto;
namespace {
VariationParams;
ScoreBuckets;
void InitializeBucketsFromString(const std::string& bucket_string,
ScoreBuckets* score_buckets) { … }
void InitializeScoreBuckets(const VariationParams& params,
const char* relevance_cap_param,
const char* half_life_param,
const char* score_buckets_param,
const char* use_decay_factor_param,
ScoreBuckets* score_buckets) { … }
std::string GetValueForRuleInContextFromVariationParams(
const std::map<std::string, std::string>& params,
const std::string& rule,
OmniboxEventProto::PageClassification page_classification) { … }
OmniboxFieldTrial::MLConfig& GetMLConfigInternal() { … }
bool IsKoreanLocale(const std::string& locale) { … }
}
HUPScoringParams::ScoreBuckets::ScoreBuckets()
: … { … }
HUPScoringParams::ScoreBuckets::ScoreBuckets(const ScoreBuckets& other) =
default;
HUPScoringParams::ScoreBuckets::~ScoreBuckets() { … }
size_t HUPScoringParams::ScoreBuckets::EstimateMemoryUsage() const { … }
double HUPScoringParams::ScoreBuckets::HalfLifeTimeDecay(
const base::TimeDelta& elapsed_time) const { … }
size_t HUPScoringParams::EstimateMemoryUsage() const { … }
int OmniboxFieldTrial::GetDisabledProviderTypes() { … }
void OmniboxFieldTrial::GetActiveSuggestFieldTrialHashes(
std::vector<uint32_t>* field_trial_hashes) { … }
void OmniboxFieldTrial::GetDemotionsByType(
OmniboxEventProto::PageClassification current_page_classification,
DemotionMultipliers* demotions_by_type) { … }
size_t OmniboxFieldTrial::GetProviderMaxMatches(
AutocompleteProvider::Type provider) { … }
bool OmniboxFieldTrial::IsMaxURLMatchesFeatureEnabled() { … }
size_t OmniboxFieldTrial::GetMaxURLMatches() { … }
void OmniboxFieldTrial::GetDefaultHUPScoringParams(
HUPScoringParams* scoring_params) { … }
void OmniboxFieldTrial::GetExperimentalHUPScoringParams(
HUPScoringParams* scoring_params) { … }
float OmniboxFieldTrial::HQPBookmarkValue() { … }
bool OmniboxFieldTrial::HQPAllowMatchInTLDValue() { … }
bool OmniboxFieldTrial::HQPAllowMatchInSchemeValue() { … }
void OmniboxFieldTrial::GetSuggestPollingStrategy(bool* from_last_keystroke,
int* polling_delay_ms) { … }
std::string OmniboxFieldTrial::HQPExperimentalScoringBuckets() { … }
float OmniboxFieldTrial::HQPExperimentalTopicalityThreshold() { … }
int OmniboxFieldTrial::MaxNumHQPUrlsIndexedAtStartup() { … }
size_t OmniboxFieldTrial::HQPMaxVisitsToScore() { … }
float OmniboxFieldTrial::HQPTypedValue() { … }
OmniboxFieldTrial::NumMatchesScores OmniboxFieldTrial::HQPNumMatchesScores() { … }
size_t OmniboxFieldTrial::HQPNumTitleWordsToAllow() { … }
bool OmniboxFieldTrial::HQPAlsoDoHUPLikeScoring() { … }
bool OmniboxFieldTrial::HUPSearchDatabase() { … }
bool OmniboxFieldTrial::IsOnDeviceHeadSuggestEnabledForIncognito() { … }
bool OmniboxFieldTrial::IsOnDeviceHeadSuggestEnabledForNonIncognito() { … }
bool OmniboxFieldTrial::IsOnDeviceHeadSuggestEnabledForAnyMode() { … }
bool OmniboxFieldTrial::IsOnDeviceTailSuggestEnabled() { … }
bool OmniboxFieldTrial::ShouldEncodeLeadingSpaceForOnDeviceTailSuggest() { … }
bool OmniboxFieldTrial::ShouldApplyOnDeviceHeadModelSelectionFix() { … }
bool OmniboxFieldTrial::IsOnDeviceHeadSuggestEnabledForLocale(
const std::string& locale) { … }
std::string OmniboxFieldTrial::OnDeviceHeadModelLocaleConstraint(
bool is_incognito) { … }
const base::FeatureParam<bool> OmniboxFieldTrial::kSquareSuggestIconAnswers(
&omnibox::kSquareSuggestIcons,
"OmniboxSquareSuggestIconAnswers",
true);
const base::FeatureParam<bool> OmniboxFieldTrial::kSquareSuggestIconIcons(
&omnibox::kSquareSuggestIcons,
"OmniboxSquareSuggestIconIcons",
false);
const base::FeatureParam<bool> OmniboxFieldTrial::kSquareSuggestIconEntities(
&omnibox::kSquareSuggestIcons,
"OmniboxSquareSuggestIconEntities",
false);
const base::FeatureParam<double>
OmniboxFieldTrial::kSquareSuggestIconEntitiesScale(
&omnibox::kSquareSuggestIcons,
"OmniboxSquareSuggestIconEntitiesScale",
0.8722);
const base::FeatureParam<bool> OmniboxFieldTrial::kSquareSuggestIconWeather(
&omnibox::kSquareSuggestIcons,
"OmniboxSquareSuggestIconWeather",
true);
bool OmniboxFieldTrial::IsUniformRowHeightEnabled() { … }
const base::FeatureParam<int> OmniboxFieldTrial::kRichSuggestionVerticalMargin(
&omnibox::kUniformRowHeight,
"OmniboxRichSuggestionVerticalMargin",
6);
bool OmniboxFieldTrial::IsGM3TextStyleEnabled() { … }
const base::FeatureParam<int> OmniboxFieldTrial::kFontSizeTouchUI(
&omnibox::kOmniboxSteadyStateTextStyle,
"OmniboxFontSizeTouchUI",
15);
const base::FeatureParam<int> OmniboxFieldTrial::kFontSizeNonTouchUI(
&omnibox::kOmniboxSteadyStateTextStyle,
"OmniboxFontSizeNonTouchUI",
13);
const char OmniboxFieldTrial::kBundledExperimentFieldTrialName[] = …;
const char OmniboxFieldTrial::kDisableProvidersRule[] = …;
const char OmniboxFieldTrial::kDemoteByTypeRule[] = …;
const char OmniboxFieldTrial::kHQPBookmarkValueRule[] = …;
const char OmniboxFieldTrial::kHQPTypedValueRule[] = …;
const char OmniboxFieldTrial::kHQPAllowMatchInTLDRule[] = …;
const char OmniboxFieldTrial::kHQPAllowMatchInSchemeRule[] = …;
const char
OmniboxFieldTrial::kMeasureSuggestPollingDelayFromLastKeystrokeRule[] = …;
const char OmniboxFieldTrial::kSuggestPollingDelayMsRule[] = …;
const char OmniboxFieldTrial::kHQPMaxVisitsToScoreRule[] = …;
const char OmniboxFieldTrial::kHQPNumMatchesScoresRule[] = …;
const char OmniboxFieldTrial::kHQPNumTitleWordsRule[] = …;
const char OmniboxFieldTrial::kHQPAlsoDoHUPLikeScoringRule[] = …;
const char OmniboxFieldTrial::kHUPSearchDatabaseRule[] = …;
const char OmniboxFieldTrial::kHUPNewScoringTypedCountRelevanceCapParam[] = …;
const char OmniboxFieldTrial::kHUPNewScoringTypedCountHalfLifeTimeParam[] = …;
const char OmniboxFieldTrial::kHUPNewScoringTypedCountScoreBucketsParam[] = …;
const char OmniboxFieldTrial::kHUPNewScoringTypedCountUseDecayFactorParam[] = …;
const char OmniboxFieldTrial::kHUPNewScoringVisitedCountRelevanceCapParam[] = …;
const char OmniboxFieldTrial::kHUPNewScoringVisitedCountHalfLifeTimeParam[] = …;
const char OmniboxFieldTrial::kHUPNewScoringVisitedCountScoreBucketsParam[] = …;
const char OmniboxFieldTrial::kHUPNewScoringVisitedCountUseDecayFactorParam[] = …;
const char OmniboxFieldTrial::kHQPExperimentalScoringBucketsParam[] = …;
const char
OmniboxFieldTrial::kHQPExperimentalScoringTopicalityThresholdParam[] = …;
const char
OmniboxFieldTrial::kMaxNumHQPUrlsIndexedAtStartupOnLowEndDevicesParam[] = …;
const char
OmniboxFieldTrial::kMaxNumHQPUrlsIndexedAtStartupOnNonLowEndDevicesParam[] = …;
const char OmniboxFieldTrial::kMaxZeroSuggestMatchesParam[] = …;
const char OmniboxFieldTrial::kOmniboxMaxURLMatchesParam[] = …;
const char OmniboxFieldTrial::kUIMaxAutocompleteMatchesByProviderParam[] = …;
const char OmniboxFieldTrial::kUIMaxAutocompleteMatchesParam[] = …;
const char OmniboxFieldTrial::kDynamicMaxAutocompleteUrlCutoffParam[] = …;
const char OmniboxFieldTrial::kDynamicMaxAutocompleteIncreasedLimitParam[] = …;
const char OmniboxFieldTrial::kOnDeviceHeadModelLocaleConstraint[] = …;
const char OmniboxFieldTrial::kOnDeviceHeadModelSelectionFix[] = …;
int OmniboxFieldTrial::kDefaultMinimumTimeBetweenSuggestQueriesMs = …;
namespace OmniboxFieldTrial {
const base::FeatureParam<int> kZeroSuggestPrefetchDebounceDelay(
&omnibox::kZeroSuggestPrefetchDebouncing,
"ZeroSuggestPrefetchDebounceDelay",
300);
const base::FeatureParam<bool> kZeroSuggestPrefetchDebounceFromLastRun(
&omnibox::kZeroSuggestPrefetchDebouncing,
"ZeroSuggestPrefetchDebounceFromLastRun",
true);
const base::FeatureParam<int> kZeroSuggestCacheMaxSize(
&omnibox::kZeroSuggestInMemoryCaching,
"ZeroSuggestCacheMaxSize",
5);
const base::FeatureParam<int> kLocalHistoryZeroSuggestRelevanceScore(
&omnibox::kAdjustLocalHistoryZeroSuggestRelevanceScore,
"LocalHistoryZeroSuggestRelevanceScore",
500);
bool IsZeroSuggestPrefetchingEnabled() { … }
bool IsZeroSuggestPrefetchingEnabledInContext(
metrics::OmniboxEventProto::PageClassification page_classification) { … }
bool IsRichAutocompletionEnabled() { … }
bool RichAutocompletionShowAdditionalText() { … }
const base::FeatureParam<bool> kRichAutocompletionAutocompleteTitles(
&omnibox::kRichAutocompletion,
"RichAutocompletionAutocompleteTitles",
false);
const base::FeatureParam<bool>
kRichAutocompletionAutocompleteTitlesShortcutProvider(
&omnibox::kRichAutocompletion,
"RichAutocompletionAutocompleteTitlesShortcutProvider",
true);
const base::FeatureParam<int> kRichAutocompletionAutocompleteTitlesMinChar(
&omnibox::kRichAutocompletion,
"RichAutocompletionAutocompleteTitlesMinChar",
3);
const base::FeatureParam<bool> kRichAutocompletionAutocompleteNonPrefixAll(
&omnibox::kRichAutocompletion,
"RichAutocompletionAutocompleteNonPrefixAll",
false);
const base::FeatureParam<bool>
kRichAutocompletionAutocompleteNonPrefixShortcutProvider(
&omnibox::kRichAutocompletion,
"RichAutocompletionAutocompleteNonPrefixShortcutProvider",
false);
const base::FeatureParam<int> kRichAutocompletionAutocompleteNonPrefixMinChar(
&omnibox::kRichAutocompletion,
"RichAutocompletionAutocompleteNonPrefixMinChar",
0);
const base::FeatureParam<bool> kRichAutocompletionShowAdditionalText(
&omnibox::kRichAutocompletion,
"RichAutocompletionAutocompleteShowAdditionalText",
true);
const base::FeatureParam<bool> kRichAutocompletionAdditionalTextWithParenthesis(
&omnibox::kRichAutocompletion,
"RichAutocompletionAdditionalTextWithParenthesis",
false);
const base::FeatureParam<bool> kRichAutocompletionAutocompleteShortcutText(
&omnibox::kRichAutocompletion,
"RichAutocompletionAutocompleteShortcutText",
true);
const base::FeatureParam<int>
kRichAutocompletionAutocompleteShortcutTextMinChar(
&omnibox::kRichAutocompletion,
"RichAutocompletionAutocompleteShortcutTextMinChar",
3);
const base::FeatureParam<bool> kRichAutocompletionCounterfactual(
&omnibox::kRichAutocompletion,
"RichAutocompletionCounterfactual",
false);
const base::FeatureParam<bool>
kRichAutocompletionAutocompletePreferUrlsOverPrefixes(
&omnibox::kRichAutocompletion,
"RichAutocompletionAutocompletePreferUrlsOverPrefixes",
false);
const base::FeatureParam<bool> kDomainSuggestionsCounterfactual(
&omnibox::kDomainSuggestions,
"DomainSuggestionsCounterfactual",
false);
const base::FeatureParam<int> kDomainSuggestionsTypedUrlsThreshold(
&omnibox::kDomainSuggestions,
"DomainSuggestionsTypedUrlsThreshold",
7);
const base::FeatureParam<int> kDomainSuggestionsTypedUrlsOffset(
&omnibox::kDomainSuggestions,
"DomainSuggestionsTypedUrlsOffset",
1);
const base::FeatureParam<int> kDomainSuggestionsTypedVisitThreshold(
&omnibox::kDomainSuggestions,
"DomainSuggestionsTypedVisitThreshold",
4);
const base::FeatureParam<int> kDomainSuggestionsTypedVisitOffset(
&omnibox::kDomainSuggestions,
"DomainSuggestionsTypedVisitOffset",
1);
const base::FeatureParam<int> kDomainSuggestionsTypedVisitCapPerVisit(
&omnibox::kDomainSuggestions,
"DomainSuggestionsTypedVisitCapPerVisit",
2);
const base::FeatureParam<int> kDomainSuggestionsMinInputLength(
&omnibox::kDomainSuggestions,
"DomainSuggestionsMinInputLength",
4);
const base::FeatureParam<int> kDomainSuggestionsMaxMatchesPerDomain(
&omnibox::kDomainSuggestions,
"DomainSuggestionsMaxMatchesPerDomain",
2);
const base::FeatureParam<double> kDomainSuggestionsScoreFactor(
&omnibox::kDomainSuggestions,
"DomainSuggestionsScoreFactor",
1);
const base::FeatureParam<bool> kDomainSuggestionsAlternativeScoring(
&omnibox::kDomainSuggestions,
"DomainSuggestionsAlternativeScoring",
false);
const base::FeatureParam<bool> kEnableScoringSignalsAnnotatorsForLogging(
&omnibox::kLogUrlScoringSignals,
"enable_scoring_signals_annotators",
false);
const base::FeatureParam<bool> kEnableScoringSignalsAnnotatorsForMlScoring(
&omnibox::kMlUrlScoring,
"enable_scoring_signals_annotators_for_ml_scoring",
true);
const base::FeatureParam<bool> kMlUrlScoringCounterfactual(
&omnibox::kMlUrlScoring,
"MlUrlScoringCounterfactual",
false);
const base::FeatureParam<bool> kMlUrlScoringUnlimitedNumCandidates(
&omnibox::kMlUrlScoring,
"MlUrlScoringUnlimitedNumCandidates",
false);
const base::FeatureParam<std::string> kMlUrlScoringMaxMatchesByProvider(
&omnibox::kMlUrlScoring,
"MlUrlScoringMaxMatchesByProvider",
"");
MLConfig::MLConfig() { … }
MLConfig::~MLConfig() = default;
MLConfig::MLConfig(const MLConfig&) = default;
MLConfig& MLConfig::operator=(const MLConfig& other) = default;
ScopedMLConfigForTesting::ScopedMLConfigForTesting()
: … { … }
ScopedMLConfigForTesting::~ScopedMLConfigForTesting() { … }
MLConfig& ScopedMLConfigForTesting::GetMLConfig() { … }
const MLConfig& GetMLConfig() { … }
bool IsReportingUrlScoringSignalsEnabled() { … }
bool IsPopulatingUrlScoringSignalsEnabled() { … }
bool AreScoringSignalsAnnotatorsEnabled() { … }
bool IsMlUrlScoringEnabled() { … }
bool IsMlUrlScoringCounterfactual() { … }
bool IsMlUrlScoringUnlimitedNumCandidatesEnabled() { … }
bool IsUrlScoringModelEnabled() { … }
bool IsMlUrlScoreCachingEnabled() { … }
std::vector<std::pair<double, int>> GetPiecewiseMappingBreakPoints(
PiecewiseMappingVariant mapping_variant) { … }
const base::FeatureParam<int>
kTouchDownTriggerForPrefetchMaxPrefetchesPerOmniboxSession(
&omnibox::kOmniboxTouchDownTriggerForPrefetch,
"max_prefetches_per_omnibox_session",
5);
const base::FeatureParam<std::string> kGeminiUrlOverride(
&omnibox::kStarterPackExpansion,
"StarterPackGeminiUrlOverride",
"https://gemini.google.com/prompt");
bool IsStarterPackExpansionEnabled() { … }
bool IsStarterPackIPHEnabled() { … }
bool IsFeaturedEnterpriseSearchIPHEnabled() { … }
}
std::string OmniboxFieldTrial::internal::GetValueForRuleInContext(
const std::string& rule,
OmniboxEventProto::PageClassification page_classification) { … }
std::string OmniboxFieldTrial::internal::GetValueForRuleInContextByFeature(
const base::Feature& feature,
const std::string& rule,
metrics::OmniboxEventProto::PageClassification page_classification) { … }