michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: 'use strict'; michael@0: michael@0: const Cc = Components.classes; michael@0: const Ci = Components.interfaces; michael@0: michael@0: // use ppmm to handle file-picker message. michael@0: let ppmm = Cc['@mozilla.org/parentprocessmessagemanager;1'] michael@0: .getService(Ci.nsIMessageListenerManager); michael@0: michael@0: let pickResult = null; michael@0: michael@0: function processPickMessage(message) { michael@0: let sender = message.target.QueryInterface(Ci.nsIMessageSender); michael@0: // reply FilePicker's message michael@0: sender.sendAsyncMessage('file-picked', pickResult); michael@0: // notify caller michael@0: sendAsyncMessage('file-picked-posted', { type: 'file-picked-posted' }); michael@0: } michael@0: michael@0: function updatePickResult(result) { michael@0: pickResult = result; michael@0: sendAsyncMessage('pick-result-updated', { type: 'pick-result-updated' }); michael@0: } michael@0: michael@0: ppmm.addMessageListener('file-picker', processPickMessage); michael@0: // use update-pick-result to change the expected pick result. michael@0: addMessageListener('update-pick-result', updatePickResult);