From a4dd4b17893be9c672721329fc4b9ff57ea0c1cc Mon Sep 17 00:00:00 2001 From: Rob Wu Date: Wed, 14 Aug 2013 23:36:40 +0200 Subject: [PATCH] [CRX] Fixes to view local files again pdfHandler-local.js references the isPdfDownloadable function from pdfHandler.js, but the function didn't expect that the responseHeaders property was absent. Added a check to prevent a runtime error when a local file is displayed in a frame, and show local PDF files again. Local files are rendered on the chrome-extension:-protocol. The previous method of getting the PDF URL was incorrect, this has been fixed as well. --- extensions/chrome/pdfHandler.js | 4 ++-- web/viewer.js | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/extensions/chrome/pdfHandler.js b/extensions/chrome/pdfHandler.js index 2dec4095f..4956c35a8 100644 --- a/extensions/chrome/pdfHandler.js +++ b/extensions/chrome/pdfHandler.js @@ -31,8 +31,8 @@ function isPdfDownloadable(details) { // if the file is displayed in the main frame. if (details.type == 'main_frame') return false; - var cdHeader = getHeaderFromHeaders(details.responseHeaders, - 'content-disposition'); + var cdHeader = details.responseHeaders && + getHeaderFromHeaders(details.responseHeaders, 'content-disposition'); return cdHeader && /^attachment/i.test(cdHeader.value); } diff --git a/web/viewer.js b/web/viewer.js index 4e61e371f..e53738df0 100644 --- a/web/viewer.js +++ b/web/viewer.js @@ -2259,13 +2259,19 @@ var DocumentOutlineView = function documentOutlineView(outline) { document.addEventListener('DOMContentLoaded', function webViewerLoad(evt) { PDFView.initialize(); -//#if !(FIREFOX || MOZCENTRAL || CHROME) +//#if !(FIREFOX || MOZCENTRAL) var params = PDFView.parseQueryString(document.location.search.substring(1)); var file = params.file || DEFAULT_URL; //#else //var file = window.location.href.split('#')[0]; //#endif +//#if CHROME +//if (location.protocol !== 'chrome-extension:') { +// file = location.href.split('#')[0]; +//} +//#endif + //#if !(FIREFOX || MOZCENTRAL || CHROME) var fileInput = document.createElement('input'); fileInput.id = 'fileInput';