Commit 3f7a769a authored by Moe Ahmadi's avatar Moe Ahmadi Committed by Commit Bot

Enables NTP realbox if configured for ZPS via omnibox::kOnFocusSuggestions

Enables NTP realbox if omnibox::kOnFocusSuggestions is enabled and
configured to show zero-prefix suggestions of some type in the NTP Realbox.

Bug: 996516
Change-Id: Idcaf394feda35b2903df267baa87764755f79211
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1837073
Commit-Queue: Moe Ahmadi <mahmadi@chromium.org>
Auto-Submit: Moe Ahmadi <mahmadi@chromium.org>
Reviewed-by: default avatarDan Beam <dbeam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#702539}
parent 178faf76
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/feature_list.h" #include "base/feature_list.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "components/omnibox/browser/omnibox_field_trial.h"
#include "components/omnibox/common/omnibox_features.h" #include "components/omnibox/common/omnibox_features.h"
#include "ui/base/ui_base_features.h" #include "ui/base/ui_base_features.h"
...@@ -41,7 +42,11 @@ const base::Feature kNtpRealbox{"NtpRealbox", ...@@ -41,7 +42,11 @@ const base::Feature kNtpRealbox{"NtpRealbox",
bool IsNtpRealboxEnabled() { bool IsNtpRealboxEnabled() {
return base::FeatureList::IsEnabled(kNtpRealbox) || return base::FeatureList::IsEnabled(kNtpRealbox) ||
base::FeatureList::IsEnabled(omnibox::kZeroSuggestionsOnNTPRealbox); base::FeatureList::IsEnabled(omnibox::kZeroSuggestionsOnNTPRealbox) ||
(base::FeatureList::IsEnabled(omnibox::kOnFocusSuggestions) &&
!OmniboxFieldTrial::GetZeroSuggestVariants(
metrics::OmniboxEventProto::NTP_REALBOX)
.empty());
} }
// If enabled, "middle slot" promos on the bottom of the NTP will show a dismiss // If enabled, "middle slot" promos on the bottom of the NTP will show a dismiss
......
...@@ -23,7 +23,8 @@ extern const base::Feature kFirstRunDefaultSearchShortcut; ...@@ -23,7 +23,8 @@ extern const base::Feature kFirstRunDefaultSearchShortcut;
extern const base::Feature kNtpRealbox; extern const base::Feature kNtpRealbox;
// Returns true if either kNtpRealbox or omnibox::kZeroSuggestionsOnNTPRealbox // Returns true if either kNtpRealbox or omnibox::kZeroSuggestionsOnNTPRealbox
// are enabled. // are enabled; or omnibox::kOnFocusSuggestions is enabled and configured to
// show suggestions of some type in the NTP Realbox.
bool IsNtpRealboxEnabled(); bool IsNtpRealboxEnabled();
extern const base::Feature kDismissNtpPromos; extern const base::Feature kDismissNtpPromos;
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/search/ntp_features.h"
#include <map>
#include <vector>
#include "base/test/scoped_feature_list.h"
#include "components/omnibox/common/omnibox_features.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace features {
TEST(NTPFeaturesTest, IsNtpRealboxEnabled) {
base::test::ScopedFeatureList feature_list;
EXPECT_FALSE(IsNtpRealboxEnabled());
feature_list.InitAndEnableFeature(kNtpRealbox);
EXPECT_TRUE(IsNtpRealboxEnabled());
feature_list.Reset();
EXPECT_FALSE(IsNtpRealboxEnabled());
feature_list.InitAndEnableFeature(omnibox::kZeroSuggestionsOnNTPRealbox);
EXPECT_TRUE(IsNtpRealboxEnabled());
feature_list.Reset();
EXPECT_FALSE(IsNtpRealboxEnabled());
// zero-prefix suggestions are configured for the NTP Omnibox.
feature_list.InitWithFeaturesAndParameters(
{{omnibox::kOnFocusSuggestions,
{{"ZeroSuggestVariant:7:*", "Does not matter"}}}},
{});
EXPECT_FALSE(IsNtpRealboxEnabled());
feature_list.Reset();
EXPECT_FALSE(IsNtpRealboxEnabled());
// zero-prefix suggestions are configured for the NTP Realbox.
feature_list.InitWithFeaturesAndParameters(
{{omnibox::kOnFocusSuggestions,
{{"ZeroSuggestVariant:15:*", "Does not matter"}}}},
{});
EXPECT_TRUE(IsNtpRealboxEnabled());
}
} // namespace features
...@@ -3945,6 +3945,9 @@ test("unit_tests") { ...@@ -3945,6 +3945,9 @@ test("unit_tests") {
# Android uses different way of showing feedback page # Android uses different way of showing feedback page
"../browser/feedback/show_feedback_page_unittest.cc", "../browser/feedback/show_feedback_page_unittest.cc",
# NTP is in native code on Android.
"../browser/search/ntp_features_unittest.cc",
] ]
if (is_posix || is_fuchsia) { if (is_posix || is_fuchsia) {
sources += [ "../browser/process_singleton_posix_unittest.cc" ] sources += [ "../browser/process_singleton_posix_unittest.cc" ]
......
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