[Cleanup] Remove unnecessay IPH suppress in runtime (#36083)
Resolves - simple cleanup issue. We can set disable kIPHSideBySidePinnableFeature/kIPHSideBySideTabSwitchFeature as default state. Don't need to suppress them in rumtime. All deleted and add state overriding to chromium_src/components/feature_engagement/public/feature_constants.cc It was added by #32937
This commit is contained in:
@@ -144,6 +144,8 @@ TEST(FeatureDefaultsTest, DisabledFeatures) {
|
||||
&feature_engagement::kIPHDiscardRingFeature,
|
||||
&feature_engagement::kIPHGMCCastStartStopFeature,
|
||||
&feature_engagement::kIPHPasswordsManagementBubbleAfterSaveFeature,
|
||||
&feature_engagement::kIPHSideBySidePinnableFeature,
|
||||
&feature_engagement::kIPHSideBySideTabSwitchFeature,
|
||||
&feature_engagement::kIPHTabSearchToolbarButtonFeature,
|
||||
#endif
|
||||
&features::kBookmarkTriggerForPrefetch,
|
||||
|
||||
@@ -47,11 +47,6 @@
|
||||
#include "brave/components/ai_chat/core/common/features.h"
|
||||
#endif
|
||||
|
||||
#if !BUILDFLAG(IS_ANDROID)
|
||||
#include "brave/browser/user_education/brave_user_education_utils.h"
|
||||
#include "chrome/browser/user_education/user_education_service_factory.h"
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(ENABLE_BRAVE_ADS)
|
||||
#include "brave/browser/brave_ads/ads_service_factory.h"
|
||||
#endif // BUILDFLAG(ENABLE_BRAVE_ADS)
|
||||
@@ -200,13 +195,6 @@ void BraveProfileManager::DoFinalInitForServices(Profile* profile,
|
||||
return;
|
||||
}
|
||||
|
||||
#if !BUILDFLAG(IS_ANDROID)
|
||||
// Suppress user education elements (New badges and IPH promos) for features
|
||||
// that Brave doesn't want to promote.
|
||||
brave::SuppressUserEducation(
|
||||
UserEducationServiceFactory::GetForBrowserContext(profile));
|
||||
#endif
|
||||
|
||||
perf::MaybeEnableBraveFeaturesServicesAndComponentsForPerfTesting(profile);
|
||||
#if BUILDFLAG(ENABLE_BRAVE_ADS)
|
||||
brave_ads::AdsServiceFactory::GetForProfile(profile);
|
||||
|
||||
@@ -13,12 +13,3 @@ brave_browser_profiles_sources = [
|
||||
"//brave/browser/profiles/brave_renderer_updater_factory.cc",
|
||||
"//brave/browser/profiles/brave_renderer_updater_factory.h",
|
||||
]
|
||||
|
||||
brave_browser_profiles_deps = []
|
||||
|
||||
if (!is_android) {
|
||||
brave_browser_profiles_deps += [
|
||||
"//brave/browser/user_education",
|
||||
"//chrome/browser/user_education",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -754,7 +754,6 @@ brave_chrome_browser_deps += brave_browser_net_deps
|
||||
brave_chrome_browser_deps += brave_browser_new_tab_deps
|
||||
brave_chrome_browser_deps += brave_browser_perf_deps
|
||||
brave_chrome_browser_deps += brave_browser_permissions_deps
|
||||
brave_chrome_browser_deps += brave_browser_profiles_deps
|
||||
brave_chrome_browser_deps += brave_browser_renderer_context_menu_deps
|
||||
brave_chrome_browser_deps += brave_browser_request_otr_deps
|
||||
brave_chrome_browser_deps += brave_browser_search_engines_deps
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
# Copyright (c) 2024 The Brave Authors. All rights reserved.
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
# You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
source_set("user_education") {
|
||||
sources = [
|
||||
"brave_user_education_utils.cc",
|
||||
"brave_user_education_utils.h",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//base",
|
||||
"//chrome/browser/ui:ui_features",
|
||||
"//chrome/browser/user_education",
|
||||
"//components/feature_engagement/public",
|
||||
"//components/user_education/common",
|
||||
]
|
||||
}
|
||||
|
||||
source_set("unit_tests") {
|
||||
testonly = true
|
||||
|
||||
sources = [ "brave_user_education_utils_unittest.cc" ]
|
||||
|
||||
deps = [
|
||||
":user_education",
|
||||
"//base",
|
||||
"//base/test:test_support",
|
||||
"//chrome/browser",
|
||||
"//chrome/browser/ui:ui_features",
|
||||
"//chrome/browser/user_education",
|
||||
"//chrome/test:test_support",
|
||||
"//components/feature_engagement/public",
|
||||
"//components/user_education/common",
|
||||
"//components/user_education/test",
|
||||
"//content/test:test_support",
|
||||
"//testing/gmock",
|
||||
"//testing/gtest",
|
||||
]
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/* Copyright (c) 2025 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "brave/browser/user_education/brave_user_education_utils.h"
|
||||
|
||||
#include "chrome/browser/ui/ui_features.h"
|
||||
#include "chrome/browser/user_education/user_education_service.h"
|
||||
#include "components/feature_engagement/public/feature_constants.h"
|
||||
#include "components/user_education/common/user_education_data.h"
|
||||
#include "components/user_education/common/user_education_storage_service.h"
|
||||
|
||||
namespace brave {
|
||||
|
||||
void SuppressUserEducation(UserEducationService* service) {
|
||||
if (!service) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto& storage_service = service->user_education_storage_service();
|
||||
|
||||
// Suppress IPH (In Product Help) promos for below features by marking
|
||||
// them as dismissed.
|
||||
const base::Feature* promos_to_suppress[] = {
|
||||
&feature_engagement::kIPHSideBySidePinnableFeature,
|
||||
&feature_engagement::kIPHSideBySideTabSwitchFeature,
|
||||
};
|
||||
|
||||
for (const auto* feature : promos_to_suppress) {
|
||||
user_education::FeaturePromoData data;
|
||||
auto existing = storage_service.ReadPromoData(*feature);
|
||||
if (existing) {
|
||||
data = *existing;
|
||||
}
|
||||
data.is_dismissed = true;
|
||||
data.last_dismissed_by = user_education::FeaturePromoClosedReason::kDismiss;
|
||||
if (data.last_show_time.is_null()) {
|
||||
data.last_show_time = storage_service.GetCurrentTime();
|
||||
}
|
||||
storage_service.SavePromoData(*feature, data);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace brave
|
||||
@@ -1,19 +0,0 @@
|
||||
/* Copyright (c) 2025 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef BRAVE_BROWSER_USER_EDUCATION_BRAVE_USER_EDUCATION_UTILS_H_
|
||||
#define BRAVE_BROWSER_USER_EDUCATION_BRAVE_USER_EDUCATION_UTILS_H_
|
||||
|
||||
class UserEducationService;
|
||||
|
||||
namespace brave {
|
||||
|
||||
// Suppresses user education elements (New badges and IPH promos) for features
|
||||
// that Brave doesn't want to promote. Called during profile initialization.
|
||||
void SuppressUserEducation(UserEducationService* service);
|
||||
|
||||
} // namespace brave
|
||||
|
||||
#endif // BRAVE_BROWSER_USER_EDUCATION_BRAVE_USER_EDUCATION_UTILS_H_
|
||||
@@ -1,132 +0,0 @@
|
||||
/* Copyright (c) 2025 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "brave/browser/user_education/brave_user_education_utils.h"
|
||||
|
||||
#include "base/test/scoped_feature_list.h"
|
||||
#include "chrome/browser/ui/ui_features.h"
|
||||
#include "chrome/browser/user_education/user_education_service.h"
|
||||
#include "chrome/test/base/testing_profile.h"
|
||||
#include "components/feature_engagement/public/feature_constants.h"
|
||||
#include "components/user_education/common/feature_promo/feature_promo_lifecycle.h"
|
||||
#include "components/user_education/common/feature_promo/feature_promo_result.h"
|
||||
#include "components/user_education/common/feature_promo/feature_promo_specification.h"
|
||||
#include "components/user_education/common/new_badge/new_badge_policy.h"
|
||||
#include "components/user_education/common/user_education_data.h"
|
||||
#include "components/user_education/test/test_user_education_storage_service.h"
|
||||
#include "content/public/test/browser_task_environment.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
namespace brave {
|
||||
|
||||
class BraveUserEducationUtilsTest : public testing::Test {
|
||||
public:
|
||||
BraveUserEducationUtilsTest() = default;
|
||||
~BraveUserEducationUtilsTest() override = default;
|
||||
|
||||
void SetUp() override {
|
||||
// Enable the features we want to test
|
||||
feature_list_.InitWithFeatures(
|
||||
{feature_engagement::kIPHSideBySidePinnableFeature,
|
||||
feature_engagement::kIPHSideBySideTabSwitchFeature},
|
||||
{});
|
||||
profile_ = std::make_unique<TestingProfile>();
|
||||
service_ = std::make_unique<UserEducationService>(profile_.get(),
|
||||
/*allows_promos=*/true);
|
||||
}
|
||||
|
||||
protected:
|
||||
content::BrowserTaskEnvironment task_environment_;
|
||||
base::test::ScopedFeatureList feature_list_;
|
||||
std::unique_ptr<TestingProfile> profile_;
|
||||
std::unique_ptr<UserEducationService> service_;
|
||||
};
|
||||
|
||||
TEST_F(BraveUserEducationUtilsTest, HandlesNullService) {
|
||||
// Should not crash with null service
|
||||
SuppressUserEducation(nullptr);
|
||||
// Test passes if no crash occurs
|
||||
}
|
||||
|
||||
TEST_F(BraveUserEducationUtilsTest, SuppressesIPHForSideBySidePinnableFeature) {
|
||||
auto& storage = service_->user_education_storage_service();
|
||||
|
||||
// Verify initial state - promo should not be dismissed
|
||||
auto initial_data =
|
||||
storage.ReadPromoData(feature_engagement::kIPHSideBySidePinnableFeature);
|
||||
EXPECT_FALSE(initial_data.has_value());
|
||||
|
||||
// Call the function to suppress promos
|
||||
SuppressUserEducation(service_.get());
|
||||
|
||||
// Verify promo data has been modified to suppress the promo
|
||||
auto suppressed_data =
|
||||
storage.ReadPromoData(feature_engagement::kIPHSideBySidePinnableFeature);
|
||||
|
||||
ASSERT_TRUE(suppressed_data.has_value());
|
||||
EXPECT_TRUE(suppressed_data->is_dismissed);
|
||||
}
|
||||
|
||||
TEST_F(BraveUserEducationUtilsTest,
|
||||
SuppressesIPHForSideBySideTabSwitchFeature) {
|
||||
auto& storage = service_->user_education_storage_service();
|
||||
|
||||
// Verify initial state - promo should not be dismissed
|
||||
auto initial_data =
|
||||
storage.ReadPromoData(feature_engagement::kIPHSideBySideTabSwitchFeature);
|
||||
EXPECT_FALSE(initial_data.has_value());
|
||||
|
||||
// Call the function to suppress promos
|
||||
SuppressUserEducation(service_.get());
|
||||
|
||||
// Verify promo data has been modified to suppress the promo
|
||||
auto suppressed_data =
|
||||
storage.ReadPromoData(feature_engagement::kIPHSideBySideTabSwitchFeature);
|
||||
|
||||
ASSERT_TRUE(suppressed_data.has_value());
|
||||
EXPECT_TRUE(suppressed_data->is_dismissed);
|
||||
}
|
||||
|
||||
TEST_F(BraveUserEducationUtilsTest, PromoShouldBePermanentlyDismissed) {
|
||||
SuppressUserEducation(service_.get());
|
||||
|
||||
auto& storage = service_->user_education_storage_service();
|
||||
|
||||
// Set profile creation time to the past to avoid new profile grace period.
|
||||
storage.set_profile_creation_time_for_testing(base::Time::Now() -
|
||||
base::Days(30));
|
||||
|
||||
// Create a lifecycle to verify CanShow() returns kPermanentlyDismissed.
|
||||
user_education::FeaturePromoLifecycle lifecycle(
|
||||
&storage,
|
||||
/*promo_key=*/"", &feature_engagement::kIPHSideBySidePinnableFeature,
|
||||
user_education::FeaturePromoSpecification::PromoType::kToast,
|
||||
user_education::FeaturePromoSpecification::PromoSubtype::kNormal,
|
||||
/*num_rotating_entries=*/0);
|
||||
|
||||
EXPECT_EQ(user_education::FeaturePromoResult::kPermanentlyDismissed,
|
||||
lifecycle.CanShow());
|
||||
}
|
||||
|
||||
TEST_F(BraveUserEducationUtilsTest, PromoBlockedByNewProfile) {
|
||||
// Don't suppress - just test that new profiles block promos.
|
||||
auto& storage = service_->user_education_storage_service();
|
||||
|
||||
// Profile creation time defaults to now (new profile).
|
||||
storage.set_profile_creation_time_for_testing(base::Time::Now());
|
||||
|
||||
user_education::FeaturePromoLifecycle lifecycle(
|
||||
&storage,
|
||||
/*promo_key=*/"", &feature_engagement::kIPHSideBySidePinnableFeature,
|
||||
user_education::FeaturePromoSpecification::PromoType::kToast,
|
||||
user_education::FeaturePromoSpecification::PromoSubtype::kNormal,
|
||||
/*num_rotating_entries=*/0);
|
||||
|
||||
// New profiles should block normal promos during grace period.
|
||||
EXPECT_EQ(user_education::FeaturePromoResult::kBlockedByNewProfile,
|
||||
lifecycle.CanShow());
|
||||
}
|
||||
|
||||
} // namespace brave
|
||||
@@ -25,6 +25,8 @@ OVERRIDE_FEATURE_DEFAULT_STATES({{
|
||||
{kIPHPasswordsManagementBubbleAfterSaveFeature,
|
||||
base::FEATURE_DISABLED_BY_DEFAULT},
|
||||
{kIPHPdfInkSignaturesFeature, base::FEATURE_DISABLED_BY_DEFAULT},
|
||||
{kIPHSideBySidePinnableFeature, base::FEATURE_DISABLED_BY_DEFAULT},
|
||||
{kIPHSideBySideTabSwitchFeature, base::FEATURE_DISABLED_BY_DEFAULT},
|
||||
{kIPHTabGroupsSaveV2IntroFeature, base::FEATURE_DISABLED_BY_DEFAULT},
|
||||
{kIPHTabSearchToolbarButtonFeature, base::FEATURE_DISABLED_BY_DEFAULT},
|
||||
#endif
|
||||
|
||||
@@ -506,7 +506,6 @@ test("brave_unit_tests") {
|
||||
"//brave/browser/ui/webui/settings:unit_tests",
|
||||
"//brave/browser/ui/webui/side_panel/customize_chrome:unit_tests",
|
||||
"//brave/browser/ui/whats_new:unit_test",
|
||||
"//brave/browser/user_education:unit_tests",
|
||||
"//brave/components/ai_chat/core/common/buildflags",
|
||||
"//brave/components/brave_shields/core/common:mojom",
|
||||
"//brave/components/brave_vpn/common/buildflags",
|
||||
|
||||
Reference in New Issue
Block a user