Commit 7b89f664 authored by manuk's avatar manuk Committed by Commit Bot

[omnibox] Support DemoteByTypeRule associated with a feature.

Previously, the DemoteByTypeRule was only usable if the params were set in the
OmniboxBundledExperimentV1 study. With this CL, a group in any study that
enables the OmniboxDemoteByType feature will also be able to set the params.

Bug: 264066
Change-Id: I7f0695f4cb71e46a7a533d240db2e91f105cda03
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1903665Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Commit-Queue: manuk hovanesian <manukh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713913}
parent ff51aa28
...@@ -281,9 +281,19 @@ void OmniboxFieldTrial::GetDemotionsByType( ...@@ -281,9 +281,19 @@ void OmniboxFieldTrial::GetDemotionsByType(
OmniboxEventProto::PageClassification current_page_classification, OmniboxEventProto::PageClassification current_page_classification,
DemotionMultipliers* demotions_by_type) { DemotionMultipliers* demotions_by_type) {
demotions_by_type->clear(); demotions_by_type->clear();
// Explicitly check whether the feature is enabled before calling
// |GetValueForRuleInContextByFeature| because it is possible for
// |GetValueForRuleInContextByFeature| to return an empty string even if the
// feature is enabled, and we don't want to fallback to
// |GetValueForRuleInContext| in this case.
std::string demotion_rule = std::string demotion_rule =
OmniboxFieldTrial::internal::GetValueForRuleInContext( base::FeatureList::IsEnabled(omnibox::kOmniboxDemoteByType)
kDemoteByTypeRule, current_page_classification); ? OmniboxFieldTrial::internal::GetValueForRuleInContextByFeature(
omnibox::kOmniboxDemoteByType, kDemoteByTypeRule,
current_page_classification)
: OmniboxFieldTrial::internal::GetValueForRuleInContext(
kDemoteByTypeRule, current_page_classification);
// If there is no demotion rule for this context, then use the default // If there is no demotion rule for this context, then use the default
// value for that context. // value for that context.
if (demotion_rule.empty()) { if (demotion_rule.empty()) {
......
...@@ -288,6 +288,12 @@ const base::Feature kOmniboxPreserveDefaultMatchAgainstAsyncUpdate{ ...@@ -288,6 +288,12 @@ const base::Feature kOmniboxPreserveDefaultMatchAgainstAsyncUpdate{
"OmniboxPreserveDefaultMatchAgainstAsyncUpdate", "OmniboxPreserveDefaultMatchAgainstAsyncUpdate",
base::FEATURE_DISABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
// Demotes the relevance scores when comparing suggestions based on the
// suggestion's |AutocompleteMatchType| and the user's |PageClassification|.
// This feature's main job is to contain the DemoteByType parameter.
const base::Feature kOmniboxDemoteByType{"OmniboxDemoteByType",
base::FEATURE_DISABLED_BY_DEFAULT};
// Feature to configure on-focus suggestions provided by ZeroSuggestProvider. // Feature to configure on-focus suggestions provided by ZeroSuggestProvider.
// This feature's main job is to contain some field trial parameters such as: // This feature's main job is to contain some field trial parameters such as:
// - "ZeroSuggestVariant" configures the per-page-classification mode of // - "ZeroSuggestVariant" configures the per-page-classification mode of
......
...@@ -53,6 +53,7 @@ extern const base::Feature kDebounceDocumentProvider; ...@@ -53,6 +53,7 @@ extern const base::Feature kDebounceDocumentProvider;
// TODO(tommycli): There are more flags above that belong in this category. // TODO(tommycli): There are more flags above that belong in this category.
extern const base::Feature kOmniboxPreserveDefaultMatchScore; extern const base::Feature kOmniboxPreserveDefaultMatchScore;
extern const base::Feature kOmniboxPreserveDefaultMatchAgainstAsyncUpdate; extern const base::Feature kOmniboxPreserveDefaultMatchAgainstAsyncUpdate;
extern const base::Feature kOmniboxDemoteByType;
// On-Focus Suggestions a.k.a. ZeroSuggest. // On-Focus Suggestions a.k.a. ZeroSuggest.
extern const base::Feature kOnFocusSuggestions; extern const base::Feature kOnFocusSuggestions;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment