Commit 848e4342 authored by Kathleen Brade's avatar Kathleen Brade Committed by Georg Koppen
Browse files

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.
parent 26941c87
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ pref("startup.homepage_override_url", "https://blog.torproject.org/category/tags
// Try to nag a bit more about updates: Pop up a restart dialog an hour after the initial dialog
pref("app.update.promptWaitTime", 3600);
pref("app.update.badge", true);
pref("app.update.notifyDuringDownload", true);
pref("extensions.hotfix.id", ""); // Bug 16837: Disable hotfix updates as they may cause compat issues

#ifdef XP_WIN
+1 −0
Original line number Diff line number Diff line
@@ -172,6 +172,7 @@
        <vbox id="appMenu-addon-banners"/>
        <toolbarbutton class="panel-banner-item"
                       label-update-available="&updateAvailable.panelUI.label;"
                       label-update-downloading="Downloading update"
                       label-update-manual="&updateManual.panelUI.label;"
                       label-update-restart="&updateRestart.panelUI.label2;"
                       oncommand="PanelUI._onBannerItemSelected(event)"
+28 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ const PanelUI = {

  init() {
    this._initElements();
    this._initUpdaterStrings();

    this.menuButton.addEventListener("mousedown", this);
    this.menuButton.addEventListener("keypress", this);
@@ -53,6 +54,7 @@ const PanelUI = {

    Services.obs.addObserver(this, "fullscreen-nav-toolbox");
    Services.obs.addObserver(this, "appMenu-notifications");
    Services.obs.addObserver(this, "show-update-progress");

    XPCOMUtils.defineLazyPreferenceGetter(this, "autoHideToolbarInFullScreen",
      "browser.fullscreen.autohide", false, (pref, previousValue, newValue) => {
@@ -120,6 +122,28 @@ const PanelUI = {
    }
  },

  _initUpdaterStrings() {
    // If Torbutton is installed and enabled, replace the "Downloading update"
    // string with one from torbutton.properties (to facilitate localization).
    try {
      let brands = Services.strings.createBundle(
                                 "chrome://branding/locale/brand.properties");
      let stringArgs = [brands.GetStringFromName("brandShortName")];
      let torbuttonBundle = Services.strings.createBundle(
                            "chrome://torbutton/locale/torbutton.properties");
      let label = torbuttonBundle.formatStringFromName(
                              "updateDownloadingPanelUILabel", stringArgs, 1);
      let attrName = "label-update-downloading";
      let elements = document.getElementsByClassName("panel-banner-item");
      for (let i = 0; i < elements.length; ++i) {
        let elem = elements.item(i);
        if (elem.hasAttribute(attrName)) {
          elem.setAttribute(attrName, label);
        }
      }
    } catch (e) {}
  },

  _eventListenersAdded: false,
  _ensureEventListenersAdded() {
    if (this._eventListenersAdded)
@@ -152,6 +176,7 @@ const PanelUI = {

    Services.obs.removeObserver(this, "fullscreen-nav-toolbox");
    Services.obs.removeObserver(this, "appMenu-notifications");
    Services.obs.removeObserver(this, "show-update-progress");

    window.removeEventListener("MozDOMFullscreen:Entered", this);
    window.removeEventListener("MozDOMFullscreen:Exited", this);
@@ -252,6 +277,9 @@ const PanelUI = {
        this._notifications = AppMenuNotifications.notifications;
        this._updateNotifications(true);
        break;
      case "show-update-progress":
        openAboutDialog();
        break;
    }
  },

+1 −0
Original line number Diff line number Diff line
@@ -187,6 +187,7 @@ const global = this;

const listeners = {
  observers: {
    "update-downloading": ["UpdateListener"],
    "update-staged": ["UpdateListener"],
    "update-downloaded": ["UpdateListener"],
    "update-available": ["UpdateListener"],
+1 −0
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@
}

#PanelUI-menu-button[badge-status="update-available"] > .toolbarbutton-badge-stack > .toolbarbutton-badge,
#PanelUI-menu-button[badge-status="update-downloading"] > .toolbarbutton-badge-stack > .toolbarbutton-badge,
#PanelUI-menu-button[badge-status="update-manual"] > .toolbarbutton-badge-stack > .toolbarbutton-badge,
#PanelUI-menu-button[badge-status="update-restart"] > .toolbarbutton-badge-stack > .toolbarbutton-badge {
  background: #74BF43 url(chrome://browser/skin/update-badge.svg) no-repeat center;
Loading