From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- .../android/actors/GeckoViewAutoFillParent.sys.mjs | 89 ++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 mobile/android/actors/GeckoViewAutoFillParent.sys.mjs (limited to 'mobile/android/actors/GeckoViewAutoFillParent.sys.mjs') diff --git a/mobile/android/actors/GeckoViewAutoFillParent.sys.mjs b/mobile/android/actors/GeckoViewAutoFillParent.sys.mjs new file mode 100644 index 0000000000..d7248d61fe --- /dev/null +++ b/mobile/android/actors/GeckoViewAutoFillParent.sys.mjs @@ -0,0 +1,89 @@ +/* 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/. */ + +import { GeckoViewActorParent } from "resource://gre/modules/GeckoViewActorParent.sys.mjs"; + +const lazy = {}; + +ChromeUtils.defineESModuleGetters(lazy, { + gAutofillManager: "resource://gre/modules/GeckoViewAutofill.sys.mjs", +}); + +export class GeckoViewAutoFillParent extends GeckoViewActorParent { + constructor() { + super(); + this.sessionId = Services.uuid.generateUUID().toString().slice(1, -1); // discard the surrounding curly braces + } + + get rootActor() { + return this.browsingContext.top.currentWindowGlobal.getActor( + "GeckoViewAutoFill" + ); + } + + get autofill() { + return lazy.gAutofillManager.get(this.sessionId); + } + + add(node) { + // We will start a new session if the current one does not exist. + const autofill = lazy.gAutofillManager.ensure( + this.sessionId, + this.eventDispatcher + ); + return autofill?.add(node); + } + + focus(node) { + this.autofill?.focus(node); + } + + commit(node) { + this.autofill?.commit(node); + } + + update(node) { + this.autofill?.update(node); + } + + clear() { + lazy.gAutofillManager.delete(this.sessionId); + } + + async receiveMessage(aMessage) { + const { name } = aMessage; + debug`receiveMessage ${name}`; + + // We need to re-route all messages through the root actor to ensure that we + // have a consistent sessionId for the entire browsingContext tree. + switch (name) { + case "Add": { + return this.rootActor.add(aMessage.data.node); + } + case "Focus": { + this.rootActor.focus(aMessage.data.node); + break; + } + case "Update": { + this.rootActor.update(aMessage.data.node); + break; + } + case "Commit": { + this.rootActor.commit(aMessage.data.node); + break; + } + case "Clear": { + if (this.browsingContext === this.browsingContext.top) { + this.clear(); + } + break; + } + } + + return null; + } +} + +const { debug, warn } = + GeckoViewAutoFillParent.initLogging("GeckoViewAutoFill"); -- cgit v1.2.3