Pier Angelo Vendrame pushed to branch mullvad-browser-140.2.0esr-15.0-1 at The Tor Project / Applications / Mullvad Browser
Commits:
-
a5709ed4
by Pier Angelo Vendrame at 2025-09-08T16:07:32+02:00
2 changed files:
Changes:
| ... | ... | @@ -430,9 +430,7 @@ BrowserGlue.prototype = { |
| 430 | 430 | // handle any UI migration
|
| 431 | 431 | this._migrateUI();
|
| 432 | 432 | lazy.ProfileDataUpgrader.upgradeBB(this._isNewProfile);
|
| 433 | - |
|
| 434 | - // Mullvad Browser-specific version of _migrateUI.
|
|
| 435 | - this._migrateUIMB();
|
|
| 433 | + lazy.ProfileDataUpgrader.upgradeMB(this._isNewProfile);
|
|
| 436 | 434 | |
| 437 | 435 | if (!Services.prefs.prefHasUserValue(PREF_PDFJS_ISDEFAULT_CACHE_STATE)) {
|
| 438 | 436 | lazy.PdfJs.checkIsDefault(this._isNewProfile);
|
| ... | ... | @@ -1654,58 +1652,6 @@ BrowserGlue.prototype = { |
| 1654 | 1652 | }
|
| 1655 | 1653 | },
|
| 1656 | 1654 | |
| 1657 | - // Use this method for any MB migration that can be run just before showing
|
|
| 1658 | - // the UI.
|
|
| 1659 | - // Anything that critically needs to be migrated earlier should not use this.
|
|
| 1660 | - async _migrateUIMB() {
|
|
| 1661 | - // Version 1: Mullvad Browser 14.5a6: Clear home page update url preference
|
|
| 1662 | - // (mullvad-browser#411).
|
|
| 1663 | - // Version 2: Mullvad Browser 15.0a2: Remove legacy search addons
|
|
| 1664 | - // (tor-browser#43111).
|
|
| 1665 | - const MB_MIGRATION_VERSION = 2;
|
|
| 1666 | - const MIGRATION_PREF = "mullvadbrowser.migration.version";
|
|
| 1667 | - |
|
| 1668 | - // If we decide to force updating users to pass through any version
|
|
| 1669 | - // following 14.5, we can remove this check, and check only whether
|
|
| 1670 | - // MIGRATION_PREF has a user value, like Mozilla does.
|
|
| 1671 | - if (this._isNewProfile) {
|
|
| 1672 | - // Do not migrate fresh profiles
|
|
| 1673 | - Services.prefs.setIntPref(MIGRATION_PREF, MB_MIGRATION_VERSION);
|
|
| 1674 | - return;
|
|
| 1675 | - } else if (this._isNewProfile === undefined) {
|
|
| 1676 | - // If this happens, check if upstream updated their function and do not
|
|
| 1677 | - // set this member anymore!
|
|
| 1678 | - console.error("_migrateUIMB: this._isNewProfile is undefined.");
|
|
| 1679 | - }
|
|
| 1680 | - |
|
| 1681 | - const currentVersion = Services.prefs.getIntPref(MIGRATION_PREF, 0);
|
|
| 1682 | - |
|
| 1683 | - if (currentVersion < 1) {
|
|
| 1684 | - Services.prefs.clearUserPref("mullvadbrowser.post_update.url");
|
|
| 1685 | - }
|
|
| 1686 | - const dropAddons = async list => {
|
|
| 1687 | - for (const id of list) {
|
|
| 1688 | - try {
|
|
| 1689 | - const engine = await lazy.AddonManager.getAddonByID(id);
|
|
| 1690 | - await engine?.uninstall();
|
|
| 1691 | - } catch {}
|
|
| 1692 | - }
|
|
| 1693 | - };
|
|
| 1694 | - if (currentVersion < 2) {
|
|
| 1695 | - await dropAddons([
|
|
| 1696 | - "brave@search.mozilla.org",
|
|
| 1697 | - "ddg@search.mozilla.org",
|
|
| 1698 | - "ddg-html@search.mozilla.org",
|
|
| 1699 | - "metager@search.mozilla.org",
|
|
| 1700 | - "mojeek@search.mozilla.org",
|
|
| 1701 | - "mullvad-leta@search.mozilla.org",
|
|
| 1702 | - "startpage@search.mozilla.org",
|
|
| 1703 | - ]);
|
|
| 1704 | - }
|
|
| 1705 | - |
|
| 1706 | - Services.prefs.setIntPref(MIGRATION_PREF, MB_MIGRATION_VERSION);
|
|
| 1707 | - },
|
|
| 1708 | - |
|
| 1709 | 1655 | async _showUpgradeDialog() {
|
| 1710 | 1656 | const data = await lazy.OnboardingMessageProvider.getUpgradeMessage();
|
| 1711 | 1657 | const { gBrowser } = lazy.BrowserWindowTracker.getTopWindow();
|
| ... | ... | @@ -974,4 +974,50 @@ export let ProfileDataUpgrader = { |
| 974 | 974 | }
|
| 975 | 975 | Services.prefs.setIntPref(MIGRATION_PREF, MIGRATION_VERSION);
|
| 976 | 976 | },
|
| 977 | + |
|
| 978 | + async upgradeMB(isNewProfile) {
|
|
| 979 | + // Version 1: Mullvad Browser 14.5a6: Clear home page update url preference
|
|
| 980 | + // (mullvad-browser#411).
|
|
| 981 | + // Version 2: Mullvad Browser 15.0a2: Remove legacy search addons
|
|
| 982 | + // (tor-browser#43111).
|
|
| 983 | + const MB_MIGRATION_VERSION = 2;
|
|
| 984 | + const MIGRATION_PREF = "mullvadbrowser.migration.version";
|
|
| 985 | + |
|
| 986 | + if (isNewProfile) {
|
|
| 987 | + // Do not migrate fresh profiles
|
|
| 988 | + Services.prefs.setIntPref(MIGRATION_PREF, MB_MIGRATION_VERSION);
|
|
| 989 | + return;
|
|
| 990 | + } else if (isNewProfile === undefined) {
|
|
| 991 | + // If this happens, check if upstream updated their function and do not
|
|
| 992 | + // set this member anymore!
|
|
| 993 | + console.error("upgradeTB: isNewProfile is undefined.");
|
|
| 994 | + }
|
|
| 995 | + |
|
| 996 | + const currentVersion = Services.prefs.getIntPref(MIGRATION_PREF, 0);
|
|
| 997 | + |
|
| 998 | + if (currentVersion < 1) {
|
|
| 999 | + Services.prefs.clearUserPref("mullvadbrowser.post_update.url");
|
|
| 1000 | + }
|
|
| 1001 | + const dropAddons = async list => {
|
|
| 1002 | + for (const id of list) {
|
|
| 1003 | + try {
|
|
| 1004 | + const engine = await lazy.AddonManager.getAddonByID(id);
|
|
| 1005 | + await engine?.uninstall();
|
|
| 1006 | + } catch {}
|
|
| 1007 | + }
|
|
| 1008 | + };
|
|
| 1009 | + if (currentVersion < 2) {
|
|
| 1010 | + await dropAddons([
|
|
| 1011 | + "brave@search.mozilla.org",
|
|
| 1012 | + "ddg@search.mozilla.org",
|
|
| 1013 | + "ddg-html@search.mozilla.org",
|
|
| 1014 | + "metager@search.mozilla.org",
|
|
| 1015 | + "mojeek@search.mozilla.org",
|
|
| 1016 | + "mullvad-leta@search.mozilla.org",
|
|
| 1017 | + "startpage@search.mozilla.org",
|
|
| 1018 | + ]);
|
|
| 1019 | + }
|
|
| 1020 | + |
|
| 1021 | + Services.prefs.setIntPref(MIGRATION_PREF, MB_MIGRATION_VERSION);
|
|
| 1022 | + },
|
|
| 977 | 1023 | }; |