зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1358921: Lazily load LoginManagerParent.jsm when first needed. r=florian
MozReview-Commit-ID: 4Aq0mBGXBX3 --HG-- extra : rebase_source : eb8bdb8efb65d758e1ddf5d6ffd6d07736763139
This commit is contained in:
Родитель
df4bfbccad
Коммит
22688fc220
|
@ -146,6 +146,14 @@ const listeners = {
|
|||
"FormValidation:ShowPopup": ["FormValidationHandler"],
|
||||
"FormValidation:HidePopup": ["FormValidationHandler"],
|
||||
"Prompt:Open": ["RemotePrompt"],
|
||||
// PLEASE KEEP THIS LIST IN SYNC WITH THE LISTENERS ADDED IN LoginManagerParent.init
|
||||
"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 LISTENERS ADDED IN LoginManagerParent.init
|
||||
"WCCR:registerProtocolHandler": ["Feeds"],
|
||||
"WCCR:registerContentHandler": ["Feeds"],
|
||||
"rtcpeer:CancelRequest": ["webrtcUI"],
|
||||
|
@ -167,13 +175,15 @@ const listeners = {
|
|||
},
|
||||
|
||||
receiveMessage(modules, data) {
|
||||
let val;
|
||||
for (let module of modules[data.name]) {
|
||||
try {
|
||||
global[module].receiveMessage(data);
|
||||
val = global[module].receiveMessage(data) || val;
|
||||
} catch (e) {
|
||||
Cu.reportError(e);
|
||||
}
|
||||
}
|
||||
return val;
|
||||
},
|
||||
|
||||
init() {
|
||||
|
@ -597,7 +607,6 @@ BrowserGlue.prototype = {
|
|||
BrowserUsageTelemetry.init();
|
||||
BrowserUITelemetry.init();
|
||||
|
||||
LoginManagerParent.init();
|
||||
ReaderParent.init();
|
||||
|
||||
SelfSupportBackend.init();
|
||||
|
|
|
@ -36,25 +36,24 @@ var LoginManagerParent = {
|
|||
*/
|
||||
_recipeManager: null,
|
||||
|
||||
// This should only be called on Android. Listeners are added in
|
||||
// nsBrowserGlue.js on desktop. Please make sure that the list of
|
||||
// listeners added here stays in sync with the listeners added in
|
||||
// nsBrowserGlue when you change either.
|
||||
init() {
|
||||
let mm = Cc["@mozilla.org/globalmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageListenerManager);
|
||||
// PLEASE KEEP THIS LIST IN SYNC WITH THE LISTENERS ADDED IN nsBrowserGlue
|
||||
mm.addMessageListener("RemoteLogins:findLogins", this);
|
||||
mm.addMessageListener("RemoteLogins:findRecipes", this);
|
||||
mm.addMessageListener("RemoteLogins:onFormSubmit", this);
|
||||
mm.addMessageListener("RemoteLogins:autoCompleteLogins", this);
|
||||
mm.addMessageListener("RemoteLogins:removeLogin", this);
|
||||
mm.addMessageListener("RemoteLogins:insecureLoginFormPresent", this);
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "recipeParentPromise", () => {
|
||||
const { LoginRecipesParent } = Cu.import("resource://gre/modules/LoginRecipes.jsm", {});
|
||||
this._recipeManager = new LoginRecipesParent({
|
||||
defaults: Services.prefs.getStringPref("signon.recipes.path"),
|
||||
});
|
||||
return this._recipeManager.initializationPromise;
|
||||
});
|
||||
// PLEASE KEEP THIS LIST IN SYNC WITH THE LISTENERS ADDED IN nsBrowserGlue
|
||||
},
|
||||
|
||||
// Listeners are added in nsBrowserGlue.js
|
||||
receiveMessage(msg) {
|
||||
let data = msg.data;
|
||||
switch (msg.name) {
|
||||
|
@ -476,3 +475,11 @@ var LoginManagerParent = {
|
|||
.CustomEvent("InsecureLoginFormsStateChange"));
|
||||
},
|
||||
};
|
||||
|
||||
XPCOMUtils.defineLazyGetter(LoginManagerParent, "recipeParentPromise", function() {
|
||||
const { LoginRecipesParent } = Cu.import("resource://gre/modules/LoginRecipes.jsm", {});
|
||||
this._recipeManager = new LoginRecipesParent({
|
||||
defaults: Services.prefs.getStringPref("signon.recipes.path"),
|
||||
});
|
||||
return this._recipeManager.initializationPromise;
|
||||
});
|
||||
|
|
|
@ -373,6 +373,7 @@ if (this.addMessageListener) {
|
|||
// Ignore ok/is in commonInit since they aren't defined in a chrome script.
|
||||
ok = is = () => {}; // eslint-disable-line no-native-reassign
|
||||
|
||||
Cu.import("resource://gre/modules/AppConstants.jsm");
|
||||
Cu.import("resource://gre/modules/LoginHelper.jsm");
|
||||
Cu.import("resource://gre/modules/LoginManagerParent.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
@ -398,7 +399,9 @@ if (this.addMessageListener) {
|
|||
addMessageListener("setupParent", ({selfFilling = false} = {selfFilling: false}) => {
|
||||
// Force LoginManagerParent to init for the tests since it's normally delayed
|
||||
// by apps such as on Android.
|
||||
LoginManagerParent.init();
|
||||
if (AppConstants.platform == "android") {
|
||||
LoginManagerParent.init();
|
||||
}
|
||||
|
||||
commonInit(selfFilling);
|
||||
sendAsyncMessage("doneSetup");
|
||||
|
|
Загрузка…
Ссылка в новой задаче