NewTabActorRegistry.sys.mjs (1762B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 import { ActorManagerParent } from "resource://gre/modules/ActorManagerParent.sys.mjs"; 6 7 let attributionActorRegister = null; 8 let attributionActorUnregister = null; 9 10 /** 11 * Fission-compatible JSWindowActor implementations. 12 * Detailed documentation of these options is in dom/docs/ipc/jsactors.rst, 13 * available at https://firefox-source-docs.mozilla.org/dom/ipc/jsactors.html 14 */ 15 const JSWINDOWACTORS = { 16 Attribution: { 17 parent: { 18 esModuleURI: 19 "resource://newtab/lib/actors/NewTabAttributionParent.sys.mjs", 20 }, 21 child: { 22 esModuleURI: 23 "resource://newtab/lib/actors/NewTabAttributionChild.sys.mjs", 24 events: { 25 FirefoxConversionNotification: { capture: true, wantUntrusted: true }, 26 }, 27 }, 28 allFrames: true, 29 matches: ["https://*/*", "about:newtab", "about:home"], 30 onAddActor(register, unregister) { 31 attributionActorRegister = register; 32 attributionActorUnregister = unregister; 33 }, 34 }, 35 }; 36 37 export const NewTabActorRegistry = { 38 init() { 39 ActorManagerParent.addJSWindowActors(JSWINDOWACTORS); 40 }, 41 42 /** 43 * Registers the Attribution actor. 44 * Called by NewTabAttributionFeed when attribution is enabled. 45 */ 46 registerAttributionActor() { 47 if (attributionActorRegister) { 48 attributionActorRegister(); 49 } 50 }, 51 52 /** 53 * Unregisters the Attribution actor. 54 * Called by NewTabAttributionFeed when attribution is disabled. 55 */ 56 unregisterAttributionActor() { 57 if (attributionActorUnregister) { 58 attributionActorUnregister(); 59 } 60 }, 61 };