Commit 0b7b4755 authored by Kathleen Brade's avatar Kathleen Brade Committed by Richard Pospesel
Browse files

Bug 4234: Use the Firefox Update Process for Tor Browser.

The following files are never updated:
  TorBrowser/Data/Browser/profiles.ini
  TorBrowser/Data/Browser/profile.default/bookmarks.html
  TorBrowser/Data/Tor/torrc
Mac OS: Store update metadata under TorBrowser/UpdateInfo.
Removed the %OS_VERSION% component from the update URL (13047) and
  added support for minSupportedOSVersion, an attribute of the
  <update> element that may be used to trigger Firefox's
  "unsupported platform" behavior.
Hide the "What's new" links (set app.releaseNotesURL value to about:blank).
Windows: disable "runas" code path in updater (15201).
Windows: avoid writing to the registry (16236).
Also includes fixes for tickets 13047, 13301, 13356, 13594, 15406,
  16014, 16909, 24476, and 25909.

Also fix Bug 26049: reduce the delay before the update prompt is displayed.
Instead of Firefox's 2 days, we use 1 hour (after which time the update
doorhanger will be displayed).

Also fix bug 27221: purge the startup cache if the Tor Browser
version changed (even if the Firefox version and build ID did
not change), e.g., after a minor Tor Browser update.

Also fix 32616: Disable GetSecureOutputDirectoryPath() functionality.

Bug 26048: potentially confusing "restart to update" message

Within the update doorhanger, remove the misleading message that mentions
that windows will be restored after an update is applied, and replace the
"Restart and Restore" button label with an existing
"Restart to update Tor Browser" string.

Bug 28885: notify users that update is downloading

Add a "Downloading Tor Browser update" item which appears in the
hamburger (app) menu while the update service is downloading a MAR
file. Before this change, the browser did not indicate to the user
that an update was in progress, which is especially confusing in
Tor Browser because downloads often take some time. If the user
clicks on the new menu item, the about dialog is opened to allow
the user to see download progress.

As part of this fix, the update service was changed to always show
update-related messages in the hamburger menu, even if the update
was started in the foreground via the about dialog or via the
"Check for Tor Browser Update" toolbar menu item. This change is
consistent with the Tor Browser goal of making sure users are
informed about the update process.

Removed #28885 parts of this patch which have been uplifted to Firefox.
parent f7705be8
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -97,10 +97,12 @@ tools repackage:: $(DIST)/bin/$(MOZ_APP_NAME) $(objdir)/macbuild/Contents/MacOS-
	rsync -aL $(DIST)/bin/$(MOZ_APP_NAME) '$(dist_dest)/Contents/MacOS'
	cp -RL $(topsrcdir)/$(MOZ_BRANDING_DIRECTORY)/firefox.icns '$(dist_dest)/Contents/Resources/firefox.icns'
	cp -RL $(topsrcdir)/$(MOZ_BRANDING_DIRECTORY)/document.icns '$(dist_dest)/Contents/Resources/document.icns'
ifndef TOR_BROWSER_UPDATE
	$(MKDIR) -p '$(dist_dest)/Contents/Library/LaunchServices'
ifdef MOZ_UPDATER
	mv -f '$(dist_dest)/Contents/MacOS/updater.app/Contents/MacOS/org.mozilla.updater' '$(dist_dest)/Contents/Library/LaunchServices'
	ln -s ../../../../Library/LaunchServices/org.mozilla.updater '$(dist_dest)/Contents/MacOS/updater.app/Contents/MacOS/org.mozilla.updater'
endif
endif
	printf APPLTORB > '$(dist_dest)/Contents/PkgInfo'
endif
+2 −8
Original line number Diff line number Diff line
@@ -140,14 +140,8 @@ pref("app.update.elevation.promptMaxAttempts", 2);
pref("app.update.notifyDuringDownload", false);

// If set to true, the Update Service will automatically download updates if the
// user can apply updates. This pref is no longer used on Windows, except as the
// default value to migrate to the new location that this data is now stored
// (which is in a file in the update directory). Because of this, this pref
// should no longer be used directly. Instead, getAppUpdateAutoEnabled and
// getAppUpdateAutoEnabled from UpdateUtils.jsm should be used.
#ifndef XP_WIN
// user can apply updates.
pref("app.update.auto", true);
#endif

// If set to true, the Update Service will apply updates in the background
// when it finishes downloading them.
+1 −1
Original line number Diff line number Diff line
@@ -174,7 +174,7 @@ appUpdater.prototype = {
      if (aChildID == "downloadAndInstall") {
        let updateVersion = gAppUpdater.update.displayVersion;
        // Include the build ID if this is an "a#" (nightly or aurora) build
        if (/a\d+$/.test(updateVersion)) {
        if (!AppConstants.TOR_BROWSER_UPDATE && /a\d+$/.test(updateVersion)) {
          let buildID = gAppUpdater.update.buildID;
          let year = buildID.slice(0, 4);
          let month = buildID.slice(4, 6);
+7 −7
Original line number Diff line number Diff line
@@ -54,15 +54,15 @@ async function init(aEvent) {
    bits: Services.appinfo.is64Bit ? 64 : 32,
  };

  // Adjust version text to show the Tor Browser version
  versionAttributes.version =
    AppConstants.TOR_BROWSER_VERSION +
    " (based on Mozilla Firefox " +
    AppConstants.MOZ_APP_VERSION_DISPLAY +
    ")";

  let version = Services.appinfo.version;
  if (/a\d+$/.test(version)) {
    versionId = "aboutDialog-version-nightly";
    let buildID = Services.appinfo.appBuildID;
    let year = buildID.slice(0, 4);
    let month = buildID.slice(4, 6);
    let day = buildID.slice(6, 8);
    versionAttributes.isodate = `${year}-${month}-${day}`;

    document.getElementById("experimental").hidden = false;
    document.getElementById("communityDesc").hidden = true;
  }
+32 −3
Original line number Diff line number Diff line
@@ -37,6 +37,9 @@ XPCOMUtils.defineLazyGetter(this, "gSystemPrincipal", () =>
);
XPCOMUtils.defineLazyGlobalGetters(this, [URL]);

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

// One-time startup homepage override configurations
const ONCE_DOMAINS = ["mozilla.org", "firefox.com"];
const ONCE_PREF = "browser.startup.homepage_override.once";
@@ -100,7 +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 (i.e. right after an upgrade).
 *                      Gecko milestone or Tor Browser 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.
@@ -117,6 +121,8 @@ function needHomepageOverride(prefb) {

  var mstone = Services.appinfo.platformVersion;

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

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

    prefb.setCharPref("browser.startup.homepage_override.mstone", mstone);
    prefb.setCharPref("browser.startup.homepage_override.buildID", buildID);
    return savedmstone ? OVERRIDE_NEW_MSTONE : OVERRIDE_NEW_PROFILE;
    prefb.setCharPref(kTBSavedVersionPref, AppConstants.TOR_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;
  }

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

  if (buildID != savedBuildID) {
@@ -651,6 +671,10 @@ nsBrowserContentHandler.prototype = {
        "browser.startup.homepage_override.buildID",
        "unknown"
      );

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

      override = needHomepageOverride(prefb);
      if (override != OVERRIDE_NONE) {
        switch (override) {
@@ -677,9 +701,10 @@ nsBrowserContentHandler.prototype = {
              "startup.homepage_override_url"
            );
            let update = UpdateManager.readyUpdate;
            let old_version = old_tbversion ? old_tbversion : old_mstone;
            if (
              update &&
              Services.vc.compare(update.appVersion, old_mstone) > 0
              Services.vc.compare(update.appVersion, old_version) > 0
            ) {
              overridePage = getPostUpdateOverridePage(update, overridePage);
              // Send the update ping to signal that the update was successful.
@@ -687,6 +712,10 @@ nsBrowserContentHandler.prototype = {
            }

            overridePage = overridePage.replace("%OLD_VERSION%", old_mstone);
            overridePage = overridePage.replace(
              "%OLD_TOR_BROWSER_VERSION%",
              old_tbversion
            );
            break;
          case OVERRIDE_NEW_BUILD_ID:
            if (UpdateManager.readyUpdate) {
Loading