Commit f53cf350 authored by Bernard Igiri's avatar Bernard Igiri
Browse files

Bug 1732893 - Add "click to open" tooltip to download items when...

Bug 1732893 - Add "click to open" tooltip to download items when improvements_to_download_panel is on r=Gijs,fluent-reviewers,kpatenio

Added a "click to open" tooltip to download items when improvements_to_download_panel is on.

Differential Revision: https://phabricator.services.mozilla.com/D131293
parent bbde548e
Loading
Loading
Loading
Loading
+19 −14
Original line number Diff line number Diff line
@@ -15,8 +15,6 @@ const { XPCOMUtils } = ChromeUtils.import(
  "resource://gre/modules/XPCOMUtils.jsm"
);

const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");

XPCOMUtils.defineLazyModuleGetters(this, {
  BrowserWindowTracker: "resource:///modules/BrowserWindowTracker.jsm",
  Downloads: "resource://gre/modules/Downloads.jsm",
@@ -248,9 +246,6 @@ var DownloadsViewUI = {
    // "always open similar files" item instead so that users can add a new
    // mimetype to about:preferences table and set to open with system default.
    // Only appear if browser.download.improvements_to_download_panel is enabled.
    let improvementsOn = Services.prefs.getBoolPref(
      "browser.download.improvements_to_download_panel"
    );
    let alwaysOpenSimilarFilesItem = contextMenu.querySelector(
      ".downloadAlwaysOpenSimilarFilesMenuItem"
    );
@@ -276,7 +271,7 @@ var DownloadsViewUI = {
      (mimeInfo.type === "text/plain" &&
        gReputationService.isBinary(download.target.path));

    if (improvementsOn && !canViewInternally) {
    if (DownloadsViewUI.improvementsIsOn && !canViewInternally) {
      alwaysOpenSimilarFilesItem.hidden =
        state !== DOWNLOAD_FINISHED || shouldNotRememberChoice;
    } else {
@@ -294,6 +289,13 @@ var DownloadsViewUI = {
  },
};

XPCOMUtils.defineLazyPreferenceGetter(
  DownloadsViewUI,
  "improvementsIsOn",
  "browser.download.improvements_to_download_panel",
  false
);

DownloadsViewUI.BaseView = class {
  canClearDownloads(nodeContainer) {
    // Downloads can be cleared if there's at least one removable download in
@@ -632,13 +634,9 @@ DownloadsViewUI.DownloadElementShell.prototype = {
  _updateStateInner() {
    let progressPaused = false;

    let improvementsOn = Services.prefs.getBoolPref(
      "browser.download.improvements_to_download_panel"
    );

    this.element.classList.toggle(
      "openWhenFinished",
      improvementsOn && !this.download.stopped
      DownloadsViewUI.improvementsIsOn && !this.download.stopped
    );

    if (!this.download.stopped) {
@@ -656,11 +654,18 @@ DownloadsViewUI.DownloadElementShell.prototype = {
      );
      this.lastEstimatedSecondsLeft = newEstimatedSecondsLeft;

      if (improvementsOn && this.download.launchWhenSucceeded) {
      if (
        DownloadsViewUI.improvementsIsOn &&
        this.download.launchWhenSucceeded
      ) {
        status = DownloadUtils.getFormattedTimeStatus(newEstimatedSecondsLeft);
      }

      this.showStatus(status);
      let hoverStatus = DownloadsViewUI.improvementsIsOn
        ? {
            l10n: "downloading-file-click-to-open",
          }
        : undefined;
      this.showStatus(status, hoverStatus);
    } else {
      let verdict = "";

+2 −0
Original line number Diff line number Diff line
@@ -144,6 +144,8 @@ downloading-file-opens-in-minutes = Opening in { $minutes }m…
downloading-file-opens-in-minutes-and-seconds = Opening in { $minutes }m { $seconds }s…
downloading-file-opens-in-seconds = Opening in { $seconds }s…
downloading-file-opens-in-some-time = Opening when completed…
downloading-file-click-to-open =
  .value = Open when completed

##