Bug 1402688 - Port part of
Bug 1358921. Move LoginManagerParent init code to nsSuiteGlue.js. r=IanN
--- 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))