From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../modules/geckoview/GeckoViewActorParent.sys.mjs | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 mobile/android/modules/geckoview/GeckoViewActorParent.sys.mjs (limited to 'mobile/android/modules/geckoview/GeckoViewActorParent.sys.mjs') diff --git a/mobile/android/modules/geckoview/GeckoViewActorParent.sys.mjs b/mobile/android/modules/geckoview/GeckoViewActorParent.sys.mjs new file mode 100644 index 0000000000..c4569fb052 --- /dev/null +++ b/mobile/android/modules/geckoview/GeckoViewActorParent.sys.mjs @@ -0,0 +1,51 @@ +/* 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 { GeckoViewUtils } from "resource://gre/modules/GeckoViewUtils.sys.mjs"; + +export class GeckoViewActorParent extends JSWindowActorParent { + static initLogging(aModuleName) { + const tag = aModuleName.replace("GeckoView", ""); + return GeckoViewUtils.initLogging(tag); + } + + get browser() { + return this.browsingContext.top.embedderElement; + } + + get window() { + const { browsingContext } = this; + // If this is a chrome actor, the chrome window will be at + // browsingContext.window. + if (!browsingContext.isContent && browsingContext.window) { + return browsingContext.window; + } + return this.browser?.ownerGlobal; + } + + get eventDispatcher() { + return this.window?.moduleManager.eventDispatcher; + } + + receiveMessage(aMessage) { + if (!this.window) { + // If we have no window, it means that this browsingContext has been + // destroyed already and there's nothing to do here for us. + debug`receiveMessage window destroyed ${aMessage.name} ${aMessage.data?.type}`; + return null; + } + + switch (aMessage.name) { + case "DispatcherMessage": + return this.eventDispatcher.sendRequest(aMessage.data); + case "DispatcherQuery": + return this.eventDispatcher.sendRequestForResult(aMessage.data); + } + + // By default messages are forwarded to the module. + return this.window.moduleManager.onMessageFromActor(this.name, aMessage); + } +} + +const { debug, warn } = GeckoViewUtils.initLogging("GeckoViewActorParent"); -- cgit v1.2.3