|
|
@ -544,21 +544,6 @@ PdfStreamConverter.prototype = { |
|
|
|
if (!isEnabled()) |
|
|
|
if (!isEnabled()) |
|
|
|
throw Cr.NS_ERROR_NOT_IMPLEMENTED; |
|
|
|
throw Cr.NS_ERROR_NOT_IMPLEMENTED; |
|
|
|
|
|
|
|
|
|
|
|
var useFetchByChrome = getBoolPref(PREF_PREFIX + '.fetchByChrome', true); |
|
|
|
|
|
|
|
if (!useFetchByChrome) { |
|
|
|
|
|
|
|
// Ignoring HTTP POST requests -- pdf.js has to repeat the request.
|
|
|
|
|
|
|
|
var skipConversion = false; |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
var request = aCtxt; |
|
|
|
|
|
|
|
request.QueryInterface(Ci.nsIHttpChannel); |
|
|
|
|
|
|
|
skipConversion = (request.requestMethod !== 'GET'); |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
// Non-HTTP request... continue normally.
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (skipConversion) |
|
|
|
|
|
|
|
throw Cr.NS_ERROR_NOT_IMPLEMENTED; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Store the listener passed to us
|
|
|
|
// Store the listener passed to us
|
|
|
|
this.listener = aListener; |
|
|
|
this.listener = aListener; |
|
|
|
}, |
|
|
|
}, |
|
|
@ -577,22 +562,15 @@ PdfStreamConverter.prototype = { |
|
|
|
|
|
|
|
|
|
|
|
// nsIRequestObserver::onStartRequest
|
|
|
|
// nsIRequestObserver::onStartRequest
|
|
|
|
onStartRequest: function(aRequest, aContext) { |
|
|
|
onStartRequest: function(aRequest, aContext) { |
|
|
|
|
|
|
|
|
|
|
|
// Setup the request so we can use it below.
|
|
|
|
// Setup the request so we can use it below.
|
|
|
|
aRequest.QueryInterface(Ci.nsIChannel); |
|
|
|
aRequest.QueryInterface(Ci.nsIChannel); |
|
|
|
var useFetchByChrome = getBoolPref(PREF_PREFIX + '.fetchByChrome', true); |
|
|
|
// Creating storage for PDF data
|
|
|
|
var dataListener; |
|
|
|
var contentLength = aRequest.contentLength; |
|
|
|
if (useFetchByChrome) { |
|
|
|
var dataListener = new PdfDataListener(contentLength); |
|
|
|
// Creating storage for PDF data
|
|
|
|
this.dataListener = dataListener; |
|
|
|
var contentLength = aRequest.contentLength; |
|
|
|
this.binaryStream = Cc['@mozilla.org/binaryinputstream;1'] |
|
|
|
dataListener = new PdfDataListener(contentLength); |
|
|
|
.createInstance(Ci.nsIBinaryInputStream); |
|
|
|
this.dataListener = dataListener; |
|
|
|
|
|
|
|
this.binaryStream = Cc['@mozilla.org/binaryinputstream;1'] |
|
|
|
|
|
|
|
.createInstance(Ci.nsIBinaryInputStream); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// Cancel the request so the viewer can handle it.
|
|
|
|
|
|
|
|
aRequest.cancel(Cr.NS_BINDING_ABORTED); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Change the content type so we don't get stuck in a loop.
|
|
|
|
// Change the content type so we don't get stuck in a loop.
|
|
|
|
aRequest.contentType = 'text/html'; |
|
|
|
aRequest.contentType = 'text/html'; |
|
|
|
|
|
|
|
|
|
|
@ -642,19 +620,17 @@ PdfStreamConverter.prototype = { |
|
|
|
channel.originalURI = aRequest.URI; |
|
|
|
channel.originalURI = aRequest.URI; |
|
|
|
channel.loadGroup = aRequest.loadGroup; |
|
|
|
channel.loadGroup = aRequest.loadGroup; |
|
|
|
|
|
|
|
|
|
|
|
if (useFetchByChrome) { |
|
|
|
// We can use resource principal when data is fetched by the chrome
|
|
|
|
// We can use resource principal when data is fetched by the chrome
|
|
|
|
// e.g. useful for NoScript
|
|
|
|
// e.g. useful for NoScript
|
|
|
|
var securityManager = Cc['@mozilla.org/scriptsecuritymanager;1'] |
|
|
|
var securityManager = Cc['@mozilla.org/scriptsecuritymanager;1'] |
|
|
|
.getService(Ci.nsIScriptSecurityManager); |
|
|
|
.getService(Ci.nsIScriptSecurityManager); |
|
|
|
var uri = ioService.newURI(PDF_VIEWER_WEB_PAGE, null, null); |
|
|
|
var uri = ioService.newURI(PDF_VIEWER_WEB_PAGE, null, null); |
|
|
|
// FF16 and below had getCodebasePrincipal, it was replaced by
|
|
|
|
// FF16 and below had getCodebasePrincipal, it was replaced by
|
|
|
|
// getNoAppCodebasePrincipal (bug 758258).
|
|
|
|
// getNoAppCodebasePrincipal (bug 758258).
|
|
|
|
var resourcePrincipal = 'getNoAppCodebasePrincipal' in securityManager ? |
|
|
|
var resourcePrincipal = 'getNoAppCodebasePrincipal' in securityManager ? |
|
|
|
securityManager.getNoAppCodebasePrincipal(uri) : |
|
|
|
securityManager.getNoAppCodebasePrincipal(uri) : |
|
|
|
securityManager.getCodebasePrincipal(uri); |
|
|
|
securityManager.getCodebasePrincipal(uri); |
|
|
|
aRequest.owner = resourcePrincipal; |
|
|
|
aRequest.owner = resourcePrincipal; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
channel.asyncOpen(proxy, aContext); |
|
|
|
channel.asyncOpen(proxy, aContext); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|