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 --- browser/actors/ContextMenuParent.sys.mjs | 117 +++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 browser/actors/ContextMenuParent.sys.mjs (limited to 'browser/actors/ContextMenuParent.sys.mjs') diff --git a/browser/actors/ContextMenuParent.sys.mjs b/browser/actors/ContextMenuParent.sys.mjs new file mode 100644 index 0000000000..4c67bc75ef --- /dev/null +++ b/browser/actors/ContextMenuParent.sys.mjs @@ -0,0 +1,117 @@ +/* vim: set ts=2 sw=2 sts=2 et tw=80: */ +/* 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/. */ + +const lazy = {}; + +ChromeUtils.defineESModuleGetters(lazy, { + FirefoxRelay: "resource://gre/modules/FirefoxRelay.sys.mjs", +}); + +export class ContextMenuParent extends JSWindowActorParent { + receiveMessage(message) { + let browser = this.manager.rootFrameLoader.ownerElement; + let win = browser.ownerGlobal; + // It's possible that the associated with this + // ContextMenu message doesn't belong to a window that actually + // loads nsContextMenu.js. In that case, try to find the chromeEventHandler, + // since that'll likely be the "top" , and then use its window's + // nsContextMenu instance instead. + if (!win.openContextMenu) { + let topBrowser = browser.ownerGlobal.docShell.chromeEventHandler; + win = topBrowser.ownerGlobal; + } + + message.data.context.showRelay &&= lazy.FirefoxRelay.isEnabled; + + win.openContextMenu(message, browser, this); + } + + hiding() { + try { + this.sendAsyncMessage("ContextMenu:Hiding", {}); + } catch (e) { + // This will throw if the content goes away while the + // context menu is still open. + } + } + + reloadFrame(targetIdentifier, forceReload) { + this.sendAsyncMessage("ContextMenu:ReloadFrame", { + targetIdentifier, + forceReload, + }); + } + + getImageText(targetIdentifier) { + return this.sendQuery("ContextMenu:GetImageText", { + targetIdentifier, + }); + } + + toggleRevealPassword(targetIdentifier) { + this.sendAsyncMessage("ContextMenu:ToggleRevealPassword", { + targetIdentifier, + }); + } + + async useRelayMask(targetIdentifier, origin) { + if (!origin) { + return; + } + + const windowGlobal = this.manager.browsingContext.currentWindowGlobal; + const browser = windowGlobal.rootFrameLoader.ownerElement; + const emailMask = await lazy.FirefoxRelay.generateUsername(browser, origin); + if (emailMask) { + this.sendAsyncMessage("ContextMenu:UseRelayMask", { + targetIdentifier, + emailMask, + }); + } + } + + reloadImage(targetIdentifier) { + this.sendAsyncMessage("ContextMenu:ReloadImage", { targetIdentifier }); + } + + getFrameTitle(targetIdentifier) { + return this.sendQuery("ContextMenu:GetFrameTitle", { targetIdentifier }); + } + + mediaCommand(targetIdentifier, command, data) { + let windowGlobal = this.manager.browsingContext.currentWindowGlobal; + let browser = windowGlobal.rootFrameLoader.ownerElement; + let win = browser.ownerGlobal; + let windowUtils = win.windowUtils; + this.sendAsyncMessage("ContextMenu:MediaCommand", { + targetIdentifier, + command, + data, + handlingUserInput: windowUtils.isHandlingUserInput, + }); + } + + canvasToBlobURL(targetIdentifier) { + return this.sendQuery("ContextMenu:Canvas:ToBlobURL", { targetIdentifier }); + } + + saveVideoFrameAsImage(targetIdentifier) { + return this.sendQuery("ContextMenu:SaveVideoFrameAsImage", { + targetIdentifier, + }); + } + + setAsDesktopBackground(targetIdentifier) { + return this.sendQuery("ContextMenu:SetAsDesktopBackground", { + targetIdentifier, + }); + } + + getSearchFieldBookmarkData(targetIdentifier) { + return this.sendQuery("ContextMenu:SearchFieldBookmarkData", { + targetIdentifier, + }); + } +} -- cgit v1.2.3