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/. */
5 import { GeckoViewActorParent } from "resource://gre/modules/GeckoViewActorParent.sys.mjs";
9 ChromeUtils.defineESModuleGetters(lazy, {
10 gAutofillManager: "resource://gre/modules/GeckoViewAutofill.sys.mjs",
13 export class GeckoViewAutoFillParent extends GeckoViewActorParent {
16 this.sessionId = Services.uuid.generateUUID().toString().slice(1, -1); // discard the surrounding curly braces
20 return this.browsingContext.top.currentWindowGlobal.getActor(
26 return lazy.gAutofillManager.get(this.sessionId);
30 // We will start a new session if the current one does not exist.
31 const autofill = lazy.gAutofillManager.ensure(
35 return autofill?.add(node);
39 this.autofill?.focus(node);
43 this.autofill?.commit(node);
47 this.autofill?.update(node);
51 lazy.gAutofillManager.delete(this.sessionId);
54 async receiveMessage(aMessage) {
55 const { name } = aMessage;
56 debug`receiveMessage ${name}`;
58 // We need to re-route all messages through the root actor to ensure that we
59 // have a consistent sessionId for the entire browsingContext tree.
62 return this.rootActor.add(aMessage.data.node);
65 this.rootActor.focus(aMessage.data.node);
69 this.rootActor.update(aMessage.data.node);
73 this.rootActor.commit(aMessage.data.node);
77 if (this.browsingContext === this.browsingContext.top) {
88 const { debug, warn } =
89 GeckoViewAutoFillParent.initLogging("GeckoViewAutoFill");