michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components; michael@0: const { Services } = Cu.import('resource://gre/modules/Services.jsm'); michael@0: const { SystemAppProxy } = Cu.import('resource://gre/modules/SystemAppProxy.jsm'); michael@0: michael@0: var processId; michael@0: michael@0: function peekChildId(aSubject, aTopic, aData) { michael@0: Services.obs.removeObserver(peekChildId, 'recording-device-events'); michael@0: Services.obs.removeObserver(peekChildId, 'recording-device-ipc-events'); michael@0: let props = aSubject.QueryInterface(Ci.nsIPropertyBag2); michael@0: if (props.hasKey('childID')) { michael@0: processId = props.get('childID'); michael@0: } michael@0: } michael@0: michael@0: addMessageListener('init-chrome-event', function(message) { michael@0: // listen mozChromeEvent and forward to content process. michael@0: let type = message.type; michael@0: SystemAppProxy.addEventListener('mozChromeEvent', function(event) { michael@0: let details = event.detail; michael@0: if (details.type === type) { michael@0: sendAsyncMessage('chrome-event', details); michael@0: } michael@0: }, true); michael@0: michael@0: Services.obs.addObserver(peekChildId, 'recording-device-events', false); michael@0: Services.obs.addObserver(peekChildId, 'recording-device-ipc-events', false); michael@0: }); michael@0: michael@0: addMessageListener('fake-content-shutdown', function(message) { michael@0: let props = Cc["@mozilla.org/hash-property-bag;1"] michael@0: .createInstance(Ci.nsIWritablePropertyBag2); michael@0: if (processId) { michael@0: props.setPropertyAsUint64('childID', processId); michael@0: } michael@0: Services.obs.notifyObservers(props, 'recording-device-ipc-events', 'content-shutdown'); michael@0: });