Verified Commit a6ab4b56 authored by Pier Angelo Vendrame's avatar Pier Angelo Vendrame 🎃
Browse files

fixup! Bug 4234: Use the Firefox Update Process for Base Browser.

Bug 41668: Port some updater patches to Base Browser

Changes that will need to remain when actually cherry-picking to
base-browser, because they contain name fixes, for example.
Or, for UpdateService.jsm, they need to stay because they make the patch
more understandable.
parent f325a6bc
Loading
Loading
Loading
Loading
+13 −20
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ XPCOMUtils.defineLazyGetter(this, "gSystemPrincipal", () =>
);
XPCOMUtils.defineLazyGlobalGetters(this, [URL]);

const kTBSavedVersionPref =
const FORK_VERSION_PREF =
  "browser.startup.homepage_override.torbrowser.version";

// One-time startup homepage override configurations
@@ -103,8 +103,8 @@ const OVERRIDE_NEW_BUILD_ID = 3;
 * Returns:
 *  OVERRIDE_NEW_PROFILE if this is the first run with a new profile.
 *  OVERRIDE_NEW_MSTONE if this is the first run with a build with a different
 *                      Gecko milestone or Tor Browser version (i.e. right
 *                      after an upgrade).
 *                      Gecko milestone or fork version (i.e. right after an
 *                      upgrade).
 *  OVERRIDE_NEW_BUILD_ID if this is the first run with a new build ID of the
 *                        same Gecko milestone (i.e. after a nightly upgrade).
 *  OVERRIDE_NONE otherwise.
@@ -121,7 +121,7 @@ function needHomepageOverride(prefb) {

  var mstone = Services.appinfo.platformVersion;

  var savedTBVersion = prefb.getCharPref(kTBSavedVersionPref, null);
  var savedForkVersion = prefb.getCharPref(FORK_VERSION_PREF, null);

  var savedBuildID = prefb.getCharPref(
    "browser.startup.homepage_override.buildID",
@@ -144,20 +144,13 @@ function needHomepageOverride(prefb) {

    prefb.setCharPref("browser.startup.homepage_override.mstone", mstone);
    prefb.setCharPref("browser.startup.homepage_override.buildID", buildID);
    prefb.setCharPref(kTBSavedVersionPref, AppConstants.BASE_BROWSER_VERSION);

    // After an upgrade from an older release of Tor Browser (<= 5.5a1), the
    // savedmstone will be undefined because those releases included the
    // value "ignore" for the browser.startup.homepage_override.mstone pref.
    // To correctly detect an upgrade vs. a new profile, we check for the
    // presence of the "app.update.postupdate" pref.
    let updated = prefb.prefHasUserValue("app.update.postupdate");
    return savedmstone || updated ? OVERRIDE_NEW_MSTONE : OVERRIDE_NEW_PROFILE;
    prefb.setCharPref(FORK_VERSION_PREF, AppConstants.BASE_BROWSER_VERSION);
    return savedmstone ? OVERRIDE_NEW_MSTONE : OVERRIDE_NEW_PROFILE;
  }

  if (AppConstants.BASE_BROWSER_VERSION != savedTBVersion) {
  if (AppConstants.BASE_BROWSER_VERSION != savedForkVersion) {
    prefb.setCharPref("browser.startup.homepage_override.buildID", buildID);
    prefb.setCharPref(kTBSavedVersionPref, AppConstants.BASE_BROWSER_VERSION);
    prefb.setCharPref(FORK_VERSION_PREF, AppConstants.BASE_BROWSER_VERSION);
    return OVERRIDE_NEW_MSTONE;
  }

@@ -672,8 +665,8 @@ nsBrowserContentHandler.prototype = {
        "unknown"
      );

      // We do the same for the Tor Browser version.
      let old_tbversion = prefb.getCharPref(kTBSavedVersionPref, null);
      // We do the same for the fork version.
      let old_forkVersion = prefb.getCharPref(FORK_VERSION_PREF, null);

      override = needHomepageOverride(prefb);
      if (override != OVERRIDE_NONE) {
@@ -701,7 +694,7 @@ nsBrowserContentHandler.prototype = {
              "startup.homepage_override_url"
            );
            let update = UpdateManager.readyUpdate;
            let old_version = old_tbversion ? old_tbversion : old_mstone;
            let old_version = old_forkVersion ? old_forkVersion : old_mstone;
            if (
              update &&
              Services.vc.compare(update.appVersion, old_version) > 0
@@ -713,8 +706,8 @@ nsBrowserContentHandler.prototype = {

            overridePage = overridePage.replace("%OLD_VERSION%", old_mstone);
            overridePage = overridePage.replace(
              "%OLD_TOR_BROWSER_VERSION%",
              old_tbversion
              "%OLD_BASE_BROWSER_VERSION%",
              old_forkVersion
            );
            break;
          case OVERRIDE_NEW_BUILD_ID:
+6 −8
Original line number Diff line number Diff line
@@ -954,10 +954,10 @@ def version_path(path):
    return path


# set RELEASE_OR_BETA and NIGHTLY_BUILD variables depending on the cycle we're in
# The logic works like this:
# - if we have "a1" in GRE_MILESTONE, we're building Nightly (define NIGHTLY_BUILD)
# - otherwise, we're building Release/Beta (define RELEASE_OR_BETA)
# Firefox looks for "a" or "a1" in the milestone to detect whether nightly
# features should be enabled. We do not want them, because we want our nightly
# builds to be as close as possible to actual releases.
# So we set always is_release_or_beta to True.
@depends(build_environment, build_project, version_path, "--help")
@imports(_from="__builtin__", _import="open")
@imports("os")
@@ -1001,9 +1001,7 @@ def milestone(build_env, build_project, version_path, _):

    is_nightly = is_release_or_beta = is_early_beta_or_earlier = None

    if "a1" in milestone:
        is_nightly = True
    else:
    # Do not enable extra nightly features
    is_release_or_beta = True

    major_version = milestone.split(".")[0]
+4 −4
Original line number Diff line number Diff line
@@ -167,8 +167,8 @@ var UpdateUtils = {
   * downloads and installs updates. This corresponds to whether or not the user
   * has selected "Automatically install updates" in about:preferences.
   *
   * On Windows (except in Tor Browser), this setting is shared across all profiles
   * for the installation
   * On Windows (except in Base Browser and derivatives), this setting is shared
   * across all profiles for the installation
   * and is read asynchronously from the file. On other operating systems, this
   * setting is stored in a pref and is thus a per-profile setting.
   *
@@ -184,8 +184,8 @@ var UpdateUtils = {
   * updates" and "Check for updates but let you choose to install them" options
   * in about:preferences.
   *
   * On Windows (except in Tor Browser), this setting is shared across all profiles
   * for the installation
   * On Windows (except in Base Browser and derivatives), this setting is shared
   * across all profiles for the installation
   * and is written asynchronously to the file. On other operating systems, this
   * setting is stored in a pref and is thus a per-profile setting.
   *
+9 −16
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ const PREF_EM_STRICT_COMPATIBILITY = "extensions.strictCompatibility";
const PREF_EM_CHECK_UPDATE_SECURITY = "extensions.checkUpdateSecurity";
const PREF_SYS_ADDON_UPDATE_ENABLED = "extensions.systemAddon.update.enabled";
const PREF_REMOTESETTINGS_DISABLED = "extensions.remoteSettings.disabled";
const PREF_EM_LAST_TORBROWSER_VERSION = "extensions.lastTorBrowserVersion";
const PREF_EM_LAST_FORK_VERSION = "extensions.lastTorBrowserVersion";

const PREF_MIN_WEBEXT_PLATFORM_VERSION =
  "extensions.webExtensionsMinPlatformVersion";
@@ -645,26 +645,19 @@ var AddonManagerInternal = {
        );
      }

      // To ensure that extension and plugin code gets a chance to run
      // after each browser update, set appChanged = true when the
      // Tor Browser version has changed even if the Mozilla app
      // version has not changed.
      let tbChanged = undefined;
      try {
        tbChanged =
          AppConstants.BASE_BROWSER_VERSION !==
          Services.prefs.getCharPref(PREF_EM_LAST_TORBROWSER_VERSION);
      } catch (e) {}
      if (tbChanged !== false) {
        // Because PREF_EM_LAST_TORBROWSER_VERSION was not present in older
        // versions of Tor Browser, an app change is indicated when tbChanged
        // is undefined or true.
      // To ensure that extension and plugin code gets a chance to run after
      // each browser update, set appChanged = true when BASE_BROWSER_VERSION
      // has changed even if the Mozilla app version has not changed.
      const forkChanged = AppConstants.BASE_BROWSER_VERSION !==
        Services.prefs.getCharPref(PREF_EM_LAST_FORK_VERSION, "");
      if (forkChanged) {
        // appChanged could be undefined (in case of a new profile)
        if (appChanged === false) {
          appChanged = true;
        }

        Services.prefs.setCharPref(
          PREF_EM_LAST_TORBROWSER_VERSION,
          PREF_EM_LAST_FORK_VERSION,
          AppConstants.BASE_BROWSER_VERSION
        );
      }
+24 −25
Original line number Diff line number Diff line
@@ -1587,10 +1587,10 @@ function handleUpdateFailure(update, errorCode) {
    );
    cancelations++;
    Services.prefs.setIntPref(PREF_APP_UPDATE_CANCELATIONS, cancelations);
    if (AppConstants.platform == "macosx") {
      if (AppConstants.BASE_BROWSER_UPDATE) {
    if (AppConstants.platform == "macosx" && AppConstants.BASE_BROWSER_UPDATE) {
      cleanupActiveUpdates();
      } else {
      update.statusText = gUpdateBundle.GetStringFromName("elevationFailure");
    } else if (AppConstants.platform == "macosx") {
      let osxCancelations = Services.prefs.getIntPref(
        PREF_APP_UPDATE_CANCELATIONS_OSX,
        0
@@ -1614,7 +1614,6 @@ function handleUpdateFailure(update, errorCode) {
          (update.state = STATE_PENDING_ELEVATE)
        );
      }
      }
      update.statusText = gUpdateBundle.GetStringFromName("elevationFailure");
    } else {
      writeStatusFile(getReadyUpdateDir(), (update.state = STATE_PENDING));
Loading