Loading browser/components/BrowserGlue.sys.mjs +1 −129 Original line number Diff line number Diff line Loading @@ -430,10 +430,7 @@ BrowserGlue.prototype = { // handle any UI migration this._migrateUI(); lazy.ProfileDataUpgrader.upgradeBB(this._isNewProfile); // Handle any TBB-specific migration before showing the UI. Keep after // _migrateUI to make sure this._isNewProfile has been defined. this._migrateUITBB(); lazy.ProfileDataUpgrader.upgradeTB(this._isNewProfile); if (!Services.prefs.prefHasUserValue(PREF_PDFJS_ISDEFAULT_CACHE_STATE)) { lazy.PdfJs.checkIsDefault(this._isNewProfile); Loading Loading @@ -1654,131 +1651,6 @@ BrowserGlue.prototype = { } }, // 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. async _migrateUITBB() { // Version 1: Tor Browser 12.0. We use it to remove langpacks, after the // migration to packaged locales. // Version 2: Tor Browser 13.0/13.0a1: tor-browser#41845. Also, removed some // torbutton preferences that are not used anymore. // Version 3: Tor Browser 13.0.7/13.5a3: Remove blockchair // (tor-browser#42283). // Version 4: Tor Browser 14.0a4 (2024-09-02): Remove Twitter, Yahoo and // YouTube search engines (tor-browser#41835). // Version 5: Tor Browser 14.0a5: Clear user preference for CFR settings // since we hid the UI (tor-browser#43118). // Version 6: Tor Browser 14.5a3: Clear preference for TorSettings that is // no longer used (tor-browser#41921). // Drop unused TorConnect setting (tor-browser#43462). // Version 7: Tor Browser 14.5a6: Clear home page update url preference // (tor-browser#43567). // Version 8: Tor Browser 15.0a2: Remove legacy search addons // (tor-browser#43111). const TBB_MIGRATION_VERSION = 8; 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) { try { await removeLangpacks(); } catch (err) { console.error("Could not remove langpacks", err); } } if (currentVersion < 2) { const prefToClear = [ // tor-browser#41845: We were forcing these value by check the value of // automatic PBM. We decided not to change "browser.cache.disk.enable", "places.history.enabled", "security.nocertdb", "permissions.memory_only", // Old torbutton preferences not used anymore. "extensions.torbutton.loglevel", "extensions.torbutton.logmethod", "extensions.torbutton.pref_fixup_version", "extensions.torbutton.resize_new_windows", "extensions.torbutton.startup", "extensions.torlauncher.prompt_for_locale", "extensions.torlauncher.loglevel", "extensions.torlauncher.logmethod", "extensions.torlauncher.torrc_fixup_version", ]; for (const pref of prefToClear) { if (Services.prefs.prefHasUserValue(pref)) { Services.prefs.clearUserPref(pref); } } } const dropAddons = async list => { for (const id of list) { try { const engine = await lazy.AddonManager.getAddonByID(id); await engine?.uninstall(); } catch {} } }; if (currentVersion < 3) { await dropAddons([ "blockchair@search.mozilla.org", "blockchair-onion@search.mozilla.org", ]); } if (currentVersion < 4) { await dropAddons([ "twitter@search.mozilla.org", "yahoo@search.mozilla.org", "youtube@search.mozilla.org", ]); } if (currentVersion < 5) { for (const pref of [ "browser.newtabpage.activity-stream.asrouter.userprefs.cfr.addons", "browser.newtabpage.activity-stream.asrouter.userprefs.cfr.features", ]) { Services.prefs.clearUserPref(pref); } } if (currentVersion < 6) { Services.prefs.clearUserPref("torbrowser.settings.enabled"); Services.prefs.clearUserPref("torbrowser.bootstrap.allow_internet_test"); } if (currentVersion < 7) { Services.prefs.clearUserPref("torbrowser.post_update.url"); } if (currentVersion < 8) { await dropAddons([ "ddg@search.mozilla.org", "ddg-onion@search.mozilla.org", "google@search.mozilla.org", "startpage@search.mozilla.org", "startpage-onion@search.mozilla.org", "wikipedia@search.mozilla.org", ]); } Services.prefs.setIntPref(MIGRATION_PREF, TBB_MIGRATION_VERSION); }, async _showUpgradeDialog() { const data = await lazy.OnboardingMessageProvider.getUpgradeMessage(); const { gBrowser } = lazy.BrowserWindowTracker.getTopWindow(); Loading browser/components/ProfileDataUpgrader.sys.mjs +122 −0 Original line number Diff line number Diff line Loading @@ -974,4 +974,126 @@ export let ProfileDataUpgrader = { } Services.prefs.setIntPref(MIGRATION_PREF, MIGRATION_VERSION); }, async upgradeTB(isNewProfile) { // Version 1: Tor Browser 12.0. We use it to remove langpacks, after the // migration to packaged locales. // Version 2: Tor Browser 13.0/13.0a1: tor-browser#41845. Also, removed some // torbutton preferences that are not used anymore. // Version 3: Tor Browser 13.0.7/13.5a3: Remove blockchair // (tor-browser#42283). // Version 4: Tor Browser 14.0a4 (2024-09-02): Remove Twitter, Yahoo and // YouTube search engines (tor-browser#41835). // Version 5: Tor Browser 14.0a5: Clear user preference for CFR settings // since we hid the UI (tor-browser#43118). // Version 6: Tor Browser 14.5a3: Clear preference for TorSettings that is // no longer used (tor-browser#41921). // Drop unused TorConnect setting (tor-browser#43462). // Version 7: Tor Browser 14.5a6: Clear home page update url preference // (tor-browser#43567). // Version 8: Tor Browser 15.0a2: Remove legacy search addons // (tor-browser#43111). const TBB_MIGRATION_VERSION = 8; 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 (isNewProfile) { // Do not migrate fresh profiles Services.prefs.setIntPref(MIGRATION_PREF, TBB_MIGRATION_VERSION); return; } else if (isNewProfile === undefined) { // If this happens, check if upstream updated their function and do not // set this member anymore! console.error("upgradeTB: 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) { try { await removeLangpacks(); } catch (err) { console.error("Could not remove langpacks", err); } } if (currentVersion < 2) { const prefToClear = [ // tor-browser#41845: We were forcing these value by check the value of // automatic PBM. We decided not to change "browser.cache.disk.enable", "places.history.enabled", "security.nocertdb", "permissions.memory_only", // Old torbutton preferences not used anymore. "extensions.torbutton.loglevel", "extensions.torbutton.logmethod", "extensions.torbutton.pref_fixup_version", "extensions.torbutton.resize_new_windows", "extensions.torbutton.startup", "extensions.torlauncher.prompt_for_locale", "extensions.torlauncher.loglevel", "extensions.torlauncher.logmethod", "extensions.torlauncher.torrc_fixup_version", ]; for (const pref of prefToClear) { if (Services.prefs.prefHasUserValue(pref)) { Services.prefs.clearUserPref(pref); } } } const dropAddons = async list => { for (const id of list) { try { const engine = await lazy.AddonManager.getAddonByID(id); await engine?.uninstall(); } catch {} } }; if (currentVersion < 3) { await dropAddons([ "blockchair@search.mozilla.org", "blockchair-onion@search.mozilla.org", ]); } if (currentVersion < 4) { await dropAddons([ "twitter@search.mozilla.org", "yahoo@search.mozilla.org", "youtube@search.mozilla.org", ]); } if (currentVersion < 5) { for (const pref of [ "browser.newtabpage.activity-stream.asrouter.userprefs.cfr.addons", "browser.newtabpage.activity-stream.asrouter.userprefs.cfr.features", ]) { Services.prefs.clearUserPref(pref); } } if (currentVersion < 6) { Services.prefs.clearUserPref("torbrowser.settings.enabled"); Services.prefs.clearUserPref("torbrowser.bootstrap.allow_internet_test"); } if (currentVersion < 7) { Services.prefs.clearUserPref("torbrowser.post_update.url"); } if (currentVersion < 8) { await dropAddons([ "ddg@search.mozilla.org", "ddg-onion@search.mozilla.org", "google@search.mozilla.org", "startpage@search.mozilla.org", "startpage-onion@search.mozilla.org", "wikipedia@search.mozilla.org", ]); } Services.prefs.setIntPref(MIGRATION_PREF, TBB_MIGRATION_VERSION); }, }; Loading
browser/components/BrowserGlue.sys.mjs +1 −129 Original line number Diff line number Diff line Loading @@ -430,10 +430,7 @@ BrowserGlue.prototype = { // handle any UI migration this._migrateUI(); lazy.ProfileDataUpgrader.upgradeBB(this._isNewProfile); // Handle any TBB-specific migration before showing the UI. Keep after // _migrateUI to make sure this._isNewProfile has been defined. this._migrateUITBB(); lazy.ProfileDataUpgrader.upgradeTB(this._isNewProfile); if (!Services.prefs.prefHasUserValue(PREF_PDFJS_ISDEFAULT_CACHE_STATE)) { lazy.PdfJs.checkIsDefault(this._isNewProfile); Loading Loading @@ -1654,131 +1651,6 @@ BrowserGlue.prototype = { } }, // 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. async _migrateUITBB() { // Version 1: Tor Browser 12.0. We use it to remove langpacks, after the // migration to packaged locales. // Version 2: Tor Browser 13.0/13.0a1: tor-browser#41845. Also, removed some // torbutton preferences that are not used anymore. // Version 3: Tor Browser 13.0.7/13.5a3: Remove blockchair // (tor-browser#42283). // Version 4: Tor Browser 14.0a4 (2024-09-02): Remove Twitter, Yahoo and // YouTube search engines (tor-browser#41835). // Version 5: Tor Browser 14.0a5: Clear user preference for CFR settings // since we hid the UI (tor-browser#43118). // Version 6: Tor Browser 14.5a3: Clear preference for TorSettings that is // no longer used (tor-browser#41921). // Drop unused TorConnect setting (tor-browser#43462). // Version 7: Tor Browser 14.5a6: Clear home page update url preference // (tor-browser#43567). // Version 8: Tor Browser 15.0a2: Remove legacy search addons // (tor-browser#43111). const TBB_MIGRATION_VERSION = 8; 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) { try { await removeLangpacks(); } catch (err) { console.error("Could not remove langpacks", err); } } if (currentVersion < 2) { const prefToClear = [ // tor-browser#41845: We were forcing these value by check the value of // automatic PBM. We decided not to change "browser.cache.disk.enable", "places.history.enabled", "security.nocertdb", "permissions.memory_only", // Old torbutton preferences not used anymore. "extensions.torbutton.loglevel", "extensions.torbutton.logmethod", "extensions.torbutton.pref_fixup_version", "extensions.torbutton.resize_new_windows", "extensions.torbutton.startup", "extensions.torlauncher.prompt_for_locale", "extensions.torlauncher.loglevel", "extensions.torlauncher.logmethod", "extensions.torlauncher.torrc_fixup_version", ]; for (const pref of prefToClear) { if (Services.prefs.prefHasUserValue(pref)) { Services.prefs.clearUserPref(pref); } } } const dropAddons = async list => { for (const id of list) { try { const engine = await lazy.AddonManager.getAddonByID(id); await engine?.uninstall(); } catch {} } }; if (currentVersion < 3) { await dropAddons([ "blockchair@search.mozilla.org", "blockchair-onion@search.mozilla.org", ]); } if (currentVersion < 4) { await dropAddons([ "twitter@search.mozilla.org", "yahoo@search.mozilla.org", "youtube@search.mozilla.org", ]); } if (currentVersion < 5) { for (const pref of [ "browser.newtabpage.activity-stream.asrouter.userprefs.cfr.addons", "browser.newtabpage.activity-stream.asrouter.userprefs.cfr.features", ]) { Services.prefs.clearUserPref(pref); } } if (currentVersion < 6) { Services.prefs.clearUserPref("torbrowser.settings.enabled"); Services.prefs.clearUserPref("torbrowser.bootstrap.allow_internet_test"); } if (currentVersion < 7) { Services.prefs.clearUserPref("torbrowser.post_update.url"); } if (currentVersion < 8) { await dropAddons([ "ddg@search.mozilla.org", "ddg-onion@search.mozilla.org", "google@search.mozilla.org", "startpage@search.mozilla.org", "startpage-onion@search.mozilla.org", "wikipedia@search.mozilla.org", ]); } Services.prefs.setIntPref(MIGRATION_PREF, TBB_MIGRATION_VERSION); }, async _showUpgradeDialog() { const data = await lazy.OnboardingMessageProvider.getUpgradeMessage(); const { gBrowser } = lazy.BrowserWindowTracker.getTopWindow(); Loading
browser/components/ProfileDataUpgrader.sys.mjs +122 −0 Original line number Diff line number Diff line Loading @@ -974,4 +974,126 @@ export let ProfileDataUpgrader = { } Services.prefs.setIntPref(MIGRATION_PREF, MIGRATION_VERSION); }, async upgradeTB(isNewProfile) { // Version 1: Tor Browser 12.0. We use it to remove langpacks, after the // migration to packaged locales. // Version 2: Tor Browser 13.0/13.0a1: tor-browser#41845. Also, removed some // torbutton preferences that are not used anymore. // Version 3: Tor Browser 13.0.7/13.5a3: Remove blockchair // (tor-browser#42283). // Version 4: Tor Browser 14.0a4 (2024-09-02): Remove Twitter, Yahoo and // YouTube search engines (tor-browser#41835). // Version 5: Tor Browser 14.0a5: Clear user preference for CFR settings // since we hid the UI (tor-browser#43118). // Version 6: Tor Browser 14.5a3: Clear preference for TorSettings that is // no longer used (tor-browser#41921). // Drop unused TorConnect setting (tor-browser#43462). // Version 7: Tor Browser 14.5a6: Clear home page update url preference // (tor-browser#43567). // Version 8: Tor Browser 15.0a2: Remove legacy search addons // (tor-browser#43111). const TBB_MIGRATION_VERSION = 8; 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 (isNewProfile) { // Do not migrate fresh profiles Services.prefs.setIntPref(MIGRATION_PREF, TBB_MIGRATION_VERSION); return; } else if (isNewProfile === undefined) { // If this happens, check if upstream updated their function and do not // set this member anymore! console.error("upgradeTB: 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) { try { await removeLangpacks(); } catch (err) { console.error("Could not remove langpacks", err); } } if (currentVersion < 2) { const prefToClear = [ // tor-browser#41845: We were forcing these value by check the value of // automatic PBM. We decided not to change "browser.cache.disk.enable", "places.history.enabled", "security.nocertdb", "permissions.memory_only", // Old torbutton preferences not used anymore. "extensions.torbutton.loglevel", "extensions.torbutton.logmethod", "extensions.torbutton.pref_fixup_version", "extensions.torbutton.resize_new_windows", "extensions.torbutton.startup", "extensions.torlauncher.prompt_for_locale", "extensions.torlauncher.loglevel", "extensions.torlauncher.logmethod", "extensions.torlauncher.torrc_fixup_version", ]; for (const pref of prefToClear) { if (Services.prefs.prefHasUserValue(pref)) { Services.prefs.clearUserPref(pref); } } } const dropAddons = async list => { for (const id of list) { try { const engine = await lazy.AddonManager.getAddonByID(id); await engine?.uninstall(); } catch {} } }; if (currentVersion < 3) { await dropAddons([ "blockchair@search.mozilla.org", "blockchair-onion@search.mozilla.org", ]); } if (currentVersion < 4) { await dropAddons([ "twitter@search.mozilla.org", "yahoo@search.mozilla.org", "youtube@search.mozilla.org", ]); } if (currentVersion < 5) { for (const pref of [ "browser.newtabpage.activity-stream.asrouter.userprefs.cfr.addons", "browser.newtabpage.activity-stream.asrouter.userprefs.cfr.features", ]) { Services.prefs.clearUserPref(pref); } } if (currentVersion < 6) { Services.prefs.clearUserPref("torbrowser.settings.enabled"); Services.prefs.clearUserPref("torbrowser.bootstrap.allow_internet_test"); } if (currentVersion < 7) { Services.prefs.clearUserPref("torbrowser.post_update.url"); } if (currentVersion < 8) { await dropAddons([ "ddg@search.mozilla.org", "ddg-onion@search.mozilla.org", "google@search.mozilla.org", "startpage@search.mozilla.org", "startpage-onion@search.mozilla.org", "wikipedia@search.mozilla.org", ]); } Services.prefs.setIntPref(MIGRATION_PREF, TBB_MIGRATION_VERSION); }, };