Commit f6cdd7d7 authored by Moe Ahmadi's avatar Moe Ahmadi Committed by Commit Bot

[Omnibox] Adds feature to disable local ZPS for signed-in users

Fixed: 1136649
Change-Id: Ie48f7b52c40fd040a23b16c63ec0bb970c8585b0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2463804
Commit-Queue: Moe Ahmadi <mahmadi@chromium.org>
Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#815865}
parent c1af0912
...@@ -108,6 +108,12 @@ void LocalHistoryZeroSuggestProvider::Start(const AutocompleteInput& input, ...@@ -108,6 +108,12 @@ void LocalHistoryZeroSuggestProvider::Start(const AutocompleteInput& input,
done_ = true; done_ = true;
matches_.clear(); matches_.clear();
if (!base::FeatureList::IsEnabled(
omnibox::kOmniboxLocalZeroSuggestForAuthenticatedUsers) &&
client_->IsAuthenticated()) {
return;
}
// Allow local history query suggestions only when the user is not in an // Allow local history query suggestions only when the user is not in an
// off-the-record context. // off-the-record context.
if (client_->IsOffTheRecord()) if (client_->IsOffTheRecord())
......
...@@ -245,14 +245,13 @@ TEST_F(LocalHistoryZeroSuggestProviderTest, Input) { ...@@ -245,14 +245,13 @@ TEST_F(LocalHistoryZeroSuggestProviderTest, Input) {
"Omnibox.LocalHistoryZeroSuggest.AsyncDeleteTime", 0); "Omnibox.LocalHistoryZeroSuggest.AsyncDeleteTime", 0);
} }
// Tests that suggestions are returned only user is not in an off-the-record // Tests that suggestions are returned only if user is not in an off-the-record
// context, regardless of the user's authentication state. // context.
TEST_F(LocalHistoryZeroSuggestProviderTest, Incognito) { TEST_F(LocalHistoryZeroSuggestProviderTest, Incognito) {
LoadURLs({ LoadURLs({
{default_search_provider(), "hello world", "&foo=bar", 1}, {default_search_provider(), "hello world", "&foo=bar", 1},
}); });
EXPECT_CALL(*client_.get(), IsAuthenticated()).Times(0);
EXPECT_CALL(*client_.get(), IsOffTheRecord()) EXPECT_CALL(*client_.get(), IsOffTheRecord())
.Times(2) .Times(2)
.WillOnce(testing::Return(true)) .WillOnce(testing::Return(true))
...@@ -265,6 +264,64 @@ TEST_F(LocalHistoryZeroSuggestProviderTest, Incognito) { ...@@ -265,6 +264,64 @@ TEST_F(LocalHistoryZeroSuggestProviderTest, Incognito) {
ExpectMatches({{"hello world", 500}}); ExpectMatches({{"hello world", 500}});
} }
// Tests that suggestions are returned regardless of the authentication state
// when omnibox::kOmniboxLocalZeroSuggestForAuthenticatedUsers is enabled.
#if defined(OS_IOS)
// Tests that enable additional features fail on iOS.
#define MAYBE_ZeroSuggestForAuthenticatedUsers_Enabled \
DISABLED_ZeroSuggestForAuthenticatedUsers_Enabled
#else
#define MAYBE_ZeroSuggestForAuthenticatedUsers_Enabled \
ZeroSuggestForAuthenticatedUsers_Enabled
#endif
TEST_F(LocalHistoryZeroSuggestProviderTest,
MAYBE_ZeroSuggestForAuthenticatedUsers_Enabled) {
LoadURLs({
{default_search_provider(), "hello world", "&foo=bar", 1},
});
scoped_feature_list_ = std::make_unique<base::test::ScopedFeatureList>();
scoped_feature_list_->InitAndEnableFeature(
omnibox::kOmniboxLocalZeroSuggestForAuthenticatedUsers);
EXPECT_CALL(*client_.get(), IsAuthenticated()).Times(0);
StartProviderAndWaitUntilDone();
ExpectMatches({{"hello world", 500}});
}
// Tests that suggestions are returned for signed-out users only when
// when omnibox::kOmniboxLocalZeroSuggestForAuthenticatedUsers is disabled.
#if defined(OS_IOS)
// Tests that enable additional features fail on iOS.
#define MAYBE_ZeroSuggestForAuthenticatedUsers_Disabled \
DISABLED_ZeroSuggestForAuthenticatedUsers_Disabled
#else
#define MAYBE_ZeroSuggestForAuthenticatedUsers_Disabled \
ZeroSuggestForAuthenticatedUsers_Disabled
#endif
TEST_F(LocalHistoryZeroSuggestProviderTest,
MAYBE_ZeroSuggestForAuthenticatedUsers_Disabled) {
LoadURLs({
{default_search_provider(), "hello world", "&foo=bar", 1},
});
scoped_feature_list_ = std::make_unique<base::test::ScopedFeatureList>();
scoped_feature_list_->InitAndDisableFeature(
omnibox::kOmniboxLocalZeroSuggestForAuthenticatedUsers);
EXPECT_CALL(*client_.get(), IsAuthenticated())
.Times(2)
.WillOnce(testing::Return(true))
.WillOnce(testing::Return(false));
StartProviderAndWaitUntilDone();
ExpectMatches({});
StartProviderAndWaitUntilDone();
ExpectMatches({{"hello world", 500}});
}
// Tests that suggestions are returned only if FeatureFlags is configured // Tests that suggestions are returned only if FeatureFlags is configured
// to return local history suggestions in the NTP. // to return local history suggestions in the NTP.
#if defined(OS_IOS) #if defined(OS_IOS)
......
...@@ -203,6 +203,13 @@ const base::Feature kClobberTriggersContextualWebZeroSuggest{ ...@@ -203,6 +203,13 @@ const base::Feature kClobberTriggersContextualWebZeroSuggest{
const base::Feature kOmniboxLocalZeroSuggestAgeThreshold{ const base::Feature kOmniboxLocalZeroSuggestAgeThreshold{
"OmniboxLocalZeroSuggestAgeThreshold", base::FEATURE_DISABLED_BY_DEFAULT}; "OmniboxLocalZeroSuggestAgeThreshold", base::FEATURE_DISABLED_BY_DEFAULT};
// If enabled, enables local zero-prefix suggestions for signed in users.
// Local zero-prefix suggestions are enabled for signed in users by default. We
// will be experimenting with DISABLING this behavior.
const base::Feature kOmniboxLocalZeroSuggestForAuthenticatedUsers{
"OmniboxLocalZeroSuggestForAuthenticatedUsers",
base::FEATURE_ENABLED_BY_DEFAULT};
// If enabled, ranks the local zero-prefix suggestions based on frecency // If enabled, ranks the local zero-prefix suggestions based on frecency
// (combined frequency and recency). // (combined frequency and recency).
const base::Feature kOmniboxLocalZeroSuggestFrecencyRanking{ const base::Feature kOmniboxLocalZeroSuggestFrecencyRanking{
......
...@@ -58,6 +58,7 @@ extern const base::Feature kBubbleUrlSuggestions; ...@@ -58,6 +58,7 @@ extern const base::Feature kBubbleUrlSuggestions;
// On-Focus Suggestions a.k.a. ZeroSuggest. // On-Focus Suggestions a.k.a. ZeroSuggest.
extern const base::Feature kClobberTriggersContextualWebZeroSuggest; extern const base::Feature kClobberTriggersContextualWebZeroSuggest;
extern const base::Feature kOmniboxLocalZeroSuggestAgeThreshold; extern const base::Feature kOmniboxLocalZeroSuggestAgeThreshold;
extern const base::Feature kOmniboxLocalZeroSuggestForAuthenticatedUsers;
extern const base::Feature kOmniboxLocalZeroSuggestFrecencyRanking; extern const base::Feature kOmniboxLocalZeroSuggestFrecencyRanking;
extern const base::Feature kOmniboxTrendingZeroPrefixSuggestionsOnNTP; extern const base::Feature kOmniboxTrendingZeroPrefixSuggestionsOnNTP;
extern const base::Feature kOnFocusSuggestionsContextualWeb; extern const base::Feature kOnFocusSuggestionsContextualWeb;
......
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