Bug 1657796 - Ensure downloads requested to open with system viewer always do. r=Gijs

* Check both the useSystemViewer flag and the preferredAction for that mime-type when deciding to not open PDFs into pdf.js
* Don't set alwaysAskBeforeHandling to true when toggling off the "Always open in system viewer" context menu item.

Differential Revision: https://phabricator.services.mozilla.com/D86992
This commit is contained in:
Sam Foster 2020-08-14 09:13:05 +00:00
Родитель 3d47eef6c3
Коммит 7e28671750
2 изменённых файлов: 23 добавлений и 18 удалений

Просмотреть файл

@ -856,7 +856,6 @@ DownloadsViewUI.DownloadElementShell.prototype = {
);
// User has selected to not open this mime-type with the system viewer
mimeInfo.preferredAction = mimeInfo.handleInternally;
mimeInfo.alwaysAskBeforeHandling = true;
}
handlerSvc.store(mimeInfo);
DownloadsCommon.openDownload(this.download).catch(Cu.reportError);

Просмотреть файл

@ -795,23 +795,29 @@ var DownloadIntegration = {
}
const PDF_CONTENT_TYPE = "application/pdf";
if (
aDownload.handleInternally ||
(!useSystemDefault && // No explicit instruction was passed to launch this download using the default system viewer.
mimeInfo &&
(mimeInfo.type == PDF_CONTENT_TYPE ||
fileExtension?.toLowerCase() == "pdf") &&
!mimeInfo.alwaysAskBeforeHandling &&
mimeInfo.preferredAction === Ci.nsIHandlerInfo.handleInternally &&
!aDownload.launchWhenSucceeded)
) {
DownloadUIHelper.loadFileIn(file, {
browsingContextId: aDownload.source.browsingContextId,
isPrivate: aDownload.source.isPrivate,
openWhere,
userContextId: aDownload.source.userContextId,
});
return;
if (!useSystemDefault && mimeInfo) {
useSystemDefault = mimeInfo.preferredAction == mimeInfo.useSystemDefault;
}
if (!useSystemDefault) {
// No explicit instruction was passed to launch this download using the default system viewer.
if (
aDownload.handleInternally ||
(mimeInfo &&
(mimeInfo.type == PDF_CONTENT_TYPE ||
fileExtension?.toLowerCase() == "pdf") &&
!mimeInfo.alwaysAskBeforeHandling &&
mimeInfo.preferredAction === Ci.nsIHandlerInfo.handleInternally &&
!aDownload.launchWhenSucceeded)
) {
DownloadUIHelper.loadFileIn(file, {
browsingContextId: aDownload.source.browsingContextId,
isPrivate: aDownload.source.isPrivate,
openWhere,
userContextId: aDownload.source.userContextId,
});
return;
}
}
// An attempt will now be made to launch the download, clear the