Skip to content

Commit

Permalink
Guarded vpn prefs
Browse files Browse the repository at this point in the history
also deleted vpn prefs handling from day zero manager as it's not
used now.
  • Loading branch information
simonhong committed Nov 10, 2024
1 parent e3a07a7 commit 0936793
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
6 changes: 5 additions & 1 deletion browser/brave_profile_prefs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "brave/components/brave_shields/content/browser/brave_shields_p3a.h"
#include "brave/components/brave_shields/core/common/pref_names.h"
#include "brave/components/brave_sync/brave_sync_prefs.h"
#include "brave/components/brave_vpn/common/buildflags/buildflags.h"
#include "brave/components/brave_wallet/browser/brave_wallet_prefs.h"
#include "brave/components/brave_wayback_machine/buildflags/buildflags.h"
#include "brave/components/brave_webtorrent/browser/buildflags/buildflags.h"
Expand Down Expand Up @@ -365,9 +366,12 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
registry->RegisterBooleanPref(kNewTabPageShowStats, true);
registry->RegisterBooleanPref(kNewTabPageShowRewards, true);
registry->RegisterBooleanPref(kNewTabPageShowBraveTalk, true);
registry->RegisterBooleanPref(kNewTabPageShowBraveVPN, true);
registry->RegisterBooleanPref(kNewTabPageHideAllWidgets, false);

#if BUILDFLAG(ENABLE_BRAVE_VPN)
registry->RegisterBooleanPref(kNewTabPageShowBraveVPN, true);
#endif

// Private New Tab Page
#if !BUILDFLAG(IS_ANDROID)
brave_private_new_tab::prefs::RegisterProfilePrefs(registry);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ void DayZeroBrowserUIExptManager::SetForDayZeroBrowserUI(Profile* profile) {
auto* prefs = profile->GetPrefs();
prefs->SetDefaultPrefValue(kNewTabPageShowRewards, base::Value(false));
prefs->SetDefaultPrefValue(kNewTabPageShowBraveTalk, base::Value(false));
prefs->SetDefaultPrefValue(kNewTabPageShowBraveVPN, base::Value(false));
prefs->SetDefaultPrefValue(kShowWalletIconOnToolbar, base::Value(false));
prefs->SetDefaultPrefValue(brave_rewards::prefs::kShowLocationBarButton,
base::Value(false));
Expand All @@ -144,7 +143,6 @@ void DayZeroBrowserUIExptManager::ResetForDayZeroBrowserUI(Profile* profile) {
auto* prefs = profile->GetPrefs();
prefs->SetDefaultPrefValue(kNewTabPageShowRewards, base::Value(true));
prefs->SetDefaultPrefValue(kNewTabPageShowBraveTalk, base::Value(true));
prefs->SetDefaultPrefValue(kNewTabPageShowBraveVPN, base::Value(true));
prefs->SetDefaultPrefValue(kShowWalletIconOnToolbar, base::Value(true));
prefs->SetDefaultPrefValue(ntp_background_images::prefs::
kNewTabPageShowSponsoredImagesBackgroundImage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class DayZeroBrowserUIExptTest : public testing::Test,
auto* prefs = profile->GetPrefs();
EXPECT_FALSE(prefs->GetBoolean(kNewTabPageShowRewards));
EXPECT_FALSE(prefs->GetBoolean(kNewTabPageShowBraveTalk));
EXPECT_FALSE(prefs->GetBoolean(kNewTabPageShowBraveVPN));
EXPECT_FALSE(prefs->GetBoolean(kShowWalletIconOnToolbar));
EXPECT_FALSE(
prefs->GetBoolean(ntp_background_images::prefs::
Expand All @@ -60,7 +59,6 @@ class DayZeroBrowserUIExptTest : public testing::Test,
auto* prefs = profile->GetPrefs();
EXPECT_TRUE(prefs->GetBoolean(kNewTabPageShowRewards));
EXPECT_TRUE(prefs->GetBoolean(kNewTabPageShowBraveTalk));
EXPECT_TRUE(prefs->GetBoolean(kNewTabPageShowBraveVPN));
EXPECT_TRUE(prefs->GetBoolean(kShowWalletIconOnToolbar));
EXPECT_TRUE(
prefs->GetBoolean(ntp_background_images::prefs::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "brave/components/brave_news/common/pref_names.h"
#include "brave/components/brave_perf_predictor/common/pref_names.h"
#include "brave/components/brave_search_conversion/pref_names.h"
#include "brave/components/brave_vpn/common/buildflags/buildflags.h"
#include "brave/components/constants/pref_names.h"
#include "brave/components/ntp_background_images/browser/url_constants.h"
#include "brave/components/ntp_background_images/browser/view_counter_service.h"
Expand Down Expand Up @@ -86,7 +87,9 @@ base::Value::Dict GetPreferencesDictionary(PrefService* prefs) {
prefs->GetBoolean(brave_news::prefs::kBraveNewsOptedIn));
pref_data.Set("hideAllWidgets", prefs->GetBoolean(kNewTabPageHideAllWidgets));
pref_data.Set("showBraveTalk", prefs->GetBoolean(kNewTabPageShowBraveTalk));
#if BUILDFLAG(ENABLE_BRAVE_VPN)
pref_data.Set("showBraveVPN", prefs->GetBoolean(kNewTabPageShowBraveVPN));
#endif
pref_data.Set(
"showSearchBox",
prefs->GetBoolean(brave_search_conversion::prefs::kShowNTPSearchBox));
Expand Down Expand Up @@ -330,11 +333,12 @@ void BraveNewTabMessageHandler::OnJavascriptAllowed() {
kNewTabPageShowBraveTalk,
base::BindRepeating(&BraveNewTabMessageHandler::OnPreferencesChanged,
base::Unretained(this)));
#if BUILDFLAG(ENABLE_BRAVE_VPN)
pref_change_registrar_.Add(
kNewTabPageShowBraveVPN,
base::BindRepeating(&BraveNewTabMessageHandler::OnPreferencesChanged,
base::Unretained(this)));

#endif
pref_change_registrar_.Add(
kNewTabPageHideAllWidgets,
base::BindRepeating(&BraveNewTabMessageHandler::OnPreferencesChanged,
Expand Down Expand Up @@ -458,8 +462,10 @@ void BraveNewTabMessageHandler::HandleSaveNewTabPagePref(
settings_key = kNewTabPageHideAllWidgets;
} else if (settings_key_input == "showBraveTalk") {
settings_key = kNewTabPageShowBraveTalk;
#if BUILDFLAG(ENABLE_BRAVE_VPN)
} else if (settings_key_input == "showBraveVPN") {
settings_key = kNewTabPageShowBraveVPN;
#endif
} else if (settings_key_input == "showSearchBox") {
settings_key = brave_search_conversion::prefs::kShowNTPSearchBox;
} else if (settings_key_input == "promptEnableSearchSuggestions") {
Expand Down

0 comments on commit 0936793

Please sign in to comment.