diff --git a/browser/brave_profile_prefs.cc b/browser/brave_profile_prefs.cc index 195d6b7f03f9..ce6bd9012fcb 100644 --- a/browser/brave_profile_prefs.cc +++ b/browser/brave_profile_prefs.cc @@ -313,11 +313,10 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { registry->RegisterStringPref(kNewTabPageClockFormat, ""); registry->RegisterBooleanPref(kNewTabPageShowStats, true); registry->RegisterBooleanPref(kNewTabPageShowRewards, true); - registry->RegisterBooleanPref(kNewTabPageShowBinance, true); + registry->RegisterBooleanPref(kNewTabPageShowBinance, false); registry->RegisterBooleanPref(kNewTabPageShowBraveTalk, false); - registry->RegisterBooleanPref(kNewTabPageShowGemini, true); + registry->RegisterBooleanPref(kNewTabPageShowGemini, false); registry->RegisterBooleanPref(kNewTabPageHideAllWidgets, false); - registry->RegisterBooleanPref(kNewTabPageWidgetVisibilityMigrated, false); registry->RegisterIntegerPref( kNewTabPageShowsOptions, diff --git a/browser/ui/webui/new_tab_page/brave_new_tab_message_handler.cc b/browser/ui/webui/new_tab_page/brave_new_tab_message_handler.cc index 75149e9b7eb2..a44250161985 100644 --- a/browser/ui/webui/new_tab_page/brave_new_tab_message_handler.cc +++ b/browser/ui/webui/new_tab_page/brave_new_tab_message_handler.cc @@ -108,8 +108,6 @@ base::DictionaryValue GetPreferencesDictionary(PrefService* prefs) { pref_data.SetBoolean("showBraveTalk", prefs->GetBoolean(kNewTabPageShowBraveTalk)); pref_data.SetBoolean("showGemini", prefs->GetBoolean(kNewTabPageShowGemini)); - pref_data.SetBoolean("widgetVisibilityMigrated", - prefs->GetBoolean(kNewTabPageWidgetVisibilityMigrated)); #if BUILDFLAG(CRYPTO_DOT_COM_ENABLED) pref_data.SetBoolean( "showCryptoDotCom", @@ -500,10 +498,6 @@ void BraveNewTabMessageHandler::HandleSaveNewTabPagePref( settingsKey = kNewTabPageShowBraveTalk; } else if (settingsKeyInput == "showGemini") { settingsKey = kNewTabPageShowGemini; - } else if (settingsKeyInput == "saveWidgetVisibilityMigrated") { - // This prefs is set to true once. - DCHECK(settingsValueBool); - settingsKey = kNewTabPageWidgetVisibilityMigrated; #if BUILDFLAG(CRYPTO_DOT_COM_ENABLED) } else if (settingsKeyInput == "showCryptoDotCom") { settingsKey = kCryptoDotComNewTabPageShowCryptoDotCom; diff --git a/common/pref_names.cc b/common/pref_names.cc index 6bbc55f938f4..afee071de500 100644 --- a/common/pref_names.cc +++ b/common/pref_names.cc @@ -64,8 +64,6 @@ const char kNewTabPageShowGemini[] = "brave.new_tab_page.show_gemini"; const char kNewTabPageShowBraveTalk[] = "brave.new_tab_page.show_together"; const char kNewTabPageHideAllWidgets[] = "brave.new_tab_page.hide_all_widgets"; const char kNewTabPageShowsOptions[] = "brave.new_tab_page.shows_options"; -const char kNewTabPageWidgetVisibilityMigrated[] = - "brave.new_tab_page.widget_visibility_migrated"; const char kBraveTodayIntroDismissed[] = "brave.today.intro_dismissed"; const char kBinanceAccessToken[] = "brave.binance.access_token"; const char kBinanceRefreshToken[] = "brave.binance.refresh_token"; diff --git a/common/pref_names.h b/common/pref_names.h index 6904492427a7..4667b3d8bd87 100644 --- a/common/pref_names.h +++ b/common/pref_names.h @@ -56,7 +56,6 @@ extern const char kNewTabPageShowGemini[]; extern const char kNewTabPageShowBraveTalk[]; extern const char kNewTabPageHideAllWidgets[]; extern const char kNewTabPageShowsOptions[]; -extern const char kNewTabPageWidgetVisibilityMigrated[]; extern const char kBraveTodayIntroDismissed[]; extern const char kAlwaysShowBookmarkBarOnNTP[]; extern const char kAutocompleteEnabled[]; diff --git a/components/brave_new_tab_ui/api/initialData.ts b/components/brave_new_tab_ui/api/initialData.ts index a55c20f85258..cad4525a8633 100644 --- a/components/brave_new_tab_ui/api/initialData.ts +++ b/components/brave_new_tab_ui/api/initialData.ts @@ -8,8 +8,6 @@ import * as statsAPI from './stats' import * as privateTabDataAPI from './privateTabData' import * as torTabDataAPI from './torTabData' import * as wallpaper from './wallpaper' -import * as storage from '../storage/new_tab_storage' -import { saveShowBinance, saveShowCryptoDotCom, saveShowFTX, saveShowGemini, saveWidgetVisibilityMigrated } from '../api/preferences' export type InitialData = { preferences: NewTab.Preferences @@ -39,99 +37,6 @@ export type InitialRewardsData = { const isIncognito: boolean = chrome.extension.inIncognitoContext -async function migrateInitialDataForWidgetVisibility (initialData: InitialData) { - // Other widget's auth state can be fetched from local storage. - // But, need to fetch ftx auth state to migrate. - // Start migration when ftx auth state is ready. - const ftxUserAuthed = await new Promise(resolve => chrome.ftx.getAccountBalances((balances, authInvalid) => { - resolve(!authInvalid) - })) - const peristentState: NewTab.PersistentState = storage.load() - const widgetLookupTable = { - 'braveTalk': { - display: initialData.braveTalkSupported && initialData.preferences.showBraveTalk, - isCrypto: false - }, - 'rewards': { - display: initialData.preferences.showRewards, - isCrypto: false - }, - 'binance': { - display: initialData.binanceSupported && initialData.preferences.showBinance, - isCrypto: true, - userAuthed: peristentState.binanceState.userAuthed - }, - 'cryptoDotCom': { - display: initialData.cryptoDotComSupported && initialData.preferences.showCryptoDotCom, - isCrypto: true, - userAuthed: false - }, - 'ftx': { - display: initialData.ftxSupported && initialData.preferences.showFTX, - isCrypto: true, - userAuthed: ftxUserAuthed - }, - 'gemini': { - display: initialData.geminiSupported && initialData.preferences.showGemini, - isCrypto: true, - userAuthed: peristentState.geminiState.userAuthed - } - } - - // Find crypto widget that is foremost and visible. - let foremostVisibleCryptoWidget = '' - const lastIndex = peristentState.widgetStackOrder.length - 1 - for (let i = lastIndex; i >= 0; --i) { - const widget = widgetLookupTable[peristentState.widgetStackOrder[i]] - if (!widget) { - console.error('Update above lookup table') - continue - } - - if (!widget.display) { - continue - } - - if (widget.isCrypto) { - foremostVisibleCryptoWidget = peristentState.widgetStackOrder[i] - } - // Found visible foremost widget in the widget stack. Go out. - break - } - - const widgetsShowState = { - 'binance': false, - 'cryptoDotCom': false, - 'ftx': false, - 'gemini': false - } - - for (const key in widgetsShowState) { - // Show foremost visible crypto widget regardless of auth state - // and show user authed crypto widget. - if (key === foremostVisibleCryptoWidget || - widgetLookupTable[key].userAuthed) { - widgetsShowState[key] = true - } - } - - // These don't return promise so we can't await and then fetch new preferences, - // instead make manual changes to initialData.preferences after. - saveShowBinance(widgetsShowState.binance) - saveShowCryptoDotCom(widgetsShowState.cryptoDotCom) - saveShowFTX(widgetsShowState.ftx) - saveShowGemini(widgetsShowState.gemini) - saveWidgetVisibilityMigrated() - - initialData.preferences = { - ...initialData.preferences, - showBinance: widgetsShowState.binance, - showCryptoDotCom: widgetsShowState.cryptoDotCom, - showFTX: widgetsShowState.ftx, - showGemini: widgetsShowState.gemini - } -} - // Gets all data required for the first render of the page export async function getInitialData (): Promise { try { @@ -185,7 +90,7 @@ export async function getInitialData (): Promise { }) ]) console.timeStamp('Got all initial data.') - const initialData = { + return { preferences, stats, privateTabData, @@ -197,12 +102,6 @@ export async function getInitialData (): Promise { ftxSupported, binanceSupported } as InitialData - - if (!initialData.preferences.widgetVisibilityMigrated) { - await migrateInitialDataForWidgetVisibility(initialData) - } - - return initialData } catch (e) { console.error(e) throw Error('Error getting initial data') diff --git a/components/brave_new_tab_ui/api/preferences.ts b/components/brave_new_tab_ui/api/preferences.ts index 2fdadec29d06..94183ffad6bf 100644 --- a/components/brave_new_tab_ui/api/preferences.ts +++ b/components/brave_new_tab_ui/api/preferences.ts @@ -22,10 +22,6 @@ function sendSavePref (key: string, value: any) { chrome.send('saveNewTabPagePref', [key, value]) } -export function saveWidgetVisibilityMigrated (): void { - sendSavePref('saveWidgetVisibilityMigrated', true) -} - export function saveShowBackgroundImage (value: boolean): void { sendSavePref('showBackgroundImage', value) } diff --git a/components/brave_new_tab_ui/storage/new_tab_storage.ts b/components/brave_new_tab_ui/storage/new_tab_storage.ts index 6a119649f338..beda583861f8 100644 --- a/components/brave_new_tab_ui/storage/new_tab_storage.ts +++ b/components/brave_new_tab_ui/storage/new_tab_storage.ts @@ -29,7 +29,6 @@ export const defaultState: NewTab.State = { showBitcoinDotCom: false, showCryptoDotCom: false, showFTX: false, - widgetVisibilityMigrated: false, hideAllWidgets: false, brandedWallpaperOptIn: false, isBrandedWallpaperNotificationDismissed: true, diff --git a/components/crypto_dot_com/browser/crypto_dot_com_pref_utils.cc b/components/crypto_dot_com/browser/crypto_dot_com_pref_utils.cc index 4da15e069685..9a8308b0688e 100644 --- a/components/crypto_dot_com/browser/crypto_dot_com_pref_utils.cc +++ b/components/crypto_dot_com/browser/crypto_dot_com_pref_utils.cc @@ -11,7 +11,7 @@ namespace crypto_dot_com { void RegisterProfilePrefs(PrefRegistrySimple* registry) { - registry->RegisterBooleanPref(kCryptoDotComNewTabPageShowCryptoDotCom, true); + registry->RegisterBooleanPref(kCryptoDotComNewTabPageShowCryptoDotCom, false); registry->RegisterBooleanPref(kCryptoDotComHasBoughtCrypto, false); registry->RegisterBooleanPref(kCryptoDotComHasInteracted, false); } diff --git a/components/definitions/newTab.d.ts b/components/definitions/newTab.d.ts index a9dacfeaf8a0..2ba62442faf8 100644 --- a/components/definitions/newTab.d.ts +++ b/components/definitions/newTab.d.ts @@ -114,7 +114,6 @@ declare namespace NewTab { showGemini: boolean showCryptoDotCom: boolean showFTX: boolean - widgetVisibilityMigrated: boolean hideAllWidgets: boolean isBraveTodayOptedIn: boolean isBrandedWallpaperNotificationDismissed: boolean diff --git a/components/ftx/browser/ftx_pref_utils.cc b/components/ftx/browser/ftx_pref_utils.cc index 4376787fd46e..d7bb7be1ac6f 100644 --- a/components/ftx/browser/ftx_pref_utils.cc +++ b/components/ftx/browser/ftx_pref_utils.cc @@ -15,7 +15,7 @@ namespace ftx { void RegisterProfilePrefs(PrefRegistrySimple* registry) { - registry->RegisterBooleanPref(kFTXNewTabPageShowFTX, true); + registry->RegisterBooleanPref(kFTXNewTabPageShowFTX, false); registry->RegisterStringPref(kFTXAccessToken, ""); const std::string country_code = brave_l10n::GetCountryCode( brave_l10n::LocaleHelper::GetInstance()->GetLocale());