Bug 1460047 - 3. Make module resource optional; r?esawin
Some modules such as Scroll and SelectionAction only require a frame
script and not a resource. Make the module resource optional so we can
remove the redundant resources for these modules.
MozReview-Commit-ID: 3uCy4xxInJf
--- a/mobile/android/chrome/geckoview/geckoview.js
+++ b/mobile/android/chrome/geckoview/geckoview.js
@@ -89,17 +89,17 @@ var ModuleManager = {
this._modules.forEach(aCallback, this);
},
_updateSettings(aSettings) {
Object.assign(this._settings, aSettings);
this._frozenSettings = Object.freeze(Object.assign({}, this._settings));
this.forEach(module => {
- if (module.enabled) {
+ if (module.enabled && module.impl) {
module.impl.onSettingsUpdate();
}
});
this._browser.messageManager.sendAsyncMessage("GeckoView:UpdateSettings",
aSettings);
},
@@ -185,17 +185,19 @@ class ModuleInfo {
});
this._onInitPhase = {
frameScript: onInit && onInit.frameScript,
};
this._onEnablePhase = onEnable;
}
onInit() {
- this._impl.onInit();
+ if (this._impl) {
+ this._impl.onInit();
+ }
this._loadPhase(this._onInitPhase);
this._onInitPhase = null;
this.enabled = this._enabledOnInit;
}
/**
* Load resources according to a phase object that contains possible keys,
@@ -212,17 +214,19 @@ class ModuleInfo {
const scope = {};
const global = ChromeUtils.import(aPhase.resource, scope);
const tag = this._name.replace("GeckoView", "GeckoView.");
GeckoViewUtils.initLogging(tag, global);
this._impl = new scope[this._name](this);
}
if (aPhase.frameScript && !this._contentModuleLoaded) {
- this._impl.onLoadContentModule();
+ if (this._impl) {
+ this._impl.onLoadContentModule();
+ }
this._manager.messageManager.loadFrameScript(aPhase.frameScript, true);
this._contentModuleLoaded = true;
}
}
get manager() {
return this._manager;
}
@@ -239,35 +243,40 @@ class ModuleInfo {
return this._enabled;
}
set enabled(aEnabled) {
if (aEnabled === this._enabled) {
return;
}
- if (!aEnabled) {
+ if (!aEnabled && this._impl) {
this._impl.onDisable();
}
this._enabled = aEnabled;
if (aEnabled) {
this._loadPhase(this._onEnablePhase);
this._onEnablePhase = null;
- this._impl.onEnable();
- this._impl.onSettingsUpdate();
+ if (this._impl) {
+ this._impl.onEnable();
+ this._impl.onSettingsUpdate();
+ }
}
this._updateContentModuleState(/* includeSettings */ aEnabled);
}
onContentModuleLoaded() {
this._updateContentModuleState(/* includeSettings */ true);
- this._impl.onContentModuleLoaded();
+
+ if (this._impl) {
+ this._impl.onContentModuleLoaded();
+ }
}
_updateContentModuleState(aIncludeSettings) {
this._manager.messageManager.sendAsyncMessage("GeckoView:UpdateModuleState", {
module: this._name,
enabled: this.enabled,
settings: aIncludeSettings ? this._manager.settings : null,
});
@@ -308,23 +317,21 @@ function startup() {
}, {
name: "GeckoViewProgress",
onEnable: {
resource: "resource://gre/modules/GeckoViewProgress.jsm",
},
}, {
name: "GeckoViewScroll",
onEnable: {
- resource: "resource://gre/modules/GeckoViewScroll.jsm",
frameScript: "chrome://geckoview/content/GeckoViewScrollContent.js",
},
}, {
name: "GeckoViewSelectionAction",
onEnable: {
- resource: "resource://gre/modules/GeckoViewSelectionAction.jsm",
frameScript: "chrome://geckoview/content/GeckoViewSelectionActionContent.js",
},
}, {
name: "GeckoViewSettings",
onInit: {
resource: "resource://gre/modules/GeckoViewSettings.jsm",
frameScript: "chrome://geckoview/content/GeckoViewContentSettings.js",
},
deleted file mode 100644
--- a/mobile/android/modules/geckoview/GeckoViewScroll.jsm
+++ /dev/null
@@ -1,16 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-var EXPORTED_SYMBOLS = ["GeckoViewScroll"];
-
-ChromeUtils.import("resource://gre/modules/GeckoViewModule.jsm");
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-
-class GeckoViewScroll extends GeckoViewModule {
- onEnable() {
- debug `onEnable`;
- }
-}
deleted file mode 100644
--- a/mobile/android/modules/geckoview/GeckoViewSelectionAction.jsm
+++ /dev/null
@@ -1,17 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-var EXPORTED_SYMBOLS = ["GeckoViewSelectionAction"];
-
-ChromeUtils.import("resource://gre/modules/GeckoViewModule.jsm");
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-
-// Handles inter-op between accessible carets and GeckoSession.
-class GeckoViewSelectionAction extends GeckoViewModule {
- onEnable() {
- debug `onEnable`;
- }
-}
--- a/mobile/android/modules/geckoview/moz.build
+++ b/mobile/android/modules/geckoview/moz.build
@@ -8,17 +8,15 @@ EXTRA_JS_MODULES += [
'AndroidLog.jsm',
'GeckoViewAccessibility.jsm',
'GeckoViewContent.jsm',
'GeckoViewContentModule.jsm',
'GeckoViewModule.jsm',
'GeckoViewNavigation.jsm',
'GeckoViewProgress.jsm',
'GeckoViewRemoteDebugger.jsm',
- 'GeckoViewScroll.jsm',
- 'GeckoViewSelectionAction.jsm',
'GeckoViewSettings.jsm',
'GeckoViewTab.jsm',
'GeckoViewTrackingProtection.jsm',
'GeckoViewUtils.jsm',
'LoadURIDelegate.jsm',
'Messaging.jsm',
]