Skip to content
Snippets Groups Projects
Verified Commit 0aac5db7 authored by Pier Angelo Vendrame's avatar Pier Angelo Vendrame :jack_o_lantern:
Browse files

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.
parent 81db97ca
Branches
Tags tor-browser-102.8.0esr-12.5-1-build1
1 merge request!543Tor Browser 12.5a 102.8.0esr rebase
......@@ -1274,6 +1274,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(
......@@ -4283,6 +4287,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();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment