Bug 1358921: Lazily load FormValidationHandler.jsm when first needed. r=florian
MozReview-Commit-ID: GI33wkhutgP
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -130,16 +130,18 @@ const listeners = {
"webrtc:UpdateGlobalIndicators": ["webrtcUI"],
"webrtc:UpdatingIndicators": ["webrtcUI"],
},
mm: {
"AboutHome:MaybeShowAutoMigrationUndoNotification": ["AboutHome"],
"AboutHome:RequestUpdate": ["AboutHome"],
"ContentSearch": ["ContentSearch"],
+ "FormValidation:ShowPopup": ["FormValidationHandler"],
+ "FormValidation:HidePopup": ["FormValidationHandler"],
"rtcpeer:CancelRequest": ["webrtcUI"],
"rtcpeer:Request": ["webrtcUI"],
"webrtc:CancelRequest": ["webrtcUI"],
"webrtc:Request": ["webrtcUI"],
"webrtc:StopRecording": ["webrtcUI"],
"webrtc:UpdateBrowserIndicators": ["webrtcUI"],
},
@@ -578,17 +580,16 @@ BrowserGlue.prototype = {
DirectoryLinksProvider.init();
NewTabUtils.init();
NewTabUtils.links.addProvider(DirectoryLinksProvider);
AboutNewTab.init();
SessionStore.init();
BrowserUsageTelemetry.init();
BrowserUITelemetry.init();
- FormValidationHandler.init();
ContentClick.init();
RemotePrompt.init();
Feeds.init();
ContentPrefServiceParent.init();
LoginManagerParent.init();
ReaderParent.init();
@@ -967,17 +968,16 @@ BrowserGlue.prototype = {
}
}
BrowserUsageTelemetry.uninit();
SelfSupportBackend.uninit();
PageThumbs.uninit();
AboutNewTab.uninit();
NewTabUtils.uninit();
- FormValidationHandler.uninit();
AutoCompletePopup.uninit();
DateTimePickerHelper.uninit();
},
_initServiceDiscovery() {
if (!Services.prefs.getBoolPref("browser.casting.enabled")) {
return;
}
--- a/browser/modules/FormValidationHandler.jsm
+++ b/browser/modules/FormValidationHandler.jsm
@@ -20,38 +20,30 @@ var FormValidationHandler =
{
_panel: null,
_anchor: null,
/*
* Public apis
*/
- init() {
- let mm = Cc["@mozilla.org/globalmessagemanager;1"].getService(Ci.nsIMessageListenerManager);
- mm.addMessageListener("FormValidation:ShowPopup", this);
- mm.addMessageListener("FormValidation:HidePopup", this);
- },
-
uninit() {
- let mm = Cc["@mozilla.org/globalmessagemanager;1"].getService(Ci.nsIMessageListenerManager);
- mm.removeMessageListener("FormValidation:ShowPopup", this);
- mm.removeMessageListener("FormValidation:HidePopup", this);
this._panel = null;
this._anchor = null;
},
hidePopup() {
this._hidePopup();
},
/*
* Events
*/
+ // Listeners are added in nsBrowserGlue.js
receiveMessage(aMessage) {
let window = aMessage.target.ownerGlobal;
let json = aMessage.json;
let tabBrowser = window.gBrowser;
switch (aMessage.name) {
case "FormValidation:ShowPopup":
// target is the <browser>, make sure we're receiving a message
// from the foreground tab.