diff --git a/app/brave_generated_resources.grd b/app/brave_generated_resources.grd index 8c1dace9784..733833bc39a 100644 --- a/app/brave_generated_resources.grd +++ b/app/brave_generated_resources.grd @@ -282,33 +282,9 @@ By installing this extension, you are agreeing to the Google Widevine Terms of U New Tab Page - - Background images - - - Sponsored images - - - Brave Stats - Brave Rewards - - Brave Together - - - Binance - - - Gemini - - - Top Sites - - - Clock - New tab page shows diff --git a/browser/resources/settings/brave_new_tab_page/brave_new_tab_browser_proxy.js b/browser/resources/settings/brave_new_tab_page/brave_new_tab_browser_proxy.js index 18b86567be6..0229bfeb51a 100644 --- a/browser/resources/settings/brave_new_tab_page/brave_new_tab_browser_proxy.js +++ b/browser/resources/settings/brave_new_tab_page/brave_new_tab_browser_proxy.js @@ -9,45 +9,6 @@ cr.define('settings', function() { /** @interface */ /* #export */ class BraveNewTabBrowserProxy { - /** - * @return {!Promise} - */ - getIsSuperReferralActive() {} - - /** - * @return {!Promise} - */ - getIsBinanceSupported() {} - - /** - * @return {!Promise} - */ - getIsBraveTogetherSupported() {} - - /** - * @return {!Promise} - */ - getIsGeminiSupported() {} - - /** - * @return {!Promise} - */ - getIsBitcoinDotComSupported() {} - - /** - * @return {!Promise} - */ - getShowTopSites() {} - - /** - */ - toggleTopSitesVisible() {} - - /** - * @return {!Promise} - */ - isCryptoDotComSupported() {} - /** * @return {!Promise} */ @@ -63,46 +24,6 @@ cr.define('settings', function() { * @implements {settings.BraveNewTabBrowserProxy} */ /* #export */ class BraveNewTabBrowserProxyImpl { - /** @override */ - getIsSuperReferralActive() { - return cr.sendWithPromise('getIsSuperReferralActive'); - } - - /** @override */ - getIsBinanceSupported() { - return cr.sendWithPromise('getIsBinanceSupported') - } - - /** @override */ - getIsBraveTogetherSupported() { - return cr.sendWithPromise('getIsBraveTogetherSupported') - } - - /** @override */ - getIsGeminiSupported() { - return cr.sendWithPromise('getIsGeminiSupported') - } - - /** @override */ - getIsBitcoinDotComSupported() { - return cr.sendWithPromise('getIsBitcoinDotComSupported') - } - - /** @override */ - getShowTopSites() { - return cr.sendWithPromise('getShowTopSites') - } - - /** @override */ - toggleTopSitesVisible() { - chrome.send('toggleTopSitesVisible', []) - } - - /** @override */ - getIsCryptoDotComSupported() { - return cr.sendWithPromise('getIsCryptoDotComSupported') - } - /** @override */ getNewTabShowsOptionsList() { return cr.sendWithPromise('getNewTabShowsOptionsList') diff --git a/browser/resources/settings/brave_new_tab_page/brave_new_tab_page.html b/browser/resources/settings/brave_new_tab_page/brave_new_tab_page.html index d51ab3a8c15..141b89f8669 100644 --- a/browser/resources/settings/brave_new_tab_page/brave_new_tab_page.html +++ b/browser/resources/settings/brave_new_tab_page/brave_new_tab_page.html @@ -38,80 +38,9 @@
-
-
- - - - - - - - - - - - - -
diff --git a/browser/resources/settings/brave_new_tab_page/brave_new_tab_page.js b/browser/resources/settings/brave_new_tab_page/brave_new_tab_page.js index 495435076ab..cb92bf4aa00 100644 --- a/browser/resources/settings/brave_new_tab_page/brave_new_tab_page.js +++ b/browser/resources/settings/brave_new_tab_page/brave_new_tab_page.js @@ -21,13 +21,6 @@ ], properties: { - isSuperReferralActive_: Boolean, - isBinanceSupported_: Boolean, - isBraveTogetherSupported_: Boolean, - isGeminiSupported_: Boolean, - isBitcoinDotComSupported_: Boolean, - showTopSites_: Boolean, - isCryptoDotComSupported_: Boolean, newTabShowOptions_: Array, shouldNewTabShowDashboardSettings_: Boolean, }, @@ -35,39 +28,11 @@ /** @override */ created: function() { this.browserProxy_ = settings.BraveNewTabBrowserProxyImpl.getInstance(); - this.isSuperReferralActive_ = false; - this.isBinanceSupported_ = false; - this.isBraveTogetherSupported_ = false; - this.isGeminiSupported_ = false; - this.isBitcoinDotComSupported_ = false; - this.showTopSites_ = false; - this.isCryptoDotComSupported_ = false; this.showNewTabDashboardSettings_ = false; }, /** @override */ ready: function() { - this.browserProxy_.getIsSuperReferralActive().then(isSuperReferralActive => { - this.isSuperReferralActive_ = isSuperReferralActive; - }) - this.browserProxy_.getIsBinanceSupported().then(isBinanceSupported => { - this.isBinanceSupported_ = isBinanceSupported; - }) - this.browserProxy_.getIsBraveTogetherSupported().then(isBraveTogetherSupported => { - this.isBraveTogetherSupported_ = isBraveTogetherSupported; - }) - this.browserProxy_.getIsGeminiSupported().then(isGeminiSupported => { - this.isGeminiSupported_ = isGeminiSupported; - }) - this.browserProxy_.getIsBitcoinDotComSupported().then(isBitcoinDotComSupported => { - this.isBitcoinDotComSupported_ = isBitcoinDotComSupported; - }) - this.browserProxy_.getShowTopSites().then(visible => { - this.showTopSites_ = visible; - }) - this.browserProxy_.getIsCryptoDotComSupported().then(isCryptoDotComSupported => { - this.isCryptoDotComSupported_ = isCryptoDotComSupported; - }) this.browserProxy_.getNewTabShowsOptionsList().then(list => { this.newTabShowOptions_ = list; }) @@ -75,19 +40,9 @@ this.showNewTabDashboardSettings_ = showNewTabDashboardSettings; }) - this.addWebUIListener('super-referral-active-state-changed', (isSuperReferralActive) => { - this.isSuperReferralActive_ = isSuperReferralActive; - }) - this.addWebUIListener('ntp-shortcut-visibility-changed', (visible) => { - this.showTopSites_ = visible; - }) this.addWebUIListener('show-new-tab-dashboard-settings-changed', (show) => { this.showNewTabDashboardSettings_ = show }) - }, - - onShowTopSitesChange_: function() { - this.browserProxy_.toggleTopSitesVisible(); } }); })(); diff --git a/browser/ui/webui/settings/brave_appearance_handler.cc b/browser/ui/webui/settings/brave_appearance_handler.cc index 39a4fd86595..25a39a3bfb5 100644 --- a/browser/ui/webui/settings/brave_appearance_handler.cc +++ b/browser/ui/webui/settings/brave_appearance_handler.cc @@ -9,19 +9,10 @@ #include "base/metrics/histogram_macros.h" #include "base/strings/string_number_conversions.h" #include "brave/browser/new_tab/new_tab_shows_options.h" -#include "brave/browser/ntp_background_images/view_counter_service_factory.h" #include "brave/browser/profiles/profile_util.h" #include "brave/browser/themes/brave_dark_mode_utils.h" #include "brave/common/pref_names.h" -#include "brave/components/binance/browser/buildflags/buildflags.h" -#include "brave/components/brave_together/buildflags/buildflags.h" -#include "brave/components/crypto_dot_com/browser/buildflags/buildflags.h" -#include "brave/components/gemini/browser/buildflags/buildflags.h" -#include "brave/components/moonpay/browser/buildflags/buildflags.h" -#include "brave/components/ntp_background_images/browser/ntp_background_images_data.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/ntp_widget_utils/browser/ntp_widget_utils_region.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/search/instant_service.h" @@ -30,45 +21,6 @@ #include "components/prefs/pref_service.h" #include "content/public/browser/web_ui.h" -#if BUILDFLAG(BINANCE_ENABLED) -#include "brave/components/binance/browser/regions.h" -#endif - -#if BUILDFLAG(BRAVE_TOGETHER_ENABLED) -#include "brave/components/brave_together/browser/regions.h" -#endif - -#if BUILDFLAG(GEMINI_ENABLED) -#include "brave/components/gemini/browser/regions.h" -#endif - -#if BUILDFLAG(MOONPAY_ENABLED) -#include "brave/components/moonpay/browser/regions.h" -#endif - -#if BUILDFLAG(CRYPTO_DOT_COM_ENABLED) -#include "brave/components/crypto_dot_com/browser/regions.h" -#endif - -using ntp_background_images::ViewCounterServiceFactory; -using ntp_background_images::prefs::kNewTabPageSuperReferralThemesOption; - -namespace { - -bool IsSuperReferralActive(Profile* profile) { - bool isSuperReferralActive = false; - auto* service = ViewCounterServiceFactory::GetForProfile(profile); - if (service) { - auto* data = service->GetCurrentBrandedWallpaperData(); - if (data && data->IsSuperReferral()) { - isSuperReferralActive = true; - } - } - - return isSuperReferralActive; -} - -} // namespace BraveAppearanceHandler::BraveAppearanceHandler() { local_state_change_registrar_.Init(g_browser_process->local_state()); @@ -84,21 +36,6 @@ BraveAppearanceHandler::~BraveAppearanceHandler() = default; void BraveAppearanceHandler::RegisterMessages() { profile_ = Profile::FromWebUI(web_ui()); profile_state_change_registrar_.Init(profile_->GetPrefs()); - profile_state_change_registrar_.Add( - kNewTabPageSuperReferralThemesOption, - base::BindRepeating(&BraveAppearanceHandler::OnPreferenceChanged, - base::Unretained(this))); - profile_state_change_registrar_.Add( - ntp_background_images::prefs::kNewTabPageShowBackgroundImage, - base::BindRepeating( - &BraveAppearanceHandler::OnBackgroundPreferenceChanged, - base::Unretained(this))); - profile_state_change_registrar_.Add( - ntp_background_images::prefs:: - kNewTabPageShowSponsoredImagesBackgroundImage, - base::BindRepeating( - &BraveAppearanceHandler::OnBackgroundPreferenceChanged, - base::Unretained(this))); profile_state_change_registrar_.Add( kNewTabPageShowsOptions, base::BindRepeating(&BraveAppearanceHandler::OnPreferenceChanged, @@ -123,34 +60,6 @@ void BraveAppearanceHandler::RegisterMessages() { "getBraveThemeType", base::BindRepeating(&BraveAppearanceHandler::GetBraveThemeType, base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "getIsSuperReferralActive", - base::BindRepeating(&BraveAppearanceHandler::GetIsSuperReferralActive, - base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "getIsBinanceSupported", - base::BindRepeating(&BraveAppearanceHandler::GetIsBinanceSupported, - base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "getIsBraveTogetherSupported", - base::BindRepeating(&BraveAppearanceHandler::GetIsBraveTogetherSupported, - base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "getIsGeminiSupported", - base::BindRepeating(&BraveAppearanceHandler::GetIsGeminiSupported, - base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "getIsBitcoinDotComSupported", - base::BindRepeating(&BraveAppearanceHandler::GetIsBitcoinDotComSupported, - base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "toggleTopSitesVisible", - base::BindRepeating(&BraveAppearanceHandler::ToggleTopSitesVisible, - base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "getShowTopSites", - base::BindRepeating(&BraveAppearanceHandler::GetShowTopSites, - base::Unretained(this))); web_ui()->RegisterMessageCallback( "getNewTabShowsOptionsList", base::BindRepeating(&BraveAppearanceHandler::GetNewTabShowsOptionsList, @@ -160,12 +69,6 @@ void BraveAppearanceHandler::RegisterMessages() { base::BindRepeating( &BraveAppearanceHandler::ShouldShowNewTabDashboardSettings, base::Unretained(this))); -#if BUILDFLAG(CRYPTO_DOT_COM_ENABLED) - web_ui()->RegisterMessageCallback( - "getIsCryptoDotComSupported", - base::BindRepeating(&BraveAppearanceHandler::GetIsCryptoDotComSupported, - base::Unretained(this))); -#endif } void BraveAppearanceHandler::SetBraveThemeType(const base::ListValue* args) { @@ -189,95 +92,6 @@ void BraveAppearanceHandler::GetBraveThemeType(const base::ListValue* args) { base::Value(static_cast(dark_mode::GetBraveDarkModeType()))); } -void BraveAppearanceHandler::GetIsSuperReferralActive( - const base::ListValue* args) { - CHECK_EQ(args->GetSize(), 1U); - - AllowJavascript(); - ResolveJavascriptCallback(args->GetList()[0], - base::Value(IsSuperReferralActive(profile_))); -} - -void BraveAppearanceHandler::GetIsBinanceSupported( - const base::ListValue* args) { - CHECK_EQ(args->GetSize(), 1U); - - AllowJavascript(); - -#if !BUILDFLAG(BINANCE_ENABLED) - bool is_supported = false; -#else - bool is_supported = ntp_widget_utils::IsRegionSupported( - profile_->GetPrefs(), binance::unsupported_regions, false); -#endif - - ResolveJavascriptCallback(args->GetList()[0], base::Value(is_supported)); -} - -void BraveAppearanceHandler::GetIsBraveTogetherSupported( - const base::ListValue* args) { - CHECK_EQ(args->GetSize(), 1U); - - AllowJavascript(); - -#if !BUILDFLAG(BRAVE_TOGETHER_ENABLED) - bool is_supported = false; -#else - bool is_supported = ntp_widget_utils::IsRegionSupported( - profile_->GetPrefs(), brave_together::unsupported_regions, false); -#endif - - ResolveJavascriptCallback(args->GetList()[0], base::Value(is_supported)); -} - -void BraveAppearanceHandler::GetIsGeminiSupported( - const base::ListValue* args) { - CHECK_EQ(args->GetSize(), 1U); - - AllowJavascript(); - -#if !BUILDFLAG(GEMINI_ENABLED) - bool is_supported = false; -#else - bool is_supported = ntp_widget_utils::IsRegionSupported( - profile_->GetPrefs(), gemini::supported_regions, true); -#endif - - ResolveJavascriptCallback(args->GetList()[0], base::Value(is_supported)); -} - -void BraveAppearanceHandler::GetIsBitcoinDotComSupported( - const base::ListValue* args) { - CHECK_EQ(args->GetSize(), 1U); - - AllowJavascript(); - -#if !BUILDFLAG(MOONPAY_ENABLED) - bool is_supported = false; -#else - bool is_supported = ntp_widget_utils::IsRegionSupported( - profile_->GetPrefs(), moonpay::bitcoin_dot_com_supported_regions, true); -#endif - - ResolveJavascriptCallback(args->GetList()[0], base::Value(is_supported)); -} - -void BraveAppearanceHandler::GetIsCryptoDotComSupported( - const base::ListValue* args) { - CHECK_EQ(args->GetSize(), 1U); - - AllowJavascript(); - -#if !BUILDFLAG(CRYPTO_DOT_COM_ENABLED) - bool is_supported = false; -#else - bool is_supported = ntp_widget_utils::IsRegionSupported( - profile_->GetPrefs(), crypto_dot_com::unsupported_regions, false); -#endif - - ResolveJavascriptCallback(args->GetList()[0], base::Value(is_supported)); -} - void BraveAppearanceHandler::OnBraveDarkModeChanged() { // GetBraveThemeType() should be used because settings option displays all // available options including default. @@ -295,12 +109,6 @@ void BraveAppearanceHandler::OnBackgroundPreferenceChanged( void BraveAppearanceHandler::OnPreferenceChanged(const std::string& pref_name) { if (IsJavascriptAllowed()) { - if (pref_name == kNewTabPageSuperReferralThemesOption) { - FireWebUIListener("super-referral-active-state-changed", - base::Value(IsSuperReferralActive(profile_))); - return; - } - if (pref_name == kNewTabPageShowsOptions || pref_name == prefs::kHomePage || pref_name == prefs::kHomePageIsNewTabPage) { @@ -312,38 +120,6 @@ void BraveAppearanceHandler::OnPreferenceChanged(const std::string& pref_name) { } } -void BraveAppearanceHandler::ToggleTopSitesVisible( - const base::ListValue* args) { - AllowJavascript(); - InstantService* instant_service = - InstantServiceFactory::GetForProfile(profile_); - // true means to notify observers - instant_service->ToggleShortcutsVisibility(true); -} - -void BraveAppearanceHandler::GetShowTopSites(const base::ListValue* args) { - CHECK_EQ(args->GetSize(), 1U); - AllowJavascript(); - InstantService* instant_service = - InstantServiceFactory::GetForProfile(profile_); - auto pair = instant_service->GetCurrentShortcutSettings(); - bool top_sites_visible = pair.second; - ResolveJavascriptCallback(args->GetList()[0], base::Value(top_sites_visible)); -} - -void BraveAppearanceHandler::TopSitesVisibleChanged( - const std::string& pref_name) { - InstantService* instant_service = - InstantServiceFactory::GetForProfile(profile_); - auto pair = instant_service->GetCurrentShortcutSettings(); - bool top_sites_visible = pair.second; - if (IsJavascriptAllowed()) { - // This event will be picked up by brave_new_tab_page.js - FireWebUIListener("ntp-shortcut-visibility-changed", - base::Value(top_sites_visible)); - } -} - void BraveAppearanceHandler::GetNewTabShowsOptionsList( const base::ListValue* args) { CHECK_EQ(args->GetSize(), 1U); diff --git a/browser/ui/webui/settings/brave_appearance_handler.h b/browser/ui/webui/settings/brave_appearance_handler.h index fd22910b7eb..ec94d1df4b5 100644 --- a/browser/ui/webui/settings/brave_appearance_handler.h +++ b/browser/ui/webui/settings/brave_appearance_handler.h @@ -32,15 +32,6 @@ class BraveAppearanceHandler : public settings::SettingsPageUIHandler { void OnPreferenceChanged(const std::string& pref_name); void SetBraveThemeType(const base::ListValue* args); void GetBraveThemeType(const base::ListValue* args); - void GetIsSuperReferralActive(const base::ListValue* args); - void GetIsBinanceSupported(const base::ListValue* args); - void GetIsBraveTogetherSupported(const base::ListValue* args); - void GetIsGeminiSupported(const base::ListValue* args); - void GetIsBitcoinDotComSupported(const base::ListValue* args); - void ToggleTopSitesVisible(const base::ListValue* args); - void GetShowTopSites(const base::ListValue* args); - void TopSitesVisibleChanged(const std::string& pref_name); - void GetIsCryptoDotComSupported(const base::ListValue* args); void GetNewTabShowsOptionsList(const base::ListValue* args); void ShouldShowNewTabDashboardSettings(const base::ListValue* args); diff --git a/chromium_src/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc b/chromium_src/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc index 8f442bc7071..16604fce0c8 100644 --- a/chromium_src/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc +++ b/chromium_src/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc @@ -10,8 +10,6 @@ #include "base/strings/utf_string_conversions.h" #include "brave/browser/ui/webui/settings/brave_privacy_handler.h" #include "brave/browser/version_info.h" -#include "brave/components/moonpay/browser/buildflags/buildflags.h" -#include "brave/components/crypto_dot_com/browser/buildflags/buildflags.h" #include "chrome/browser/ui/webui/webui_util.h" #include "chrome/common/pref_names.h" #include "components/grit/brave_components_strings.h" @@ -261,21 +259,7 @@ void BraveAddCommonStrings(content::WebUIDataSource* html_source, IDS_SETTINGS_HELP_TIPS_SHOW_BRAVE_WAYBACK_MACHINE_PROMPT}, // New Tab Page { "braveNewTab", IDS_SETTINGS_NEW_TAB }, - { "braveNewTabBackgroundImages", IDS_SETTINGS_NEW_TAB_BACKGROUND_IMAGES }, - { "braveNewTabSponsoredImages", IDS_SETTINGS_NEW_TAB_SPONSORED_IMAGES }, - { "braveNewTabStats", IDS_SETTINGS_NEW_TAB_STATS }, { "braveNewTabBraveRewards", IDS_SETTINGS_NEW_TAB_BRAVE_REWARDS }, - { "braveNewTabBinance", IDS_SETTINGS_NEW_TAB_BINANCE }, - { "braveNewTabGemini", IDS_SETTINGS_NEW_TAB_GEMINI }, -#if BUILDFLAG(MOONPAY_ENABLED) - { "braveNewTabBitcoinDotCom", IDS_SETTINGS_NEW_TAB_BITCOIN_DOT_COM }, -#endif -#if BUILDFLAG(CRYPTO_DOT_COM_ENABLED) - { "braveNewTabCryptoDotCom", IDS_SETTINGS_NEW_TAB_CRYPTO_DOT_COM }, -#endif - { "braveNewTabTogether", IDS_SETTINGS_NEW_TAB_TOGETHER }, - { "braveNewTabTopSites", IDS_SETTINGS_NEW_TAB_TOP_SITES }, - { "braveNewTabClock", IDS_SETTINGS_NEW_TAB_CLOCK }, { "braveNewTabNewTabPageShows", IDS_SETTINGS_NEW_TAB_NEW_TAB_PAGE_SHOWS }, // Misc (TODO: Organize this) {"onExitPageTitle",