Support file save triggered from the Firefox integrated version.

Related to https://bugzilla.mozilla.org/show_bug.cgi?id=1659753

This allows Firefox trigger a "save" event from ctrl/cmd+s or the "Save
Page As" context menu, which in turn lets pdf.js generate a new PDF if
there is form data to save.

I also now use `sourceEventType` on downloads so Firefox can determine if
it should launch the "open with" dialog or "save as" dialog.
This commit is contained in:
Brendan Dahl 2020-08-19 12:19:59 -07:00
parent 10f61b8c96
commit 8023175103
4 changed files with 38 additions and 12 deletions

View file

@ -64,7 +64,13 @@ class DownloadManager {
download(blobUrl, filename);
}
download(blob, url, filename) {
/**
* @param sourceEventType {string} Used to signal what triggered the download.
* The version of PDF.js integrated with Firefox uses this to to determine
* which dialog to show. "save" triggers "save as" and "download" triggers
* the "open with" dialog.
*/
download(blob, url, filename, sourceEventType = "download") {
if (navigator.msSaveBlob) {
// IE10 / IE11
if (!navigator.msSaveBlob(blob, filename)) {