Commit 0801bc59 authored by Moe Ahmadi's avatar Moe Ahmadi Committed by Commit Bot

[Omnibox] Use rZPS dedicated Features to gate local zero-prefix suggestions

Note: In order to simplify ZeroSuggest congifs and avoid conflicts, we
are moving away from ZeroSuggestVariant. That means every ZeroSuggest
congif is gated with a dedicated Feature. See crrev.com/c/2128686

Since local ZPS has been launched in the NTP Omnibox on Desktop and
remote ZPS are expected to appear alongside local ZPS, local ZPS should
be gated with the same dedicated features used for remote rZPS.

Tested with the following command after deleting the ZeroSuggestVariant
entries in fieldtrial_testing_config.json:

out/Default/Chromium.app/Contents/MacOS/Chromium
--enable-features=OmniboxReactiveZeroSuggestionsOnNTPRealbox
--force-variation-ids=t3317462
--user-data-dir=tmp

Both local ZPS and remote rZPS work as expected in signed out and
signed in scenarios.

Change-Id: I6fde3e773e474bade294e71b5dc9f3f9c4c86f6d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2227121
Commit-Queue: Justin Donnelly <jdonnelly@chromium.org>
Reviewed-by: default avatarJustin Donnelly <jdonnelly@chromium.org>
Cr-Commit-Position: refs/heads/master@{#774491}
parent f2c8bbc3
......@@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/check.h"
#include "base/feature_list.h"
#include "base/i18n/case_conversion.h"
#include "base/metrics/histogram_macros.h"
#include "base/stl_util.h"
......@@ -32,6 +33,8 @@
#include "components/search_engines/template_url_service.h"
#include "url/gurl.h"
using metrics::OmniboxEventProto;
namespace {
// Default relevance for the LocalHistoryZeroSuggestProvider query suggestions.
......@@ -54,9 +57,30 @@ bool AllowLocalHistoryZeroSuggestSuggestions(const AutocompleteInput& input) {
#if defined(OS_ANDROID) // Default-enabled on Android.
return true;
#else
if (!base::FeatureList::IsEnabled(omnibox::kNewSearchFeatures))
return false;
const auto current_page_classification = input.current_page_classification();
// Reactive Zero-Prefix Suggestions (rZPS) and basically all remote ZPS on the
// NTP are expected to be displayed alongside local history zero-prefix
// suggestions. Enable local history ZPS if rZPS is enabled.
// NTP Omnibox.
if ((current_page_classification == OmniboxEventProto::NTP ||
current_page_classification ==
OmniboxEventProto::INSTANT_NTP_WITH_OMNIBOX_AS_STARTING_FOCUS) &&
base::FeatureList::IsEnabled(
omnibox::kReactiveZeroSuggestionsOnNTPOmnibox)) {
return true;
}
// NTP Realbox.
if (current_page_classification == OmniboxEventProto::NTP_REALBOX &&
base::FeatureList::IsEnabled(
omnibox::kReactiveZeroSuggestionsOnNTPRealbox)) {
return true;
}
return base::Contains(
OmniboxFieldTrial::GetZeroSuggestVariants(
input.current_page_classification()),
OmniboxFieldTrial::GetZeroSuggestVariants(current_page_classification),
LocalHistoryZeroSuggestProvider::kZeroSuggestLocalVariant);
#endif
}
......
......@@ -305,6 +305,43 @@ TEST_F(LocalHistoryZeroSuggestProviderTest, MAYBE_ZeroSuggestVariant) {
ExpectMatches({});
#endif
scoped_feature_list_ = std::make_unique<base::test::ScopedFeatureList>();
scoped_feature_list_->InitAndEnableFeature(
omnibox::kReactiveZeroSuggestionsOnNTPRealbox);
StartProviderAndWaitUntilDone();
ExpectMatches({{"hello world", 500}});
scoped_feature_list_ = std::make_unique<base::test::ScopedFeatureList>();
scoped_feature_list_->InitAndEnableFeature(
omnibox::kReactiveZeroSuggestionsOnNTPOmnibox);
StartProviderAndWaitUntilDone();
#if defined(OS_ANDROID) // Enabled by default.
ExpectMatches({{"hello world", 500}});
#else
ExpectMatches({});
#endif
StartProviderAndWaitUntilDone(
/*text=*/"", /*from_omnibox_focus=*/true,
/*page_classification=*/
metrics::OmniboxEventProto::INSTANT_NTP_WITH_OMNIBOX_AS_STARTING_FOCUS);
ExpectMatches({{"hello world", 500}});
// Make sure disabling omnibox::kNewSearchFeatures disables zero suggest.
scoped_feature_list_ = std::make_unique<base::test::ScopedFeatureList>();
scoped_feature_list_->InitWithFeatures(
{omnibox::kReactiveZeroSuggestionsOnNTPOmnibox},
{omnibox::kNewSearchFeatures});
StartProviderAndWaitUntilDone(
/*text=*/"", /*from_omnibox_focus=*/true,
/*page_classification=*/
metrics::OmniboxEventProto::INSTANT_NTP_WITH_OMNIBOX_AS_STARTING_FOCUS);
#if defined(OS_ANDROID) // Enabled by default.
ExpectMatches({{"hello world", 500}});
#else
ExpectMatches({});
#endif
SetZeroSuggestVariant(
metrics::OmniboxEventProto::NTP_REALBOX,
LocalHistoryZeroSuggestProvider::kZeroSuggestLocalVariant);
......
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