This is an automated email from the git hooks/post-receive script.
pierov pushed a commit to branch tor-browser-102.5.0esr-12.5-1 in repository tor-browser.
commit 031b265ccfba695d4877e5ecdb3d2de6a50ffaf9 Author: Pier Angelo Vendrame pierov@torproject.org AuthorDate: Fri Dec 2 11:55:13 2022 +0100
Bug 41435: Add a Tor Browser migration function
For now this function only deletes old language packs for which we are already packaging the strings with the application. --- browser/components/BrowserGlue.jsm | 41 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
diff --git a/browser/components/BrowserGlue.jsm b/browser/components/BrowserGlue.jsm index 0949c795d8c7..3dc4c3b21888 100644 --- a/browser/components/BrowserGlue.jsm +++ b/browser/components/BrowserGlue.jsm @@ -1298,6 +1298,10 @@ BrowserGlue.prototype = { // handle any UI migration this._migrateUI();
+ // Handle any TBB-specific migration before showing the UI. Keep after + // _migrateUI to make sure this._isNewProfile has been defined. + this._migrateUITBB(); + // Clear possibly auto enabled enterprise_roots prefs (see bug 40166) if ( !Services.prefs.getBoolPref( @@ -4294,6 +4298,43 @@ BrowserGlue.prototype = { Services.prefs.setIntPref("browser.migration.version", UI_VERSION); },
+ // Use this method for any TBB migration that can be run just before showing + // the UI. + // Anything that critically needs to be migrated earlier should not use this. + _migrateUITBB() { + // Version 1: Tor Browser 12.0. We use it to remove langpacks, after the + // migration to packaged locales. + const TBB_MIGRATION_VERSION = 1; + const MIGRATION_PREF = "torbrowser.migration.version"; + + // If we decide to force updating users to pass through any version + // following 12.0, we can remove this check, and check only whether + // MIGRATION_PREF has a user value, like Mozilla does. + if (this._isNewProfile) { + // Do not migrate fresh profiles + Services.prefs.setIntPref(MIGRATION_PREF, TBB_MIGRATION_VERSION); + return; + } else if (this._isNewProfile === undefined) { + // If this happens, check if upstream updated their function and do not + // set this member anymore! + console.error("_migrateUITBB: this._isNewProfile is undefined."); + } + + const currentVersion = Services.prefs.getIntPref(MIGRATION_PREF, 0); + const removeLangpacks = async () => { + for (const addon of await AddonManager.getAddonsByTypes(["locale"])) { + await addon.uninstall(); + } + }; + if (currentVersion < 1) { + removeLangpacks().catch(err => { + console.error("Could not remove langpacks", err); + }); + } + + Services.prefs.setIntPref(MIGRATION_PREF, TBB_MIGRATION_VERSION); + }, + async _showUpgradeDialog() { const data = await OnboardingMessageProvider.getUpgradeMessage(); const win = BrowserWindowTracker.getTopWindow();