1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 14:48:08 +02:00

Add preprocessor directives for the extension; and refactor FirefoxCom callback

This commit is contained in:
Yury Delendik 2014-05-28 10:21:58 -05:00
parent da93e65d8c
commit 68b037ffb0
2 changed files with 15 additions and 5 deletions

View file

@ -161,15 +161,22 @@ function getLocalizedString(strings, id, property) {
}
function makeContentReadable(obj, window) {
//#if MOZCENTRAL
return Cu.cloneInto(obj, window);
//#else
if (Cu.cloneInto) {
return Cu.cloneInto(obj, window);
}
if (typeof obj !== 'object' || obj === null) {
return obj;
}
var expose = {};
for (let k in obj) {
expose[k] = "r";
}
obj.__exposedProps__ = expose;
return obj;
//#endif
}
// PDF data storage
@ -698,7 +705,7 @@ var StandardChromeActions = (function StandardChromeActionsClosure() {
return StandardChromeActions;
})();
// Event listener to trigger chrome privedged code.
// Event listener to trigger chrome privileged code.
function RequestListener(actions) {
this.actions = actions;
}
@ -719,7 +726,7 @@ RequestListener.prototype.receive = function(event) {
event.detail.response = response;
} else {
var response;
if (!event.detail.callback) {
if (!event.detail.responseExpected) {
doc.documentElement.removeChild(message);
response = null;
} else {

View file

@ -64,9 +64,12 @@ var FirefoxCom = (function FirefoxComClosure() {
document.documentElement.appendChild(request);
var sender = document.createEvent('CustomEvent');
sender.initCustomEvent('pdf.js.message', true, false,
{action: action, data: data, sync: false,
callback: callback});
sender.initCustomEvent('pdf.js.message', true, false, {
action: action,
data: data,
sync: false,
responseExpected: !!callback
});
return request.dispatchEvent(sender);
}
};