Add preprocessor directives for the extension; and refactor FirefoxCom callback
This commit is contained in:
parent
da93e65d8c
commit
68b037ffb0
@ -161,15 +161,22 @@ function getLocalizedString(strings, id, property) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function makeContentReadable(obj, window) {
|
function makeContentReadable(obj, window) {
|
||||||
|
//#if MOZCENTRAL
|
||||||
|
return Cu.cloneInto(obj, window);
|
||||||
|
//#else
|
||||||
if (Cu.cloneInto) {
|
if (Cu.cloneInto) {
|
||||||
return Cu.cloneInto(obj, window);
|
return Cu.cloneInto(obj, window);
|
||||||
}
|
}
|
||||||
|
if (typeof obj !== 'object' || obj === null) {
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
var expose = {};
|
var expose = {};
|
||||||
for (let k in obj) {
|
for (let k in obj) {
|
||||||
expose[k] = "r";
|
expose[k] = "r";
|
||||||
}
|
}
|
||||||
obj.__exposedProps__ = expose;
|
obj.__exposedProps__ = expose;
|
||||||
return obj;
|
return obj;
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// PDF data storage
|
// PDF data storage
|
||||||
@ -698,7 +705,7 @@ var StandardChromeActions = (function StandardChromeActionsClosure() {
|
|||||||
return StandardChromeActions;
|
return StandardChromeActions;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
// Event listener to trigger chrome privedged code.
|
// Event listener to trigger chrome privileged code.
|
||||||
function RequestListener(actions) {
|
function RequestListener(actions) {
|
||||||
this.actions = actions;
|
this.actions = actions;
|
||||||
}
|
}
|
||||||
@ -719,7 +726,7 @@ RequestListener.prototype.receive = function(event) {
|
|||||||
event.detail.response = response;
|
event.detail.response = response;
|
||||||
} else {
|
} else {
|
||||||
var response;
|
var response;
|
||||||
if (!event.detail.callback) {
|
if (!event.detail.responseExpected) {
|
||||||
doc.documentElement.removeChild(message);
|
doc.documentElement.removeChild(message);
|
||||||
response = null;
|
response = null;
|
||||||
} else {
|
} else {
|
||||||
|
@ -64,9 +64,12 @@ var FirefoxCom = (function FirefoxComClosure() {
|
|||||||
document.documentElement.appendChild(request);
|
document.documentElement.appendChild(request);
|
||||||
|
|
||||||
var sender = document.createEvent('CustomEvent');
|
var sender = document.createEvent('CustomEvent');
|
||||||
sender.initCustomEvent('pdf.js.message', true, false,
|
sender.initCustomEvent('pdf.js.message', true, false, {
|
||||||
{action: action, data: data, sync: false,
|
action: action,
|
||||||
callback: callback});
|
data: data,
|
||||||
|
sync: false,
|
||||||
|
responseExpected: !!callback
|
||||||
|
});
|
||||||
return request.dispatchEvent(sender);
|
return request.dispatchEvent(sender);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user