This commit is contained in:
gorhill 2015-11-16 15:12:26 -05:00
parent fd0c09f434
commit b9475507c8
2 changed files with 31 additions and 8 deletions

View File

@ -63,6 +63,23 @@ const getMessageManager = function(win) {
/******************************************************************************/
const getChildProcessMessageManager = function() {
var svc = Services;
if ( !svc ) {
return;
}
var cpmm = svc.cpmm;
if ( cpmm ) {
return cpmm;
}
cpmm = Components.classes['@mozilla.org/childprocessmessagemanager;1'];
if ( cpmm ) {
return cpmm.getService(Ci.nsISyncMessageSender);
}
};
/******************************************************************************/
var contentObserver = {
classDescription: 'content-policy for ' + hostName,
classID: Components.ID('{7afbd130-cbaf-46c2-b944-f5d24305f484}'),
@ -242,11 +259,9 @@ var contentObserver = {
wantXHRConstructor: false
});
if ( Services.cpmm ) {
if ( getChildProcessMessageManager() ) {
sandbox.rpc = function(details) {
var svc = Services;
if ( svc === undefined ) { return; }
var cpmm = svc.cpmm;
var cpmm = getChildProcessMessageManager();
if ( !cpmm ) { return; }
var r = cpmm.sendSyncMessage(rpcEmitterName, details);
if ( Array.isArray(r) ) {

View File

@ -1712,16 +1712,24 @@ vAPI.rpcReceiver = (function() {
}
};
if ( Services.ppmm ) {
Services.ppmm.addMessageListener(
var ppmm = Services.ppmm;
if ( !ppmm ) {
ppmm = Cc['@mozilla.org/parentprocessmessagemanager;1'];
if ( ppmm ) {
ppmm = ppmm.getService(Ci.nsIMessageListenerManager);
}
}
if ( ppmm ) {
ppmm.addMessageListener(
childProcessMessageName,
onChildProcessMessage
);
}
cleanupTasks.push(function() {
if ( Services.ppmm ) {
Services.ppmm.removeMessageListener(
if ( ppmm ) {
ppmm.removeMessageListener(
childProcessMessageName,
onChildProcessMessage
);