mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 22:58:07 +02:00
parent
efcf2aed6e
commit
be012ed1df
1 changed files with 10 additions and 2 deletions
|
@ -22,10 +22,18 @@ limitations under the License.
|
|||
/**
|
||||
* @param {Object} details First argument of the webRequest.onHeadersReceived
|
||||
* event. The property "url" is read.
|
||||
* @return {boolean} True if the PDF download was initiated by PDF.js
|
||||
* @return {boolean} True if the PDF file should be downloaded.
|
||||
*/
|
||||
function isPdfDownloadable(details) {
|
||||
return details.url.indexOf('pdfjs.action=download') >= 0;
|
||||
if (details.url.indexOf('pdfjs.action=download') >= 0)
|
||||
return true;
|
||||
// Display the PDF viewer regardless of the Content-Disposition header
|
||||
// if the file is displayed in the main frame.
|
||||
if (details.type == 'main_frame')
|
||||
return false;
|
||||
var cdHeader = getHeaderFromHeaders(details.responseHeaders,
|
||||
'content-disposition');
|
||||
return cdHeader && /^attachment/i.test(cdHeader.value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue