зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1639067 part 3 - Extend "Open In System Viewer" from PDF to all viewable internally. r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D86652
This commit is contained in:
Родитель
29649175ed
Коммит
a4c25ac405
|
@ -311,14 +311,14 @@ class DownloadsSubview extends DownloadsViewUI.BaseView {
|
|||
"temporary-block",
|
||||
button.classList.contains("temporary-block")
|
||||
);
|
||||
// menu items are conditionally displayed via CSS based on an is-pdf attribute
|
||||
// menu items are conditionally displayed via CSS based on a viewable-internally attribute
|
||||
DownloadsCommon.log(
|
||||
"DownloadsSubview, updateContextMenu, download is pdf? ",
|
||||
"DownloadsSubview, updateContextMenu, download is viewable internally? ",
|
||||
download.target.path,
|
||||
button.hasAttribute("is-pdf")
|
||||
button.hasAttribute("viewable-internally")
|
||||
);
|
||||
if (button.hasAttribute("is-pdf")) {
|
||||
menu.setAttribute("is-pdf", "true");
|
||||
if (button.hasAttribute("viewable-internally")) {
|
||||
menu.setAttribute("viewable-internally", "true");
|
||||
let alwaysUseSystemViewerItem = menu.querySelector(
|
||||
".downloadAlwaysUseSystemDefaultMenuItem"
|
||||
);
|
||||
|
@ -339,7 +339,7 @@ class DownloadsSubview extends DownloadsViewUI.BaseView {
|
|||
DownloadsCommon.openInSystemViewerItemEnabled
|
||||
);
|
||||
} else {
|
||||
menu.removeAttribute("is-pdf");
|
||||
menu.removeAttribute("viewable-internally");
|
||||
}
|
||||
|
||||
for (let menuitem of menu.getElementsByTagName("menuitem")) {
|
||||
|
|
|
@ -31,6 +31,17 @@ XPCOMUtils.defineLazyServiceGetter(
|
|||
"nsIHandlerService"
|
||||
);
|
||||
|
||||
const { Integration } = ChromeUtils.import(
|
||||
"resource://gre/modules/Integration.jsm"
|
||||
);
|
||||
|
||||
/* global DownloadIntegration */
|
||||
Integration.downloads.defineModuleGetter(
|
||||
this,
|
||||
"DownloadIntegration",
|
||||
"resource://gre/modules/DownloadIntegration.jsm"
|
||||
);
|
||||
|
||||
const HTML_NS = "http://www.w3.org/1999/xhtml";
|
||||
|
||||
var gDownloadElementButtons = {
|
||||
|
@ -465,11 +476,12 @@ DownloadsViewUI.DownloadElementShell.prototype = {
|
|||
// This is a completed download, and the target file still exists.
|
||||
this.element.setAttribute("exists", "true");
|
||||
|
||||
const isPDF = DownloadsCommon.isFileOfType(
|
||||
this.download,
|
||||
"application/pdf"
|
||||
this.element.toggleAttribute(
|
||||
"viewable-internally",
|
||||
DownloadIntegration.shouldViewDownloadInternally(
|
||||
DownloadsCommon.getMimeInfo(this.download)?.type
|
||||
)
|
||||
);
|
||||
this.element.toggleAttribute("is-pdf", isPDF);
|
||||
|
||||
let sizeWithUnits = DownloadsViewUI.getSizeWithUnits(this.download);
|
||||
if (this.isPanel) {
|
||||
|
@ -741,7 +753,9 @@ DownloadsViewUI.DownloadElementShell.prototype = {
|
|||
return this.download.stopped;
|
||||
case "downloadsCmd_openInSystemViewer":
|
||||
case "downloadsCmd_alwaysOpenInSystemViewer":
|
||||
return DownloadsCommon.isFileOfType(this.download, "application/pdf");
|
||||
return DownloadIntegration.shouldViewDownloadInternally(
|
||||
DownloadsCommon.getMimeInfo(this.download)?.type
|
||||
);
|
||||
}
|
||||
return DownloadsViewUI.isCommandName(aCommand) && !!this[aCommand];
|
||||
},
|
||||
|
|
|
@ -715,8 +715,8 @@ DownloadsPlacesView.prototype = {
|
|||
contextMenu.setAttribute("exists", "true");
|
||||
contextMenu.classList.toggle("temporary-block", !!download.hasBlockedData);
|
||||
|
||||
if (element.hasAttribute("is-pdf")) {
|
||||
contextMenu.setAttribute("is-pdf", "true");
|
||||
if (element.hasAttribute("viewable-internally")) {
|
||||
contextMenu.setAttribute("viewable-internally", "true");
|
||||
let alwaysUseSystemViewerItem = contextMenu.querySelector(
|
||||
".downloadAlwaysUseSystemDefaultMenuItem"
|
||||
);
|
||||
|
@ -737,7 +737,7 @@ DownloadsPlacesView.prototype = {
|
|||
DownloadsCommon.openInSystemViewerItemEnabled
|
||||
);
|
||||
} else {
|
||||
contextMenu.removeAttribute("is-pdf");
|
||||
contextMenu.removeAttribute("viewable-internally");
|
||||
}
|
||||
|
||||
if (!download.stopped) {
|
||||
|
|
|
@ -99,10 +99,10 @@
|
|||
|
||||
/* the system-viewer context menu items are only shown for certain mime-types
|
||||
and can be individually enabled via prefs */
|
||||
.download-state:not([is-pdf]) .downloadUseSystemDefaultMenuItem,
|
||||
.download-state:not([viewable-internally]) .downloadUseSystemDefaultMenuItem,
|
||||
.download-state .downloadUseSystemDefaultMenuItem:not([enabled]),
|
||||
.download-state .downloadAlwaysUseSystemDefaultMenuItem:not([enabled]),
|
||||
.download-state:not([is-pdf]) .downloadAlwaysUseSystemDefaultMenuItem
|
||||
.download-state:not([viewable-internally]) .downloadAlwaysUseSystemDefaultMenuItem
|
||||
{
|
||||
display: none;
|
||||
}
|
||||
|
|
|
@ -953,8 +953,8 @@ var DownloadsView = {
|
|||
"temporary-block",
|
||||
element.classList.contains("temporary-block")
|
||||
);
|
||||
if (element.hasAttribute("is-pdf")) {
|
||||
contextMenu.setAttribute("is-pdf", "true");
|
||||
if (element.hasAttribute("viewable-internally")) {
|
||||
contextMenu.setAttribute("viewable-internally", "true");
|
||||
let alwaysUseSystemViewerItem = contextMenu.querySelector(
|
||||
".downloadAlwaysUseSystemDefaultMenuItem"
|
||||
);
|
||||
|
@ -975,7 +975,7 @@ var DownloadsView = {
|
|||
DownloadsCommon.openInSystemViewerItemEnabled
|
||||
);
|
||||
} else {
|
||||
contextMenu.removeAttribute("is-pdf");
|
||||
contextMenu.removeAttribute("viewable-internally");
|
||||
}
|
||||
},
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче