1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-06-27 10:46:02 +02:00
bitwarden-browser/apps/browser/src/autofill/background/context-menus.background.ts
Cesar Gonzalez 0b9a2775f0
[PM-5043] Update ownership of code to autofill team (#7017)
* [PM-5043] Update owernship of code belonging to autofill team

* [PM-5043] Updating location of webRequest.background.ts file to belong to autofill team

* [PM-5043] Updating location of autofill component settings within the popup
2023-11-30 19:59:33 +00:00

38 lines
1.2 KiB
TypeScript

import { BrowserApi } from "../../platform/browser/browser-api";
import { ContextMenuClickedHandler } from "../browser/context-menu-clicked-handler";
import LockedVaultPendingNotificationsItem from "../notification/models/locked-vault-pending-notifications-item";
export default class ContextMenusBackground {
private contextMenus: typeof chrome.contextMenus;
constructor(private contextMenuClickedHandler: ContextMenuClickedHandler) {
this.contextMenus = chrome.contextMenus;
}
init() {
if (!this.contextMenus) {
return;
}
this.contextMenus.onClicked.addListener((info, tab) =>
this.contextMenuClickedHandler.run(info, tab),
);
BrowserApi.messageListener(
"contextmenus.background",
(
msg: { command: string; data: LockedVaultPendingNotificationsItem },
sender: chrome.runtime.MessageSender,
) => {
if (msg.command === "unlockCompleted" && msg.data.target === "contextmenus.background") {
this.contextMenuClickedHandler
.cipherAction(msg.data.commandToRetry.msg.data, msg.data.commandToRetry.sender.tab)
.then(() => {
BrowserApi.tabSendMessageData(sender.tab, "closeNotificationBar");
});
}
},
);
}
}