mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 07:43:35 +00:00
add support for shortcuts to edge and vivaldi
This commit is contained in:
@@ -12,22 +12,26 @@ import { UtilsService } from 'jslib/services/utils.service';
|
||||
export default class CommandsBackground {
|
||||
private commands: any;
|
||||
private isSafari: boolean;
|
||||
private isEdge: boolean;
|
||||
private isVivaldi: boolean;
|
||||
|
||||
constructor(private main: MainBackground, private passwordGenerationService: PasswordGenerationService,
|
||||
private platformUtilsService: PlatformUtilsService) {
|
||||
this.isSafari = this.platformUtilsService.isSafari();
|
||||
this.isEdge = this.platformUtilsService.isEdge();
|
||||
this.isVivaldi = this.platformUtilsService.isVivaldi();
|
||||
this.commands = this.isSafari ? safari.application : chrome.commands;
|
||||
}
|
||||
|
||||
async init() {
|
||||
if (!this.commands) {
|
||||
if (!this.commands && !this.isEdge) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.isSafari) {
|
||||
if (this.isSafari || this.isEdge || this.isVivaldi) {
|
||||
BrowserApi.messageListener(async (msg: any, sender: any, sendResponse: any) => {
|
||||
if (msg.command === 'keyboardShortcutTriggered' && msg.shortcut) {
|
||||
await this.processCommand(msg.shortcut);
|
||||
await this.processCommand(msg.shortcut, sender);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -54,7 +58,7 @@ export default class CommandsBackground {
|
||||
}
|
||||
|
||||
private async generatePasswordToClipboard() {
|
||||
if (this.isSafari) {
|
||||
if (this.isSafari || this.isEdge) {
|
||||
// Safari does not support access to clipboard from background
|
||||
return;
|
||||
}
|
||||
@@ -88,6 +92,7 @@ export default class CommandsBackground {
|
||||
}
|
||||
|
||||
private async openPopup() {
|
||||
// Chrome APIs cannot open popup
|
||||
if (!this.isSafari || !safari.extension.toolbarItems || !safari.extension.toolbarItems.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user