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 = { var contentObserver = {
classDescription: 'content-policy for ' + hostName, classDescription: 'content-policy for ' + hostName,
classID: Components.ID('{7afbd130-cbaf-46c2-b944-f5d24305f484}'), classID: Components.ID('{7afbd130-cbaf-46c2-b944-f5d24305f484}'),
@ -242,11 +259,9 @@ var contentObserver = {
wantXHRConstructor: false wantXHRConstructor: false
}); });
if ( Services.cpmm ) { if ( getChildProcessMessageManager() ) {
sandbox.rpc = function(details) { sandbox.rpc = function(details) {
var svc = Services; var cpmm = getChildProcessMessageManager();
if ( svc === undefined ) { return; }
var cpmm = svc.cpmm;
if ( !cpmm ) { return; } if ( !cpmm ) { return; }
var r = cpmm.sendSyncMessage(rpcEmitterName, details); var r = cpmm.sendSyncMessage(rpcEmitterName, details);
if ( Array.isArray(r) ) { if ( Array.isArray(r) ) {

View File

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