# HG changeset patch # User Frank-Rainer Grahl # Date 1507031294 -7200 # Node ID 8d15df25387ffe060b05e32414357ae672aa045f # Parent 3952cb938e02978518a60165909427b50b1f7c39 Bug 1402688 - Port part of Bug 1358921. Move LoginManagerParent init code to nsSuiteGlue.js. r=IanN a=frg diff --git a/suite/components/nsSuiteGlue.js b/suite/components/nsSuiteGlue.js --- a/suite/components/nsSuiteGlue.js +++ b/suite/components/nsSuiteGlue.js @@ -55,16 +55,50 @@ XPCOMUtils.defineLazyModuleGetter(this, "resource://gre/modules/AppConstants.jsm"); XPCOMUtils.defineLazyGetter(this, "DebuggerServer", () => { var tmp = {}; ChromeUtils.import("resource://devtools/shared/Loader.jsm", tmp); 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) { + Cu.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_SEC = 15 * 60; // Minimum interval between backups. We try to not create more than one backup // per interval. const BOOKMARKS_BACKUP_MIN_INTERVAL_DAYS = 1; // Devtools Preferences @@ -180,17 +214,17 @@ SuiteGlue.prototype = { case "profile-after-change": this._onProfileAfterChange(); break; case "final-ui-startup": this._onProfileStartup(); this._promptForMasterPassword(); this._checkForNewAddons(); Services.search.init(); - LoginManagerParent.init(); + listeners.init(); Cc["@mozilla.org/globalmessagemanager;1"] .getService(Ci.nsIMessageListenerManager) .loadFrameScript("chrome://navigator/content/content.js", true); ChromeUtils.import("resource://gre/modules/NotificationDB.jsm"); break; case "sessionstore-windows-restored": this._onBrowserStartup(subject);