Merge remote-tracking branch 'origin/master' into fixpassword
This commit is contained in:
commit
b7ea788b0c
@ -13,14 +13,25 @@ const PDFJS_EVENT_ID = 'pdf.js.message';
|
|||||||
const PDF_CONTENT_TYPE = 'application/pdf';
|
const PDF_CONTENT_TYPE = 'application/pdf';
|
||||||
const EXT_PREFIX = 'extensions.uriloader@pdf.js';
|
const EXT_PREFIX = 'extensions.uriloader@pdf.js';
|
||||||
const MAX_DATABASE_LENGTH = 4096;
|
const MAX_DATABASE_LENGTH = 4096;
|
||||||
|
const FIREFOX_ID = '{ec8030f7-c20a-464f-9b0e-13a3a9e97384}';
|
||||||
|
const SEAMONKEY_ID = '{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}';
|
||||||
|
|
||||||
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
|
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
|
||||||
Cu.import('resource://gre/modules/Services.jsm');
|
Cu.import('resource://gre/modules/Services.jsm');
|
||||||
Cu.import('resource://gre/modules/NetUtil.jsm');
|
Cu.import('resource://gre/modules/NetUtil.jsm');
|
||||||
|
|
||||||
let privateBrowsing = Cc['@mozilla.org/privatebrowsing;1']
|
let appInfo = Cc['@mozilla.org/xre/app-info;1']
|
||||||
.getService(Ci.nsIPrivateBrowsingService);
|
.getService(Ci.nsIXULAppInfo);
|
||||||
let inPrivateBrowswing = privateBrowsing.privateBrowsingEnabled;
|
let privateBrowsing, inPrivateBrowsing;
|
||||||
|
|
||||||
|
if (appInfo.ID === FIREFOX_ID) {
|
||||||
|
privateBrowsing = Cc['@mozilla.org/privatebrowsing;1']
|
||||||
|
.getService(Ci.nsIPrivateBrowsingService);
|
||||||
|
inPrivateBrowsing = privateBrowsing.privateBrowsingEnabled;
|
||||||
|
} else if (appInfo.ID === SEAMONKEY_ID) {
|
||||||
|
privateBrowsing = null;
|
||||||
|
inPrivateBrowsing = false;
|
||||||
|
}
|
||||||
|
|
||||||
function getBoolPref(pref, def) {
|
function getBoolPref(pref, def) {
|
||||||
try {
|
try {
|
||||||
@ -61,8 +72,8 @@ function getDOMWindow(aChannel) {
|
|||||||
|
|
||||||
// All the priviledged actions.
|
// All the priviledged actions.
|
||||||
function ChromeActions() {
|
function ChromeActions() {
|
||||||
this.inPrivateBrowswing = privateBrowsing.privateBrowsingEnabled;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ChromeActions.prototype = {
|
ChromeActions.prototype = {
|
||||||
download: function(data) {
|
download: function(data) {
|
||||||
let mimeService = Cc['@mozilla.org/mime;1'].getService(Ci.nsIMIMEService);
|
let mimeService = Cc['@mozilla.org/mime;1'].getService(Ci.nsIMIMEService);
|
||||||
@ -98,7 +109,7 @@ ChromeActions.prototype = {
|
|||||||
channel.asyncOpen(listener, null);
|
channel.asyncOpen(listener, null);
|
||||||
},
|
},
|
||||||
setDatabase: function(data) {
|
setDatabase: function(data) {
|
||||||
if (this.inPrivateBrowswing)
|
if (inPrivateBrowsing)
|
||||||
return;
|
return;
|
||||||
// Protect against something sending tons of data to setDatabase.
|
// Protect against something sending tons of data to setDatabase.
|
||||||
if (data.length > MAX_DATABASE_LENGTH)
|
if (data.length > MAX_DATABASE_LENGTH)
|
||||||
@ -106,7 +117,7 @@ ChromeActions.prototype = {
|
|||||||
setStringPref(EXT_PREFIX + '.database', data);
|
setStringPref(EXT_PREFIX + '.database', data);
|
||||||
},
|
},
|
||||||
getDatabase: function() {
|
getDatabase: function() {
|
||||||
if (this.inPrivateBrowswing)
|
if (inPrivateBrowsing)
|
||||||
return '{}';
|
return '{}';
|
||||||
return getStringPref(EXT_PREFIX + '.database', '{}');
|
return getStringPref(EXT_PREFIX + '.database', '{}');
|
||||||
},
|
},
|
||||||
|
@ -8,11 +8,22 @@
|
|||||||
<!-- PDFJS_LOCALIZED_METADATA -->
|
<!-- PDFJS_LOCALIZED_METADATA -->
|
||||||
<em:name>PDF Viewer</em:name>
|
<em:name>PDF Viewer</em:name>
|
||||||
<em:version>PDFJSSCRIPT_VERSION</em:version>
|
<em:version>PDFJSSCRIPT_VERSION</em:version>
|
||||||
|
|
||||||
|
<!-- Firefox -->
|
||||||
<em:targetApplication>
|
<em:targetApplication>
|
||||||
<Description>
|
<Description>
|
||||||
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
|
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
|
||||||
<em:minVersion>6.0</em:minVersion>
|
<em:minVersion>6.0</em:minVersion>
|
||||||
<em:maxVersion>14.0a1</em:maxVersion>
|
<em:maxVersion>15.0a1</em:maxVersion>
|
||||||
|
</Description>
|
||||||
|
</em:targetApplication>
|
||||||
|
|
||||||
|
<!-- SeaMonkey -->
|
||||||
|
<em:targetApplication>
|
||||||
|
<Description>
|
||||||
|
<em:id>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</em:id>
|
||||||
|
<em:minVersion>2.1.*</em:minVersion>
|
||||||
|
<em:maxVersion>2.12a1</em:maxVersion>
|
||||||
</Description>
|
</Description>
|
||||||
</em:targetApplication>
|
</em:targetApplication>
|
||||||
<em:bootstrap>true</em:bootstrap>
|
<em:bootstrap>true</em:bootstrap>
|
||||||
|
@ -8,10 +8,12 @@
|
|||||||
* e.g. No cross domain requests without CORS.
|
* e.g. No cross domain requests without CORS.
|
||||||
*
|
*
|
||||||
* @param {string|TypedAray} source Either a url to a PDF is located or a
|
* @param {string|TypedAray} source Either a url to a PDF is located or a
|
||||||
* typed array already populated with data.
|
* typed array (Uint8Array) already populated with data.
|
||||||
|
* @param {Object} headers An object containing the http headers like this:
|
||||||
|
* { Authorization: "BASIC XXX" }.
|
||||||
* @return {Promise} A promise that is resolved with {PDFDocumentProxy} object.
|
* @return {Promise} A promise that is resolved with {PDFDocumentProxy} object.
|
||||||
*/
|
*/
|
||||||
PDFJS.getDocument = function getDocument(source) {
|
PDFJS.getDocument = function getDocument(source, headers) {
|
||||||
var promise = new PDFJS.Promise();
|
var promise = new PDFJS.Promise();
|
||||||
var transport = new WorkerTransport(promise);
|
var transport = new WorkerTransport(promise);
|
||||||
if (typeof source === 'string') {
|
if (typeof source === 'string') {
|
||||||
@ -29,7 +31,8 @@ PDFJS.getDocument = function getDocument(source) {
|
|||||||
error: function getPDFError(e) {
|
error: function getPDFError(e) {
|
||||||
promise.reject('Unexpected server response of ' +
|
promise.reject('Unexpected server response of ' +
|
||||||
e.target.status + '.');
|
e.target.status + '.');
|
||||||
}
|
},
|
||||||
|
headers: headers
|
||||||
},
|
},
|
||||||
function getPDFLoad(data) {
|
function getPDFLoad(data) {
|
||||||
transport.sendData(data);
|
transport.sendData(data);
|
||||||
|
12
src/core.js
12
src/core.js
@ -31,7 +31,19 @@ function getPdf(arg, callback) {
|
|||||||
params = { url: arg };
|
params = { url: arg };
|
||||||
|
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
|
|
||||||
xhr.open('GET', params.url);
|
xhr.open('GET', params.url);
|
||||||
|
|
||||||
|
var headers = params.headers;
|
||||||
|
if (headers) {
|
||||||
|
for (var property in headers) {
|
||||||
|
if (typeof headers[property] === 'undefined')
|
||||||
|
continue;
|
||||||
|
|
||||||
|
xhr.setRequestHeader(property, params.headers[property]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
xhr.mozResponseType = xhr.responseType = 'arraybuffer';
|
xhr.mozResponseType = xhr.responseType = 'arraybuffer';
|
||||||
var protocol = params.url.indexOf(':') < 0 ? window.location.protocol :
|
var protocol = params.url.indexOf(':') < 0 ? window.location.protocol :
|
||||||
params.url.substring(0, params.url.indexOf(':') + 1);
|
params.url.substring(0, params.url.indexOf(':') + 1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user