mirror of
https://github.com/zen-browser/desktop.git
synced 2026-08-27 17:01:30 +00:00
chore: Refactor JS actors into their own modules, b=no-bug, c=common, glance, mods
This commit is contained in:
5
src/zen/common/Components.manifest
Normal file
5
src/zen/common/Components.manifest
Normal file
@@ -0,0 +1,5 @@
|
||||
# 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/.
|
||||
|
||||
category browser-before-ui-startup resource:///modules/ZenActorsManager.sys.mjs gZenActorsManager.init
|
||||
@@ -1,34 +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/.
|
||||
// Utility to register JSWindowActors
|
||||
|
||||
window.gZenActorsManager = {
|
||||
_actors: new Set(),
|
||||
_lazy: {},
|
||||
|
||||
init() {
|
||||
ChromeUtils.defineESModuleGetters(this._lazy, {
|
||||
ActorManagerParent: 'resource://gre/modules/ActorManagerParent.sys.mjs',
|
||||
});
|
||||
},
|
||||
|
||||
addJSWindowActor(name, data) {
|
||||
if (!this._lazy.ActorManagerParent) {
|
||||
this.init();
|
||||
}
|
||||
if (this._actors.has(name)) {
|
||||
// Actor already registered, nothing to do
|
||||
return;
|
||||
}
|
||||
|
||||
const decl = {};
|
||||
decl[name] = data;
|
||||
try {
|
||||
this._lazy.ActorManagerParent.addJSWindowActors(decl);
|
||||
this._actors.add(name);
|
||||
} catch (e) {
|
||||
console.warn(`Failed to register JSWindowActor: ${e}`);
|
||||
}
|
||||
},
|
||||
};
|
||||
61
src/zen/common/ZenActorsManager.sys.mjs
Normal file
61
src/zen/common/ZenActorsManager.sys.mjs
Normal file
@@ -0,0 +1,61 @@
|
||||
// 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/.
|
||||
// Utility to register JSWindowActors
|
||||
|
||||
import { ActorManagerParent } from 'resource://gre/modules/ActorManagerParent.sys.mjs';
|
||||
|
||||
/**
|
||||
* Fission-compatible JSProcess implementations.
|
||||
* Each actor options object takes the form of a ProcessActorOptions dictionary.
|
||||
* Detailed documentation of these options is in dom/docs/ipc/jsactors.rst,
|
||||
* available at https://firefox-source-docs.mozilla.org/dom/ipc/jsactors.html
|
||||
*/
|
||||
let JSPROCESSACTORS = {};
|
||||
|
||||
/**
|
||||
* Fission-compatible JSWindowActor implementations.
|
||||
* Detailed documentation of these options is in dom/docs/ipc/jsactors.rst,
|
||||
* available at https://firefox-source-docs.mozilla.org/dom/ipc/jsactors.html
|
||||
*/
|
||||
let JSWINDOWACTORS = {
|
||||
ZenModsMarketplace: {
|
||||
parent: {
|
||||
esModuleURI: 'resource:///actors/ZenModsMarketplaceParent.sys.mjs',
|
||||
},
|
||||
child: {
|
||||
esModuleURI: 'resource:///actors/ZenModsMarketplaceChild.sys.mjs',
|
||||
events: {
|
||||
DOMContentLoaded: {},
|
||||
},
|
||||
},
|
||||
matches: [
|
||||
...Services.prefs.getStringPref('zen.injections.match-urls').split(','),
|
||||
'about:preferences',
|
||||
],
|
||||
},
|
||||
ZenGlance: {
|
||||
parent: {
|
||||
esModuleURI: 'resource:///actors/ZenGlanceParent.sys.mjs',
|
||||
},
|
||||
child: {
|
||||
esModuleURI: 'resource:///actors/ZenGlanceChild.sys.mjs',
|
||||
events: {
|
||||
DOMContentLoaded: {},
|
||||
keydown: {
|
||||
capture: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
allFrames: true,
|
||||
matches: ['*://*/*'],
|
||||
enablePreference: 'zen.glance.enabled',
|
||||
},
|
||||
};
|
||||
|
||||
export let gZenActorsManager = {
|
||||
init() {
|
||||
ActorManagerParent.addJSProcessActors(JSPROCESSACTORS);
|
||||
ActorManagerParent.addJSWindowActors(JSWINDOWACTORS);
|
||||
},
|
||||
};
|
||||
@@ -3,6 +3,7 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
EXTRA_JS_MODULES += [
|
||||
"ZenActorsManager.sys.mjs",
|
||||
"ZenCustomizableUI.sys.mjs",
|
||||
"ZenUIMigration.sys.mjs",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user