From 7e05c2708b8b55f40ad241145dab0559e8e1773f Mon Sep 17 00:00:00 2001 From: Frank-Rainer Grahl Date: Mon, 2 Oct 2017 16:51:50 +0200 Subject: [PATCH] Bug 1402688 - Port part of Bug 1358921. Move LoginManagerParent init code to nsSuiteGlue.js. r=IanN --- suite/common/src/nsSuiteGlue.js | 36 ++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/suite/common/src/nsSuiteGlue.js b/suite/common/src/nsSuiteGlue.js index 62ec9f1cb5..4e791e7a9b 100644 --- a/suite/common/src/nsSuiteGlue.js +++ b/suite/common/src/nsSuiteGlue.js @@ -40,6 +40,40 @@ XPCOMUtils.defineLazyGetter(this, "DebuggerServer", () => { return tmp.require("devtools/server/main").DebuggerServer; }); +const global = this; + +const listeners = { + mm: { + // PLEASE KEEP THIS LIST IN SYNC WITH THE MOBILE LISTENERS IN nsBrowserGlue.js + "RemoteLogins:findLogins": ["LoginManagerParent"], + "RemoteLogins:findRecipes": ["LoginManagerParent"], + "RemoteLogins:onFormSubmit": ["LoginManagerParent"], + "RemoteLogins:autoCompleteLogins": ["LoginManagerParent"], + "RemoteLogins:removeLogin": ["LoginManagerParent"], + "RemoteLogins:insecureLoginFormPresent": ["LoginManagerParent"], + // PLEASE KEEP THIS LIST IN SYNC WITH THE MOBILE LISTENERS IN nsBrowserGlue.js + }, + + receiveMessage(modules, data) { + let val; + for (let module of modules[data.name]) { + try { + val = global[module].receiveMessage(data) || val; + } catch (e) { + Components.utils.reportError(e); + } + } + return val; + }, + + init() { + let receiveMessageMM = this.receiveMessage.bind(this, this.mm); + for (let message of Object.keys(this.mm)) { + Services.mm.addMessageListener(message, receiveMessageMM); + } + } +}; + // We try to backup bookmarks at idle times, to avoid doing that at shutdown. // Number of idle seconds before trying to backup bookmarks. 15 minutes. const BOOKMARKS_BACKUP_IDLE_TIME = 15 * 60; @@ -194,7 +228,7 @@ SuiteGlue.prototype = { this._promptForMasterPassword(); this._checkForNewAddons(); Services.search.init(); - LoginManagerParent.init(); + listeners.init(); Components.classes["@mozilla.org/globalmessagemanager;1"] .getService(Components.interfaces.nsIMessageListenerManager) .loadFrameScript("chrome://navigator/content/content.js", true);