Commit f1e9d2ff authored by Dan Beam's avatar Dan Beam Committed by Commit Bot

Local NTP: move from generic features:: namespace to ntp_features::

Bug: None
Change-Id: I8b7f574b49b92a6221462fd1b1139d4ab168731b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1899007
Commit-Queue: Moe Ahmadi <mahmadi@chromium.org>
Reviewed-by: default avatarMoe Ahmadi <mahmadi@chromium.org>
Auto-Submit: Dan Beam <dbeam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712686}
parent f1f38b74
...@@ -3075,30 +3075,30 @@ const FeatureEntry kFeatureEntries[] = { ...@@ -3075,30 +3075,30 @@ const FeatureEntry kFeatureEntries[] = {
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
{"chrome-colors", flag_descriptions::kChromeColorsName, {"chrome-colors", flag_descriptions::kChromeColorsName,
flag_descriptions::kChromeColorsDescription, kOsDesktop, flag_descriptions::kChromeColorsDescription, kOsDesktop,
FEATURE_VALUE_TYPE(features::kChromeColors)}, FEATURE_VALUE_TYPE(ntp_features::kChromeColors)},
{"chrome-colors-custom-color-picker", {"chrome-colors-custom-color-picker",
flag_descriptions::kChromeColorsCustomColorPickerName, flag_descriptions::kChromeColorsCustomColorPickerName,
flag_descriptions::kChromeColorsCustomColorPickerDescription, kOsDesktop, flag_descriptions::kChromeColorsCustomColorPickerDescription, kOsDesktop,
FEATURE_VALUE_TYPE(features::kChromeColorsCustomColorPicker)}, FEATURE_VALUE_TYPE(ntp_features::kChromeColorsCustomColorPicker)},
{"ntp-confirm-suggestion-removals", {"ntp-confirm-suggestion-removals",
flag_descriptions::kNtpConfirmSuggestionRemovalsName, flag_descriptions::kNtpConfirmSuggestionRemovalsName,
flag_descriptions::kNtpConfirmSuggestionRemovalsDescription, kOsDesktop, flag_descriptions::kNtpConfirmSuggestionRemovalsDescription, kOsDesktop,
FEATURE_VALUE_TYPE(features::kConfirmNtpSuggestionRemovals)}, FEATURE_VALUE_TYPE(ntp_features::kConfirmSuggestionRemovals)},
{"ntp-customization-menu-v2", {"ntp-customization-menu-v2",
flag_descriptions::kNtpCustomizationMenuV2Name, flag_descriptions::kNtpCustomizationMenuV2Name,
flag_descriptions::kNtpCustomizationMenuV2Description, kOsDesktop, flag_descriptions::kNtpCustomizationMenuV2Description, kOsDesktop,
FEATURE_VALUE_TYPE(features::kNtpCustomizationMenuV2)}, FEATURE_VALUE_TYPE(ntp_features::kCustomizationMenuV2)},
{"ntp-dismiss-promos", flag_descriptions::kNtpDismissPromosName, {"ntp-dismiss-promos", flag_descriptions::kNtpDismissPromosName,
flag_descriptions::kNtpDismissPromosDescription, kOsDesktop, flag_descriptions::kNtpDismissPromosDescription, kOsDesktop,
FEATURE_VALUE_TYPE(features::kDismissNtpPromos)}, FEATURE_VALUE_TYPE(ntp_features::kDismissPromos)},
{"ntp-realbox", flag_descriptions::kNtpRealboxName, {"ntp-realbox", flag_descriptions::kNtpRealboxName,
flag_descriptions::kNtpRealboxDescription, kOsDesktop, flag_descriptions::kNtpRealboxDescription, kOsDesktop,
FEATURE_VALUE_TYPE(features::kNtpRealbox)}, FEATURE_VALUE_TYPE(ntp_features::kRealbox)},
{"webui-a11y-enhancements", flag_descriptions::kWebUIA11yEnhancementsName, {"webui-a11y-enhancements", flag_descriptions::kWebUIA11yEnhancementsName,
flag_descriptions::kWebUIA11yEnhancementsDescription, kOsDesktop, flag_descriptions::kWebUIA11yEnhancementsDescription, kOsDesktop,
......
...@@ -613,13 +613,14 @@ class LocalNtpSource::SearchConfigurationProvider ...@@ -613,13 +613,14 @@ class LocalNtpSource::SearchConfigurationProvider
if (is_google) { if (is_google) {
config_data.SetBoolean( config_data.SetBoolean(
"richerPicker", "richerPicker",
base::FeatureList::IsEnabled(features::kNtpCustomizationMenuV2)); base::FeatureList::IsEnabled(ntp_features::kCustomizationMenuV2));
config_data.SetBoolean("chromeColors", base::FeatureList::IsEnabled( config_data.SetBoolean("chromeColors", base::FeatureList::IsEnabled(
features::kChromeColors)); ntp_features::kChromeColors));
config_data.SetBoolean("chromeColorsCustomColorPicker", config_data.SetBoolean("chromeColorsCustomColorPicker",
base::FeatureList::IsEnabled( base::FeatureList::IsEnabled(
features::kChromeColorsCustomColorPicker)); ntp_features::kChromeColorsCustomColorPicker));
config_data.SetBoolean("realboxEnabled", features::IsNtpRealboxEnabled()); config_data.SetBoolean("realboxEnabled",
ntp_features::IsRealboxEnabled());
config_data.SetBoolean( config_data.SetBoolean(
"suggestionTransparencyEnabled", "suggestionTransparencyEnabled",
base::FeatureList::IsEnabled( base::FeatureList::IsEnabled(
...@@ -1033,12 +1034,12 @@ void LocalNtpSource::StartDataRequest( ...@@ -1033,12 +1034,12 @@ void LocalNtpSource::StartDataRequest(
"\" as=\"image\">"; "\" as=\"image\">";
} }
bool realbox_enabled = features::IsNtpRealboxEnabled(); bool realbox_enabled = ntp_features::IsRealboxEnabled();
replacements["hiddenIfRealboxEnabled"] = realbox_enabled ? "hidden" : ""; replacements["hiddenIfRealboxEnabled"] = realbox_enabled ? "hidden" : "";
replacements["hiddenIfRealboxDisabled"] = realbox_enabled ? "" : "hidden"; replacements["hiddenIfRealboxDisabled"] = realbox_enabled ? "" : "hidden";
bool use_google_g_icon = bool use_google_g_icon =
base::FeatureList::IsEnabled(features::kNtpRealboxUseGoogleGIcon); base::FeatureList::IsEnabled(ntp_features::kRealboxUseGoogleGIcon);
replacements["realboxIconClass"] = replacements["realboxIconClass"] =
use_google_g_icon ? "google-g-icon" : "search-icon"; use_google_g_icon ? "google-g-icon" : "search-icon";
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#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"
namespace features { namespace ntp_features {
// If enabled, 'Chrome Colors' menu becomes visible in the customization picker. // If enabled, 'Chrome Colors' menu becomes visible in the customization picker.
const base::Feature kChromeColors{"ChromeColors", const base::Feature kChromeColors{"ChromeColors",
...@@ -22,31 +22,30 @@ const base::Feature kChromeColorsCustomColorPicker{ ...@@ -22,31 +22,30 @@ const base::Feature kChromeColorsCustomColorPicker{
// If enabled, shows a confirm dialog before removing search suggestions from // If enabled, shows a confirm dialog before removing search suggestions from
// the New Tab page real search box ("realbox"). // the New Tab page real search box ("realbox").
const base::Feature kConfirmNtpSuggestionRemovals{ const base::Feature kConfirmSuggestionRemovals{
"ConfirmNtpSuggestionRemovals", base::FEATURE_DISABLED_BY_DEFAULT}; "ConfirmNtpSuggestionRemovals", base::FEATURE_DISABLED_BY_DEFAULT};
// If enabled, the user will see the second version of the customization picker.
const base::Feature kCustomizationMenuV2{"NtpCustomizationMenuV2",
base::FEATURE_DISABLED_BY_DEFAULT};
// 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
// UI that allows users to close them and not see them again. // UI that allows users to close them and not see them again.
const base::Feature kDismissNtpPromos{"DismissNtpPromos", const base::Feature kDismissPromos{"DismissNtpPromos",
base::FEATURE_DISABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
// If enabled, the user will see the second version of the customization picker.
const base::Feature kNtpCustomizationMenuV2{"NtpCustomizationMenuV2",
base::FEATURE_DISABLED_BY_DEFAULT};
// If enabled, the real search box ("realbox") on the New Tab page will show a // If enabled, the real search box ("realbox") on the New Tab page will show a
// Google (g) icon instead of the typical magnifying glass (aka loupe). // Google (g) icon instead of the typical magnifying glass (aka loupe).
const base::Feature kNtpRealboxUseGoogleGIcon{ const base::Feature kRealboxUseGoogleGIcon{"NtpRealboxUseGoogleGIcon",
"NtpRealboxUseGoogleGIcon", base::FEATURE_DISABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
// If enabled, the search box in the middle of the NTP will accept input // If enabled, the search box in the middle of the NTP will accept input
// directly (i.e. not be a "fake" box) and search results will show directly // directly (i.e. not be a "fake" box) and search results will show directly
// below the non-fake input ("realbox"). // below the non-fake input ("realbox").
const base::Feature kNtpRealbox{"NtpRealbox", const base::Feature kRealbox{"NtpRealbox", base::FEATURE_DISABLED_BY_DEFAULT};
base::FEATURE_DISABLED_BY_DEFAULT};
bool IsNtpRealboxEnabled() { bool IsRealboxEnabled() {
return base::FeatureList::IsEnabled(kNtpRealbox) || return base::FeatureList::IsEnabled(kRealbox) ||
base::FeatureList::IsEnabled(omnibox::kZeroSuggestionsOnNTPRealbox) || base::FeatureList::IsEnabled(omnibox::kZeroSuggestionsOnNTPRealbox) ||
(base::FeatureList::IsEnabled(omnibox::kOnFocusSuggestions) && (base::FeatureList::IsEnabled(omnibox::kOnFocusSuggestions) &&
!OmniboxFieldTrial::GetZeroSuggestVariants( !OmniboxFieldTrial::GetZeroSuggestVariants(
...@@ -54,4 +53,4 @@ bool IsNtpRealboxEnabled() { ...@@ -54,4 +53,4 @@ bool IsNtpRealboxEnabled() {
.empty()); .empty());
} }
} // namespace features } // namespace ntp_features
...@@ -7,26 +7,26 @@ ...@@ -7,26 +7,26 @@
#include "base/feature_list.h" #include "base/feature_list.h"
namespace features { namespace ntp_features {
// The features should be documented alongside the definition of their values in // The features should be documented alongside the definition of their values in
// the .cc file. // the .cc file.
extern const base::Feature kChromeColors; extern const base::Feature kChromeColors;
extern const base::Feature kChromeColorsCustomColorPicker; extern const base::Feature kChromeColorsCustomColorPicker;
extern const base::Feature kConfirmNtpSuggestionRemovals; extern const base::Feature kConfirmSuggestionRemovals;
extern const base::Feature kDismissNtpPromos; extern const base::Feature kCustomizationMenuV2;
extern const base::Feature kNtpCustomizationMenuV2; extern const base::Feature kDismissPromos;
extern const base::Feature kNtpRealboxUseGoogleGIcon; extern const base::Feature kRealboxUseGoogleGIcon;
// Note: only exposed for about:flags. Use IsNtpRealboxEnabled() instead. // Note: only exposed for about:flags. Use IsNtpRealboxEnabled() instead.
extern const base::Feature kNtpRealbox; extern const base::Feature kRealbox;
// Returns true if either kNtpRealbox 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.
bool IsNtpRealboxEnabled(); bool IsRealboxEnabled();
} // namespace features } // namespace ntp_features
#endif // CHROME_BROWSER_SEARCH_NTP_FEATURES_H_ #endif // CHROME_BROWSER_SEARCH_NTP_FEATURES_H_
...@@ -11,40 +11,40 @@ ...@@ -11,40 +11,40 @@
#include "components/omnibox/common/omnibox_features.h" #include "components/omnibox/common/omnibox_features.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace features { namespace ntp_features {
TEST(NTPFeaturesTest, IsNtpRealboxEnabled) { TEST(NTPFeaturesTest, IsRealboxEnabled) {
base::test::ScopedFeatureList feature_list; base::test::ScopedFeatureList feature_list;
EXPECT_FALSE(IsNtpRealboxEnabled()); EXPECT_FALSE(IsRealboxEnabled());
feature_list.InitAndEnableFeature(kNtpRealbox); feature_list.InitAndEnableFeature(kRealbox);
EXPECT_TRUE(IsNtpRealboxEnabled()); EXPECT_TRUE(IsRealboxEnabled());
feature_list.Reset(); feature_list.Reset();
EXPECT_FALSE(IsNtpRealboxEnabled()); EXPECT_FALSE(IsRealboxEnabled());
feature_list.InitAndEnableFeature(omnibox::kZeroSuggestionsOnNTPRealbox); feature_list.InitAndEnableFeature(omnibox::kZeroSuggestionsOnNTPRealbox);
EXPECT_TRUE(IsNtpRealboxEnabled()); EXPECT_TRUE(IsRealboxEnabled());
feature_list.Reset(); feature_list.Reset();
EXPECT_FALSE(IsNtpRealboxEnabled()); EXPECT_FALSE(IsRealboxEnabled());
// zero-prefix suggestions are configured for the NTP Omnibox. // zero-prefix suggestions are configured for the NTP Omnibox.
feature_list.InitWithFeaturesAndParameters( feature_list.InitWithFeaturesAndParameters(
{{omnibox::kOnFocusSuggestions, {{omnibox::kOnFocusSuggestions,
{{"ZeroSuggestVariant:7:*", "Does not matter"}}}}, {{"ZeroSuggestVariant:7:*", "Does not matter"}}}},
{}); {});
EXPECT_FALSE(IsNtpRealboxEnabled()); EXPECT_FALSE(IsRealboxEnabled());
feature_list.Reset(); feature_list.Reset();
EXPECT_FALSE(IsNtpRealboxEnabled()); EXPECT_FALSE(IsRealboxEnabled());
// zero-prefix suggestions are configured for the NTP Realbox. // zero-prefix suggestions are configured for the NTP Realbox.
feature_list.InitWithFeaturesAndParameters( feature_list.InitWithFeaturesAndParameters(
{{omnibox::kOnFocusSuggestions, {{omnibox::kOnFocusSuggestions,
{{"ZeroSuggestVariant:15:*", "Does not matter"}}}}, {{"ZeroSuggestVariant:15:*", "Does not matter"}}}},
{}); {});
EXPECT_TRUE(IsNtpRealboxEnabled()); EXPECT_TRUE(IsRealboxEnabled());
} }
} // namespace features } // namespace ntp_features
...@@ -41,7 +41,7 @@ const char kNewTabPromosApiPath[] = "/async/newtab_promos"; ...@@ -41,7 +41,7 @@ const char kNewTabPromosApiPath[] = "/async/newtab_promos";
const char kXSSIResponsePreamble[] = ")]}'"; const char kXSSIResponsePreamble[] = ")]}'";
bool CanBlockPromos() { bool CanBlockPromos() {
return base::FeatureList::IsEnabled(features::kDismissNtpPromos); return base::FeatureList::IsEnabled(ntp_features::kDismissPromos);
} }
GURL GetGoogleBaseUrl() { GURL GetGoogleBaseUrl() {
......
...@@ -157,7 +157,7 @@ TEST_F(PromoServiceTest, GoodPromoResponse) { ...@@ -157,7 +157,7 @@ TEST_F(PromoServiceTest, GoodPromoResponse) {
TEST_F(PromoServiceTest, GoodPromoResponseCanDismiss) { TEST_F(PromoServiceTest, GoodPromoResponseCanDismiss) {
base::test::ScopedFeatureList feature_list; base::test::ScopedFeatureList feature_list;
feature_list.InitAndEnableFeature(features::kDismissNtpPromos); feature_list.InitAndEnableFeature(ntp_features::kDismissPromos);
std::string response_string = std::string response_string =
"{\"update\":{\"promos\":{\"middle\":\"<style></style><div><script></" "{\"update\":{\"promos\":{\"middle\":\"<style></style><div><script></"
...@@ -180,7 +180,7 @@ TEST_F(PromoServiceTest, GoodPromoResponseCanDismiss) { ...@@ -180,7 +180,7 @@ TEST_F(PromoServiceTest, GoodPromoResponseCanDismiss) {
TEST_F(PromoServiceTest, GoodPromoResponseNoIdField) { TEST_F(PromoServiceTest, GoodPromoResponseNoIdField) {
base::test::ScopedFeatureList feature_list; base::test::ScopedFeatureList feature_list;
feature_list.InitAndEnableFeature(features::kDismissNtpPromos); feature_list.InitAndEnableFeature(ntp_features::kDismissPromos);
std::string response_string = std::string response_string =
"{\"update\":{\"promos\":{\"middle\":\"<style></style><div><script></" "{\"update\":{\"promos\":{\"middle\":\"<style></style><div><script></"
...@@ -203,7 +203,7 @@ TEST_F(PromoServiceTest, GoodPromoResponseNoIdField) { ...@@ -203,7 +203,7 @@ TEST_F(PromoServiceTest, GoodPromoResponseNoIdField) {
TEST_F(PromoServiceTest, GoodPromoResponseNoIdFieldNorLogUrl) { TEST_F(PromoServiceTest, GoodPromoResponseNoIdFieldNorLogUrl) {
base::test::ScopedFeatureList feature_list; base::test::ScopedFeatureList feature_list;
feature_list.InitAndEnableFeature(features::kDismissNtpPromos); feature_list.InitAndEnableFeature(ntp_features::kDismissPromos);
std::string response_string = std::string response_string =
"{\"update\":{\"promos\":{\"middle\":\"<style></style><div><script></" "{\"update\":{\"promos\":{\"middle\":\"<style></style><div><script></"
...@@ -224,7 +224,7 @@ TEST_F(PromoServiceTest, GoodPromoResponseNoIdFieldNorLogUrl) { ...@@ -224,7 +224,7 @@ TEST_F(PromoServiceTest, GoodPromoResponseNoIdFieldNorLogUrl) {
TEST_F(PromoServiceTest, GoodPromoWithBlockedID) { TEST_F(PromoServiceTest, GoodPromoWithBlockedID) {
base::test::ScopedFeatureList feature_list; base::test::ScopedFeatureList feature_list;
feature_list.InitAndEnableFeature(features::kDismissNtpPromos); feature_list.InitAndEnableFeature(ntp_features::kDismissPromos);
{ {
DictionaryPrefUpdate update(prefs(), prefs::kNtpPromoBlocklist); DictionaryPrefUpdate update(prefs(), prefs::kNtpPromoBlocklist);
...@@ -248,7 +248,7 @@ TEST_F(PromoServiceTest, GoodPromoWithBlockedID) { ...@@ -248,7 +248,7 @@ TEST_F(PromoServiceTest, GoodPromoWithBlockedID) {
TEST_F(PromoServiceTest, BlocklistPromo) { TEST_F(PromoServiceTest, BlocklistPromo) {
base::test::ScopedFeatureList feature_list; base::test::ScopedFeatureList feature_list;
feature_list.InitAndEnableFeature(features::kDismissNtpPromos); feature_list.InitAndEnableFeature(ntp_features::kDismissPromos);
std::string response_string = std::string response_string =
"{\"update\":{\"promos\":{\"middle\":\"<style></style><div><script></" "{\"update\":{\"promos\":{\"middle\":\"<style></style><div><script></"
...@@ -282,7 +282,7 @@ TEST_F(PromoServiceTest, BlocklistPromo) { ...@@ -282,7 +282,7 @@ TEST_F(PromoServiceTest, BlocklistPromo) {
TEST_F(PromoServiceTest, BlocklistExpiration) { TEST_F(PromoServiceTest, BlocklistExpiration) {
base::test::ScopedFeatureList feature_list; base::test::ScopedFeatureList feature_list;
feature_list.InitAndEnableFeature(features::kDismissNtpPromos); feature_list.InitAndEnableFeature(ntp_features::kDismissPromos);
{ {
DictionaryPrefUpdate update(prefs(), prefs::kNtpPromoBlocklist); DictionaryPrefUpdate update(prefs(), prefs::kNtpPromoBlocklist);
...@@ -316,7 +316,7 @@ TEST_F(PromoServiceTest, BlocklistExpiration) { ...@@ -316,7 +316,7 @@ TEST_F(PromoServiceTest, BlocklistExpiration) {
TEST_F(PromoServiceTest, BlocklistWrongExpiryType) { TEST_F(PromoServiceTest, BlocklistWrongExpiryType) {
base::test::ScopedFeatureList feature_list; base::test::ScopedFeatureList feature_list;
feature_list.InitAndEnableFeature(features::kDismissNtpPromos); feature_list.InitAndEnableFeature(ntp_features::kDismissPromos);
{ {
DictionaryPrefUpdate update(prefs(), prefs::kNtpPromoBlocklist); DictionaryPrefUpdate update(prefs(), prefs::kNtpPromoBlocklist);
......
...@@ -685,7 +685,7 @@ void SearchTabHelper::DeleteAutocompleteMatch( ...@@ -685,7 +685,7 @@ void SearchTabHelper::DeleteAutocompleteMatch(
return; return;
} }
if (!base::FeatureList::IsEnabled(features::kConfirmNtpSuggestionRemovals)) { if (!base::FeatureList::IsEnabled(ntp_features::kConfirmSuggestionRemovals)) {
// If suggestion transparency is disabled, the UI is also disabled. This // If suggestion transparency is disabled, the UI is also disabled. This
// must've come from a keyboard shortcut, which are allowed to remove // must've come from a keyboard shortcut, which are allowed to remove
// without confirmation. // without confirmation.
......
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