diff --git a/extensions/firefox/content/PdfStreamConverter.jsm b/extensions/firefox/content/PdfStreamConverter.jsm index 298387192..2a37d7459 100644 --- a/extensions/firefox/content/PdfStreamConverter.jsm +++ b/extensions/firefox/content/PdfStreamConverter.jsm @@ -147,44 +147,6 @@ function getLocalizedString(strings, id, property) { return id; } -function createNewChannel(uri, node) { -//#if !MOZCENTRAL - if (NetUtil.newChannel2) { - var systemPrincipal = Services.scriptSecurityManager.getSystemPrincipal(); - return NetUtil.newChannel2(uri, - null, - null, - node, // aLoadingNode - systemPrincipal, // aLoadingPrincipal - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); - } -//#endif - return NetUtil.newChannel({ - uri: uri, - loadUsingSystemPrincipal: true, - }); -} - -function asyncOpenChannel(channel, listener, context) { -//#if !MOZCENTRAL - if (!channel.asyncOpen2 || !('originAttributes' in channel.loadInfo)) { - return channel.asyncOpen(listener, context); - } -//#endif - return channel.asyncOpen2(listener); -} - -function asyncFetchChannel(channel, callback) { -//#if !MOZCENTRAL - if (NetUtil.asyncFetch2) { - return NetUtil.asyncFetch2(channel, callback); - } -//#endif - return NetUtil.asyncFetch(channel, callback); -} - // PDF data storage function PdfDataListener(length) { this.length = length; // less than 0, if length is unknown @@ -278,12 +240,15 @@ ChromeActions.prototype = { getService(Ci.nsIExternalHelperAppService); var docIsPrivate = this.isInPrivateBrowsing(); - var netChannel = createNewChannel(blobUri, this.domWindow.document); + var netChannel = NetUtil.newChannel({ + uri: blobUri, + loadUsingSystemPrincipal: true, + }); if ('nsIPrivateBrowsingChannel' in Ci && netChannel instanceof Ci.nsIPrivateBrowsingChannel) { netChannel.setPrivate(docIsPrivate); } - asyncFetchChannel(netChannel, function(aInputStream, aResult) { + NetUtil.asyncFetch(netChannel, function(aInputStream, aResult) { if (!Components.isSuccessCode(aResult)) { if (sendResponse) { sendResponse(true); @@ -341,7 +306,7 @@ ChromeActions.prototype = { } }; - asyncOpenChannel(channel, listener, null); + channel.asyncOpen2(listener); }); }, getLocale: function() { @@ -983,7 +948,10 @@ PdfStreamConverter.prototype = { .createInstance(Ci.nsIBinaryInputStream); // Create a new channel that is viewer loaded as a resource. - var channel = createNewChannel(PDF_VIEWER_WEB_PAGE, null); + var channel = NetUtil.newChannel({ + uri: PDF_VIEWER_WEB_PAGE, + loadUsingSystemPrincipal: true, + }); var listener = this.listener; var dataListener = this.dataListener; @@ -1033,13 +1001,7 @@ PdfStreamConverter.prototype = { // Keep the URL the same so the browser sees it as the same. channel.originalURI = aRequest.URI; channel.loadGroup = aRequest.loadGroup; -//#if MOZCENTRAL channel.loadInfo.originAttributes = aRequest.loadInfo.originAttributes; -//#else - if ('originAttributes' in aRequest.loadInfo) { - channel.loadInfo.originAttributes = aRequest.loadInfo.originAttributes; - } -//#endif // We can use the resource principal when data is fetched by the chrome, // e.g. useful for NoScript. Make make sure we reuse the origin attributes @@ -1047,23 +1009,11 @@ PdfStreamConverter.prototype = { var ssm = Cc['@mozilla.org/scriptsecuritymanager;1'] .getService(Ci.nsIScriptSecurityManager); var uri = NetUtil.newURI(PDF_VIEWER_WEB_PAGE, null, null); - var resourcePrincipal; -//#if MOZCENTRAL - resourcePrincipal = + var resourcePrincipal = ssm.createCodebasePrincipal(uri, aRequest.loadInfo.originAttributes); -//#else - // FF43 replaced `getCodebasePrincipal` with `createCodebasePrincipal`, - // see https://bugzilla.mozilla.org/show_bug.cgi?id=1165272. - if ('createCodebasePrincipal' in ssm && - 'originAttributes' in aRequest.loadInfo) { - resourcePrincipal = - ssm.createCodebasePrincipal(uri, aRequest.loadInfo.originAttributes); - } else { - resourcePrincipal = ssm.getCodebasePrincipal(uri); - } -//#endif aRequest.owner = resourcePrincipal; - asyncOpenChannel(channel, proxy, aContext); + + channel.asyncOpen2(proxy); }, // nsIRequestObserver::onStopRequest diff --git a/extensions/firefox/install.rdf b/extensions/firefox/install.rdf index 832dc7abb..ad00cab3a 100644 --- a/extensions/firefox/install.rdf +++ b/extensions/firefox/install.rdf @@ -13,8 +13,8 @@ {ec8030f7-c20a-464f-9b0e-13a3a9e97384} - 38.0 - 50.0a1 + 45.0 + 54.0a1 @@ -22,8 +22,8 @@ {92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a} - 2.40 - 2.48a1 + 2.46 + 2.51a1 @@ -31,8 +31,8 @@ {aa3c5121-dab2-40e2-81ca-7ea25febc110} - 38.0 - 50.0a1 + 45.0 + 54.0a1 diff --git a/extensions/firefox/update.rdf b/extensions/firefox/update.rdf index 498f47eac..260a1f33f 100644 --- a/extensions/firefox/update.rdf +++ b/extensions/firefox/update.rdf @@ -14,8 +14,8 @@ {ec8030f7-c20a-464f-9b0e-13a3a9e97384} - 38.0 - 50.0 + 45.0 + 54.0a1 https://raw.githubusercontent.com/mozilla/pdf.js/gh-pages/extensions/firefox/pdf.js.xpi @@ -25,8 +25,8 @@ {aa3c5121-dab2-40e2-81ca-7ea25febc110} - 38.0 - 50.0 + 45.0 + 54.0a1 https://raw.githubusercontent.com/mozilla/pdf.js/gh-pages/extensions/firefox/pdf.js.xpi