Skip to content

Commit

Permalink
Remove desktop changes for dayzero flag (uplift to 1.73.x) (#26563)
Browse files Browse the repository at this point in the history
Uplift of #26396 (squashed) to release
  • Loading branch information
brave-builds authored Nov 16, 2024
1 parent bc61dab commit c74c0a2
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 186 deletions.
23 changes: 0 additions & 23 deletions browser/day_zero_browser_ui_expt/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ source_set("unit_tests") {

deps = [
"//base",
"//brave/components/brave_news/common",
"//brave/components/brave_rewards/common",
"//brave/components/brave_wallet/browser:pref_names",
"//brave/components/ntp_background_images/browser",
"//brave/components/ntp_background_images/common",
"//brave/components/p3a",
"//chrome/browser/ui",
"//chrome/test:test_support",
Expand All @@ -26,21 +21,3 @@ source_set("unit_tests") {
"//testing/gtest",
]
}

source_set("browser_tests") {
testonly = true
defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]

sources = [ "day_zero_browser_ui_expt_browsertest.cc" ]

deps = [
"//base",
"//brave/components/brave_rewards/common",
"//chrome/browser",
"//chrome/browser:browser_process",
"//chrome/browser/ui",
"//chrome/test:test_support_ui",
"//components/prefs",
"//content/test:test_support",
]
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@
#include "brave/browser/brave_browser_features.h"
#include "brave/browser/brave_stats/first_run_util.h"
#include "brave/browser/day_zero_browser_ui_expt/pref_names.h"
#include "brave/components/brave_news/common/locales_helper.h"
#include "brave/components/brave_news/common/pref_names.h"
#include "brave/components/brave_rewards/common/pref_names.h"
#include "brave/components/brave_wallet/browser/pref_names.h"
#include "brave/components/constants/pref_names.h"
#include "brave/components/ntp_background_images/common/pref_names.h"
#include "brave/components/p3a/pref_names.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
Expand Down Expand Up @@ -117,41 +112,14 @@ void DayZeroBrowserUIExptManager::OnProfileManagerDestroying() {

void DayZeroBrowserUIExptManager::SetForDayZeroBrowserUI(Profile* profile) {
VLOG(2) << __func__ << " Update prefs for day zero expt.";

auto* prefs = profile->GetPrefs();
prefs->SetDefaultPrefValue(kNewTabPageShowRewards, base::Value(false));
prefs->SetDefaultPrefValue(kNewTabPageShowBraveTalk, base::Value(false));
prefs->SetDefaultPrefValue(kShowWalletIconOnToolbar, base::Value(false));
prefs->SetDefaultPrefValue(brave_rewards::prefs::kShowLocationBarButton,
base::Value(false));
bool should_show_ntp_si_and_news = false;
#if BUILDFLAG(IS_ANDROID)
should_show_ntp_si_and_news = true;
Java_DayZeroHelper_setDayZeroExptAndroid(
base::android::AttachCurrentThread(), false);
#endif // #BUILDFLAG(IS_ANDROID)
prefs->SetDefaultPrefValue(ntp_background_images::prefs::
kNewTabPageShowSponsoredImagesBackgroundImage,
base::Value(should_show_ntp_si_and_news));
prefs->SetDefaultPrefValue(brave_news::prefs::kNewTabPageShowToday,
base::Value(should_show_ntp_si_and_news));
}

void DayZeroBrowserUIExptManager::ResetForDayZeroBrowserUI(Profile* profile) {
VLOG(2) << __func__ << " Update prefs for day zero expt.";

auto* prefs = profile->GetPrefs();
prefs->SetDefaultPrefValue(kNewTabPageShowRewards, base::Value(true));
prefs->SetDefaultPrefValue(kNewTabPageShowBraveTalk, base::Value(true));
prefs->SetDefaultPrefValue(kShowWalletIconOnToolbar, base::Value(true));
prefs->SetDefaultPrefValue(ntp_background_images::prefs::
kNewTabPageShowSponsoredImagesBackgroundImage,
base::Value(true));
prefs->SetDefaultPrefValue(brave_rewards::prefs::kShowLocationBarButton,
base::Value(true));
prefs->SetDefaultPrefValue(
brave_news::prefs::kNewTabPageShowToday,
base::Value(brave_news::IsUserInDefaultEnabledLocale()));
#if BUILDFLAG(IS_ANDROID)
Java_DayZeroHelper_setDayZeroExptAndroid(
base::android::AttachCurrentThread(), true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@
#include "base/test/scoped_feature_list.h"
#include "brave/browser/brave_browser_features.h"
#include "brave/browser/day_zero_browser_ui_expt/day_zero_browser_ui_expt_manager.h"
#include "brave/components/brave_news/common/locales_helper.h"
#include "brave/components/brave_news/common/pref_names.h"
#include "brave/components/brave_rewards/common/pref_names.h"
#include "brave/components/brave_wallet/browser/pref_names.h"
#include "brave/components/constants/pref_names.h"
#include "brave/components/ntp_background_images/browser/view_counter_service.h"
#include "brave/components/ntp_background_images/common/pref_names.h"
#include "brave/components/p3a/p3a_service.h"
#include "brave/components/p3a/pref_names.h"
#include "chrome/browser/profiles/profile_manager_observer.h"
Expand Down Expand Up @@ -42,32 +36,9 @@ class DayZeroBrowserUIExptTest : public testing::Test,
}
}

void CheckBrowserHasDayZeroUI(Profile* profile) {
auto* prefs = profile->GetPrefs();
EXPECT_FALSE(prefs->GetBoolean(kNewTabPageShowRewards));
EXPECT_FALSE(prefs->GetBoolean(kNewTabPageShowBraveTalk));
EXPECT_FALSE(prefs->GetBoolean(kShowWalletIconOnToolbar));
EXPECT_FALSE(
prefs->GetBoolean(ntp_background_images::prefs::
kNewTabPageShowSponsoredImagesBackgroundImage));
EXPECT_FALSE(
prefs->GetBoolean(brave_rewards::prefs::kShowLocationBarButton));
EXPECT_FALSE(prefs->GetBoolean(brave_news::prefs::kNewTabPageShowToday));
}

void CheckBrowserHasOriginalUI(Profile* profile) {
auto* prefs = profile->GetPrefs();
EXPECT_TRUE(prefs->GetBoolean(kNewTabPageShowRewards));
EXPECT_TRUE(prefs->GetBoolean(kNewTabPageShowBraveTalk));
EXPECT_TRUE(prefs->GetBoolean(kShowWalletIconOnToolbar));
EXPECT_TRUE(
prefs->GetBoolean(ntp_background_images::prefs::
kNewTabPageShowSponsoredImagesBackgroundImage));
EXPECT_TRUE(
prefs->GetBoolean(brave_rewards::prefs::kShowLocationBarButton));
EXPECT_EQ(prefs->GetBoolean(brave_news::prefs::kNewTabPageShowToday),
brave_news::IsUserInDefaultEnabledLocale());
}
// Keeping below methods empty to add future features and test
void CheckBrowserHasDayZeroUI(Profile* profile) {}
void CheckBrowserHasOriginalUI(Profile* profile) {}

bool IsDayZeroEnabled() { return GetParam(); }

Expand All @@ -85,6 +56,7 @@ TEST_P(DayZeroBrowserUIExptTest, PrefsTest) {
auto* profile2 =
testing_profile_manager_.CreateTestingProfile("TestProfile2");

// Add check for DayZero prefs here
if (IsDayZeroEnabled()) {
CheckBrowserHasDayZeroUI(profile);
CheckBrowserHasDayZeroUI(profile2);
Expand Down
1 change: 0 additions & 1 deletion test/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,6 @@ test("brave_browser_tests") {

if (is_win) {
public_configs = [ "//build/config/win:delayloads" ]
deps += [ "//brave/browser/day_zero_browser_ui_expt:browser_tests" ]
}

if (use_aura) {
Expand Down

0 comments on commit c74c0a2

Please sign in to comment.