Bug 1402688 - Port part of Bug 1358921. Move LoginManagerParent init code to nsSuiteGlue.js. r=IanN a=IanN
authorFrank-Rainer Grahl <frgrahl@gmx.net>
Tue, 03 Oct 2017 13:48:14 +0200
changeset 29796 8d15df25387ffe060b05e32414357ae672aa045f
parent 29795 c12e6f8c6f73a0c74e4f316637af54c86d82f875
child 29797 f1b007502af6cee39e705049ec5940aacb91f141
push id378
push userclokep@gmail.com
push dateMon, 13 Nov 2017 18:45:35 +0000
reviewersIanN, IanN
bugs1402688, 1358921
Bug 1402688 - Port part of Bug 1358921. Move LoginManagerParent init code to nsSuiteGlue.js. r=IanN a=IanN
suite/common/src/nsSuiteGlue.js
--- a/suite/common/src/nsSuiteGlue.js
+++ b/suite/common/src/nsSuiteGlue.js
@@ -35,16 +35,50 @@ XPCOMUtils.defineLazyModuleGetter(this, 
 
 
 XPCOMUtils.defineLazyGetter(this, "DebuggerServer", () => {
   var tmp = {};
   Components.utils.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) {
+        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;
 // Minimum interval in milliseconds between backups.
 const BOOKMARKS_BACKUP_INTERVAL = 86400 * 1000;
 // Maximum number of backups to create.  Old ones will be purged.
 const BOOKMARKS_BACKUP_MAX_BACKUPS = 10;
 // Devtools Preferences
@@ -189,17 +223,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();
         Components.classes["@mozilla.org/globalmessagemanager;1"]
                   .getService(Components.interfaces.nsIMessageListenerManager)
                   .loadFrameScript("chrome://navigator/content/content.js", true);
         Components.utils.import("resource://gre/modules/NotificationDB.jsm");
         Components.utils.import("resource://gre/modules/Downloads.jsm");
         Components.utils.import("resource://gre/modules/DownloadIntegration.jsm");
         DownloadIntegration.shouldPersistDownload = function() { return true; }
         Downloads.getList(Downloads.ALL).then(list => list.addView(this))