diff --git a/app/brave_generated_resources.grd b/app/brave_generated_resources.grd index 3c5da89b38e9..d9e453c5b1b4 100644 --- a/app/brave_generated_resources.grd +++ b/app/brave_generated_resources.grd @@ -261,6 +261,34 @@ By installing this extension, you are agreeing to the Google Widevine Terms of U Show autocomplete in address bar + + + New Tab Page + + + Customize your Brave Dashboard + + + Background images + + + Sponsored images + + + Brave Stats + + + Brave Rewards + + + Binance + + + Top Sites + + + Clock + New Tor Identity diff --git a/browser/extensions/api/settings_private/brave_prefs_util.cc b/browser/extensions/api/settings_private/brave_prefs_util.cc index 75f2eb7571b6..869ce93a035f 100644 --- a/browser/extensions/api/settings_private/brave_prefs_util.cc +++ b/browser/extensions/api/settings_private/brave_prefs_util.cc @@ -7,6 +7,7 @@ #include "brave/common/pref_names.h" #include "brave/components/brave_wayback_machine/buildflags.h" +#include "brave/components/ntp_background_images/common/pref_names.h" #include "chrome/browser/extensions/api/settings_private/prefs_util.h" #include "chrome/common/extensions/api/settings_private.h" #include "components/browsing_data/core/pref_names.h" @@ -62,6 +63,21 @@ const PrefsUtil::TypedPrefMap& BravePrefsUtil::GetWhitelistedKeys() { settings_api::PrefType::PREF_TYPE_BOOLEAN; (*s_brave_whitelist)[kAskWidevineInstall] = settings_api::PrefType::PREF_TYPE_BOOLEAN; + // new tab prefs + (*s_brave_whitelist)[ntp_background_images::prefs::kNewTabPageShowBrandedBackgroundImage] = + settings_api::PrefType::PREF_TYPE_BOOLEAN; + (*s_brave_whitelist)[ntp_background_images::prefs::kNewTabPageShowBackgroundImage] = + settings_api::PrefType::PREF_TYPE_BOOLEAN; + (*s_brave_whitelist)[kNewTabPageShowClock] = + settings_api::PrefType::PREF_TYPE_BOOLEAN; + (*s_brave_whitelist)[kNewTabPageShowTopSites] = + settings_api::PrefType::PREF_TYPE_BOOLEAN; + (*s_brave_whitelist)[kNewTabPageShowStats] = + settings_api::PrefType::PREF_TYPE_BOOLEAN; + (*s_brave_whitelist)[kNewTabPageShowRewards] = + settings_api::PrefType::PREF_TYPE_BOOLEAN; + (*s_brave_whitelist)[kNewTabPageShowBinance] = + settings_api::PrefType::PREF_TYPE_BOOLEAN; // Clear browsing data on exit prefs. (*s_brave_whitelist)[browsing_data::prefs::kDeleteBrowsingHistoryOnExit] = settings_api::PrefType::PREF_TYPE_BOOLEAN; diff --git a/browser/resources/settings/brave_icons.html b/browser/resources/settings/brave_icons.html index e2fc474264d4..b41d43db89bf 100644 --- a/browser/resources/settings/brave_icons.html +++ b/browser/resources/settings/brave_icons.html @@ -67,6 +67,10 @@ + + + diff --git a/browser/resources/settings/brave_new_tab_page/brave_new_tab_browser_proxy.html b/browser/resources/settings/brave_new_tab_page/brave_new_tab_browser_proxy.html new file mode 100644 index 000000000000..6ea9ea253f3a --- /dev/null +++ b/browser/resources/settings/brave_new_tab_page/brave_new_tab_browser_proxy.html @@ -0,0 +1,2 @@ + + 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 new file mode 100644 index 000000000000..4fb581e596d5 --- /dev/null +++ b/browser/resources/settings/brave_new_tab_page/brave_new_tab_browser_proxy.js @@ -0,0 +1,20 @@ +/* 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 http://mozilla.org/MPL/2.0/. */ + + cr.define('settings', function() { + /** @interface */ + class BraveNewTabBrowserProxy {} + + /** + * @implements {settings.BraveNewTabBrowserProxy} + */ + class BraveNewTabBrowserProxyImpl {} + + cr.addSingletonGetter(BraveNewTabBrowserProxyImpl); + + return { + BraveNewTabBrowserProxy, + BraveNewTabBrowserProxyImpl + }; +}); 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 new file mode 100644 index 000000000000..485650ed9d31 --- /dev/null +++ b/browser/resources/settings/brave_new_tab_page/brave_new_tab_page.html @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + $i18n{braveNewTabCustomizeDashboard} + + + + + + + + + + + + + + + + + + + + + + + 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 new file mode 100644 index 000000000000..74f201f1a53e --- /dev/null +++ b/browser/resources/settings/brave_new_tab_page/brave_new_tab_page.js @@ -0,0 +1,37 @@ +/* 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 http://mozilla.org/MPL/2.0/. */ + + (function() { + 'use strict'; + + /** + * 'settings-brave-new-tab-page' is the settings page containing + * brave's new tab features. + */ + Polymer({ + is: 'settings-brave-new-tab-page', + + /** @private {?settings.BraveNewTabBrowserProxy} */ + browserProxy_: null, + + /** @override */ + created: function() { + this.browserProxy_ = settings.BraveNewTabBrowserProxyImpl.getInstance(); + }, + + toggleBrandedBackgroundOption_: function(isBackgroundEnabled, isBrandedBackgroundEnabled) { + // If background image setting is not turned ON, + // inform the back-end to also disable the branded wallpaper setting. + // We will later disable interacting with the button as well. + if (isBackgroundEnabled === false) { + return { + key: 'brave.new_tab_page.show_branded_background_image', + type: 'BOOLEAN', + value: false + }; + } + return isBrandedBackgroundEnabled; + }, + }); +})(); diff --git a/browser/resources/settings/brave_settings_overrides.html b/browser/resources/settings/brave_settings_overrides.html index 3c3549ad4f18..e76a847361e1 100644 --- a/browser/resources/settings/brave_settings_overrides.html +++ b/browser/resources/settings/brave_settings_overrides.html @@ -8,6 +8,7 @@ + diff --git a/browser/resources/settings/brave_settings_overrides.js b/browser/resources/settings/brave_settings_overrides.js index 5058fe75f059..87234db62f10 100644 --- a/browser/resources/settings/brave_settings_overrides.js +++ b/browser/resources/settings/brave_settings_overrides.js @@ -166,13 +166,16 @@ BravePatching.RegisterPolymerTemplateModifications({ // Move Appearance item const appearanceBrowserEl = getMenuElement(templateContent, '/appearance') getStartedEl.insertAdjacentElement('afterend', appearanceBrowserEl) + // Add New Tab item + const newTabEl = createMenuElement(loadTimeData.getString('braveNewTab'), '/braveNewTab', 'brave_settings:new-tab') + appearanceBrowserEl.insertAdjacentElement('afterend', newTabEl) // Add Sync and Help Tips item const helpTipsEl = createMenuElement(loadTimeData.getString('braveHelpTips'), '/braveHelpTips', 'brave_settings:help') if (loadTimeData.getBoolean('isSyncDisabled')) { - appearanceBrowserEl.insertAdjacentElement('afterend', helpTipsEl) + newTabEl.insertAdjacentElement('afterend', helpTipsEl) } else { const syncEl = createMenuElement(loadTimeData.getString('braveSync'), '/braveSync', 'brave_settings:sync') - appearanceBrowserEl.insertAdjacentElement('afterend', syncEl) + newTabEl.insertAdjacentElement('afterend', syncEl) syncEl.insertAdjacentElement('afterend', helpTipsEl) } // Add Shields item @@ -242,6 +245,7 @@ BravePatching.RegisterPolymerTemplateModifications({ r.EXTENSIONS = r.BASIC.createSection('/extensions', 'extensions') r.BRAVE_SYNC = r.BASIC.createSection('/braveSync', 'braveSync') r.BRAVE_HELP_TIPS = r.BASIC.createSection('/braveHelpTips', 'braveHelpTips') + r.BRAVE_NEW_TAB = r.BASIC.createSection('/braveNewTab', 'braveNewTab') if (!r.SITE_SETTINGS) { console.error('[Brave Settings Overrides] Routes: could not find SITE_SETTINGS page') } @@ -327,13 +331,24 @@ BravePatching.RegisterPolymerTemplateModifications({ ` + const sectionNewTab = document.createElement('template') + sectionNewTab.setAttribute('is', 'dom-if') + sectionNewTab.setAttribute('restamp', true) + sectionNewTab.setAttribute('if', '[[showPage_(pageVisibility.braveNewTab)]]') + sectionNewTab.innerHTML = ` + + + + ` // Get Started at top basicPageEl.insertAdjacentElement('afterbegin', sectionGetStarted) // Move Appearance item const sectionAppearance = getSectionElement(actualTemplate.content, 'appearance') sectionGetStarted.insertAdjacentElement('afterend', sectionAppearance) + // Insert New Tab + sectionAppearance.insertAdjacentElement('afterend', sectionNewTab) // Insert sync - sectionAppearance.insertAdjacentElement('afterend', sectionSync) + sectionNewTab.insertAdjacentElement('afterend', sectionSync) // Insert shields sectionSync.insertAdjacentElement('afterend', sectionShields) // Insert Social Blocking diff --git a/browser/resources/settings/settings_resources.grd b/browser/resources/settings/settings_resources.grd index 49ebaa0a3f09..d0abf9e04b28 100644 --- a/browser/resources/settings/settings_resources.grd +++ b/browser/resources/settings/settings_resources.grd @@ -51,6 +51,11 @@ + + + + + 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 fff08fc4d6c5..5b1bb30163ae 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 @@ -137,6 +137,17 @@ void BraveAddCommonStrings(content::WebUIDataSource* html_source, IDS_SETTINGS_HELP_TIPS}, {"braveHelpTipsWaybackMachineLabel", IDS_SETTINGS_HELP_TIPS_SHOW_BRAVE_WAYBACK_MACHINE_PROMPT}, + // New Tab Page + { "braveNewTab", IDS_SETTINGS_NEW_TAB }, + { "braveNewTabCustomizeDashboard", IDS_SETTINGS_NEW_TAB_CUSTOMIZE_BRAVE_DASHBOARD }, + { "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 }, + { "braveNewTabTopSites", IDS_SETTINGS_NEW_TAB_TOP_SITES }, + { "braveNewTabClock", IDS_SETTINGS_NEW_TAB_CLOCK }, + // Misc (TODO: Organize this) {"onExitPageTitle", IDS_SETTINGS_BRAVE_ON_EXIT}, {"braveDefaultExtensions",