mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-26 11:45:37 +00:00
Bug 1460046 - Make child modules behave the same way as parent modules; r=esawin
Update content modules to use the "GeckoView:UpdateModuleState" message instead of "GeckoView:Register"/"GeckoView:Unregister", similar to what we already do for parent modules. Also only call onSettingsUpdate in content module when the module is enabled, similar to what we already do for parent modules. MozReview-Commit-ID: C30W9iEd7Rz --HG-- extra : rebase_source : 0ff689e9e03655df0d7206ad0bb49b751bd0119d
This commit is contained in:
parent
4ff74a279c
commit
3a0567907f
@ -84,13 +84,13 @@ var ModuleManager = {
|
||||
this._frozenSettings = Object.freeze(Object.assign({}, this._settings));
|
||||
|
||||
this.forEach(module => {
|
||||
if (!module.enabled) {
|
||||
return;
|
||||
}
|
||||
if (module.enabled) {
|
||||
module.impl.onSettingsUpdate();
|
||||
this._browser.messageManager.sendAsyncMessage("GeckoView:UpdateSettings",
|
||||
this._settings);
|
||||
}
|
||||
});
|
||||
|
||||
this._browser.messageManager.sendAsyncMessage("GeckoView:UpdateSettings",
|
||||
aSettings);
|
||||
},
|
||||
|
||||
onEvent(aEvent, aData, aCallback) {
|
||||
@ -175,9 +175,6 @@ class ModuleInfo {
|
||||
}
|
||||
|
||||
if (!aEnabled) {
|
||||
this._manager.messageManager.sendAsyncMessage("GeckoView:Unregister", {
|
||||
module: this._name,
|
||||
});
|
||||
this._impl.onDisable();
|
||||
}
|
||||
|
||||
@ -186,11 +183,13 @@ class ModuleInfo {
|
||||
if (aEnabled) {
|
||||
this._impl.onEnable();
|
||||
this._impl.onSettingsUpdate();
|
||||
this._manager.messageManager.sendAsyncMessage("GeckoView:Register", {
|
||||
module: this._name,
|
||||
settings: this._manager.settings,
|
||||
});
|
||||
}
|
||||
|
||||
this._manager.messageManager.sendAsyncMessage("GeckoView:UpdateModuleState", {
|
||||
module: this._name,
|
||||
enabled: aEnabled,
|
||||
settings: aEnabled ? this._manager.settings : null,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,8 @@ class GeckoViewContentModule {
|
||||
constructor(aModuleName, aGlobal) {
|
||||
this.moduleName = aModuleName;
|
||||
this.messageManager = aGlobal;
|
||||
this.enabled = false;
|
||||
this.settings = {};
|
||||
|
||||
if (!aGlobal._gvEventDispatcher) {
|
||||
aGlobal._gvEventDispatcher =
|
||||
@ -42,24 +44,40 @@ class GeckoViewContentModule {
|
||||
this.messageManager.addMessageListener(
|
||||
"GeckoView:UpdateSettings",
|
||||
aMsg => {
|
||||
this.settings = aMsg.data;
|
||||
Object.assign(this.settings, aMsg.data);
|
||||
if (this.enabled) {
|
||||
this.onSettingsUpdate();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
this.messageManager.addMessageListener(
|
||||
"GeckoView:Register",
|
||||
"GeckoView:UpdateModuleState",
|
||||
aMsg => {
|
||||
if (aMsg.data.module == this.moduleName) {
|
||||
this.settings = aMsg.data.settings;
|
||||
if (aMsg.data.module !== this.moduleName) {
|
||||
return;
|
||||
}
|
||||
|
||||
const {enabled, settings} = aMsg.data;
|
||||
|
||||
if (settings) {
|
||||
Object.assign(this.settings, settings);
|
||||
}
|
||||
|
||||
if (enabled !== this.enabled) {
|
||||
if (!enabled) {
|
||||
this.onDisable();
|
||||
}
|
||||
|
||||
this.enabled = enabled;
|
||||
|
||||
if (enabled) {
|
||||
this.onEnable();
|
||||
}
|
||||
}
|
||||
);
|
||||
this.messageManager.addMessageListener(
|
||||
"GeckoView:Unregister",
|
||||
aMsg => {
|
||||
if (aMsg.data.module == this.moduleName) {
|
||||
this.onDisable();
|
||||
|
||||
if (settings && enabled) {
|
||||
this.onSettingsUpdate();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user