bitwarden-estensione-browser/apps/browser/src/background/contextMenus.background.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

39 lines
1.2 KiB
TypeScript
Raw Normal View History

2022-02-24 18:14:04 +01:00
import { BrowserApi } from "../browser/browserApi";
import { ContextMenuClickedHandler } from "../browser/context-menu-clicked-handler";
2022-02-24 18:14:04 +01:00
import LockedVaultPendingNotificationsItem from "./models/lockedVaultPendingNotificationsItem";
2017-12-07 22:02:15 +01:00
export default class ContextMenusBackground {
private contextMenus: typeof chrome.contextMenus;
2021-12-21 15:43:35 +01:00
constructor(private contextMenuClickedHandler: ContextMenuClickedHandler) {
2017-12-07 22:02:15 +01:00
this.contextMenus = chrome.contextMenus;
2021-12-21 15:43:35 +01:00
}
init() {
2017-12-07 22:02:15 +01:00
if (!this.contextMenus) {
2021-12-21 15:43:35 +01:00
return;
2017-12-07 22:02:15 +01:00
}
this.contextMenus.onClicked.addListener((info, tab) =>
this.contextMenuClickedHandler.run(info, tab)
2021-12-21 15:43:35 +01:00
);
2021-10-19 16:00:38 +02:00
BrowserApi.messageListener(
"contextmenus.background",
async (
msg: { command: string; data: LockedVaultPendingNotificationsItem },
sender: chrome.runtime.MessageSender,
sendResponse: any
) => {
if (msg.command === "unlockCompleted" && msg.data.target === "contextmenus.background") {
await this.contextMenuClickedHandler.cipherAction(
msg.data.commandToRetry.msg.data,
msg.data.commandToRetry.sender.tab
2021-12-21 15:43:35 +01:00
);
}
}
);
}
2017-12-07 22:02:15 +01:00
}