Commit 38288f76 authored by Moe Ahmadi's avatar Moe Ahmadi Committed by Commit Bot

[ZPS] Add new feature flag to enable Vasco suggestions in NTP alongside ZPS

Currently Vasco suggestions are disabled in NTP when ZPS is showing in NTP
Omnibox/Realbox. This CL add new feature flag that, once enabled, shows
Vasco suggestions in NTP while ZPS is showing.

Bug: 1063122
Change-Id: I927f3b29e7c5ae46d3a2250ed89f026a26e6c8f1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2111070
Commit-Queue: Moe Ahmadi <mahmadi@chromium.org>
Commit-Queue: Tibor Goldschwendt <tiborg@chromium.org>
Auto-Submit: Moe Ahmadi <mahmadi@chromium.org>
Reviewed-by: default avatarTibor Goldschwendt <tiborg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#751825}
parent 1156877e
...@@ -37,6 +37,11 @@ const base::Feature kRealboxUseGoogleGIcon{"NtpRealboxUseGoogleGIcon", ...@@ -37,6 +37,11 @@ const base::Feature kRealboxUseGoogleGIcon{"NtpRealboxUseGoogleGIcon",
// below the non-fake input ("realbox"). // below the non-fake input ("realbox").
const base::Feature kRealbox{"NtpRealbox", base::FEATURE_DISABLED_BY_DEFAULT}; const base::Feature kRealbox{"NtpRealbox", base::FEATURE_DISABLED_BY_DEFAULT};
// If enabled, shows Vasco suggestion chips in the NTP below fakebox/realbox
// despite other config.
const base::Feature kSearchSuggestChips{"SearchSuggestChips",
base::FEATURE_DISABLED_BY_DEFAULT};
// If enabled, the WebUI new tab page will load when a new tab is created // If enabled, the WebUI new tab page will load when a new tab is created
// instead of the local NTP. // instead of the local NTP.
const base::Feature kWebUI{"NtpWebUI", base::FEATURE_DISABLED_BY_DEFAULT}; const base::Feature kWebUI{"NtpWebUI", base::FEATURE_DISABLED_BY_DEFAULT};
......
...@@ -21,6 +21,8 @@ extern const base::Feature kWebUI; ...@@ -21,6 +21,8 @@ extern const base::Feature kWebUI;
// Note: only exposed for about:flags. Use IsNtpRealboxEnabled() instead. // Note: only exposed for about:flags. Use IsNtpRealboxEnabled() instead.
extern const base::Feature kRealbox; extern const base::Feature kRealbox;
extern const base::Feature kSearchSuggestChips;
// Returns true if either kRealbox or omnibox::kZeroSuggestionsOnNTPRealbox // Returns true if either kRealbox or omnibox::kZeroSuggestionsOnNTPRealbox
// are enabled; or omnibox::kOnFocusSuggestions is enabled and configured to // are enabled; or omnibox::kOnFocusSuggestions is enabled and configured to
// show suggestions of some type in the NTP Realbox. // show suggestions of some type in the NTP Realbox.
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search/ntp_features.h"
#include "chrome/browser/search/search.h" #include "chrome/browser/search/search.h"
#include "chrome/browser/search/search_suggest/search_suggest_loader.h" #include "chrome/browser/search/search_suggest/search_suggest_loader.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
...@@ -98,6 +99,9 @@ class SearchSuggestService::SigninObserver ...@@ -98,6 +99,9 @@ class SearchSuggestService::SigninObserver
// static // static
bool SearchSuggestService::IsEnabled() { bool SearchSuggestService::IsEnabled() {
if (base::FeatureList::IsEnabled(ntp_features::kSearchSuggestChips))
return true;
return !base::FeatureList::IsEnabled(omnibox::kZeroSuggestionsOnNTP) && return !base::FeatureList::IsEnabled(omnibox::kZeroSuggestionsOnNTP) &&
!base::FeatureList::IsEnabled(omnibox::kZeroSuggestionsOnNTPRealbox) && !base::FeatureList::IsEnabled(omnibox::kZeroSuggestionsOnNTPRealbox) &&
!(base::FeatureList::IsEnabled(omnibox::kOnFocusSuggestions) && !(base::FeatureList::IsEnabled(omnibox::kOnFocusSuggestions) &&
......
...@@ -10,13 +10,16 @@ ...@@ -10,13 +10,16 @@
#include "base/optional.h" #include "base/optional.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h" #include "base/test/task_environment.h"
#include "chrome/browser/search/ntp_features.h"
#include "chrome/browser/search/search_suggest/search_suggest_data.h" #include "chrome/browser/search/search_suggest/search_suggest_data.h"
#include "chrome/browser/search/search_suggest/search_suggest_loader.h" #include "chrome/browser/search/search_suggest/search_suggest_loader.h"
#include "chrome/browser/search_engines/template_url_service_factory.h" #include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "chrome/test/base/browser_with_test_window_test.h" #include "chrome/test/base/browser_with_test_window_test.h"
#include "chrome/test/base/search_test_utils.h" #include "chrome/test/base/search_test_utils.h"
#include "components/omnibox/common/omnibox_features.h"
#include "components/search_engines/template_url_service.h" #include "components/search_engines/template_url_service.h"
#include "components/signin/public/base/test_signin_client.h" #include "components/signin/public/base/test_signin_client.h"
#include "components/signin/public/identity_manager/identity_test_environment.h" #include "components/signin/public/identity_manager/identity_test_environment.h"
...@@ -140,6 +143,83 @@ class SearchSuggestServiceTest : public BrowserWithTestWindowTest { ...@@ -140,6 +143,83 @@ class SearchSuggestServiceTest : public BrowserWithTestWindowTest {
std::unique_ptr<SearchSuggestService> service_; std::unique_ptr<SearchSuggestService> service_;
}; };
TEST_F(SearchSuggestServiceTest, IsEnabled) {
constexpr char kRemoteSendUrl[] = "RemoteSendUrl";
constexpr char kRemoteNoUrlLocal[] = "RemoteNoUrl,Local";
{
// The service is enabled by default.
EXPECT_TRUE(SearchSuggestService::IsEnabled());
}
{
// Enabling omnibox::kZeroSuggestionsOnNTP disables the service.
base::test::ScopedFeatureList feature_list;
feature_list.InitWithFeatures({omnibox::kZeroSuggestionsOnNTP}, {});
EXPECT_FALSE(SearchSuggestService::IsEnabled());
}
{
// Enabling omnibox::kZeroSuggestionsOnNTPRealbox disables the service.
base::test::ScopedFeatureList feature_list;
feature_list.InitWithFeatures({omnibox::kZeroSuggestionsOnNTPRealbox}, {});
EXPECT_FALSE(SearchSuggestService::IsEnabled());
}
{
// Enabling omnibox::kOnFocusSuggestions for SERP does not disable the
// service.
base::test::ScopedFeatureList feature_list;
std::map<std::string, std::string> feature_params;
// Note: ZPS variant 6 is Search Engine Results Page.
feature_params["ZeroSuggestVariant:6:*"] = kRemoteSendUrl;
feature_list.InitWithFeaturesAndParameters(
{{omnibox::kOnFocusSuggestions, feature_params}}, {});
EXPECT_TRUE(SearchSuggestService::IsEnabled());
}
{
// Enabling omnibox::kOnFocusSuggestions for NTP Omnibox disables the
// service.
base::test::ScopedFeatureList feature_list;
std::map<std::string, std::string> feature_params;
// Note: ZPS variant 7 is NTP with Omnibox as starting focus.
feature_params["ZeroSuggestVariant:7:*"] = kRemoteNoUrlLocal;
feature_list.InitWithFeaturesAndParameters(
{{omnibox::kOnFocusSuggestions, feature_params}}, {});
EXPECT_FALSE(SearchSuggestService::IsEnabled());
}
{
// Enabling omnibox::kOnFocusSuggestions for NTP Realbox disables the
// service.
base::test::ScopedFeatureList feature_list;
std::map<std::string, std::string> feature_params;
// Note: ZPS variant 15 is NTP Realbox as starting focus.
feature_params["ZeroSuggestVariant:15:*"] = kRemoteNoUrlLocal;
feature_list.InitWithFeaturesAndParameters(
{{omnibox::kOnFocusSuggestions, feature_params}}, {});
EXPECT_FALSE(SearchSuggestService::IsEnabled());
}
{
// Disabling ntp_features::kSearchSuggestChips does not disable the service.
base::test::ScopedFeatureList feature_list;
feature_list.InitWithFeaturesAndParameters(
{}, {ntp_features::kSearchSuggestChips});
EXPECT_TRUE(SearchSuggestService::IsEnabled());
}
{
// Enabling ntp_features::kSearchSuggestChips enables the service despite
// the other config.
base::test::ScopedFeatureList feature_list;
std::map<std::string, std::string> feature_params;
// Note: ZPS variant 7 is NTP with Omnibox as starting focus.
feature_params["ZeroSuggestVariant:7:*"] = kRemoteNoUrlLocal;
// Note: ZPS variant 15 is NTP Realbox as starting focus.
feature_params["ZeroSuggestVariant:15:*"] = kRemoteNoUrlLocal;
feature_list.InitWithFeaturesAndParameters(
{{omnibox::kZeroSuggestionsOnNTP, {}},
{omnibox::kZeroSuggestionsOnNTPRealbox, {}},
{omnibox::kOnFocusSuggestions, feature_params}},
{ntp_features::kSearchSuggestChips});
EXPECT_FALSE(SearchSuggestService::IsEnabled());
}
}
TEST_F(SearchSuggestServiceTest, NoRefreshOnSignedOutRequest) { TEST_F(SearchSuggestServiceTest, NoRefreshOnSignedOutRequest) {
ASSERT_EQ(base::nullopt, service()->search_suggest_data()); ASSERT_EQ(base::nullopt, service()->search_suggest_data());
......
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