Commit 6be3d80b authored by henry's avatar henry Committed by Pier Angelo Vendrame
Browse files

MB 419: Mullvad Browser migration procedures.

This commit implements the the Mullvad Browser's version of _migrateUI.
parent 6902875c
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
@@ -1517,6 +1517,9 @@ BrowserGlue.prototype = {
    // Base Browser-specific version of _migrateUI.
    this._migrateUIBB();

    // Mullvad Browser-specific version of _migrateUI.
    this._migrateUIMB();

    if (!Services.prefs.prefHasUserValue(PREF_PDFJS_ISDEFAULT_CACHE_STATE)) {
      lazy.PdfJs.checkIsDefault(this._isNewProfile);
    }
@@ -4698,6 +4701,37 @@ BrowserGlue.prototype = {
    Services.prefs.setIntPref(MIGRATION_PREF, MIGRATION_VERSION);
  },

  // Use this method for any MB migration that can be run just before showing
  // the UI.
  // Anything that critically needs to be migrated earlier should not use this.
  _migrateUIMB() {
    // Version 1: Mullvad Browser 14.5a6: Clear home page update url preference
    //            (mullvad-browser#411).
    const MB_MIGRATION_VERSION = 1;
    const MIGRATION_PREF = "mullvadbrowser.migration.version";

    // If we decide to force updating users to pass through any version
    // following 14.5, 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, MB_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("_migrateUIMB: this._isNewProfile is undefined.");
    }

    const currentVersion = Services.prefs.getIntPref(MIGRATION_PREF, 0);

    if (currentVersion < 1) {
      Services.prefs.clearUserPref("mullvadbrowser.post_update.url");
    }

    Services.prefs.setIntPref(MIGRATION_PREF, MB_MIGRATION_VERSION);
  },

  async _showUpgradeDialog() {
    const data = await lazy.OnboardingMessageProvider.getUpgradeMessage();
    const { gBrowser } = lazy.BrowserWindowTracker.getTopWindow();