1
0
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:
Kyle Spearrin
2018-01-17 13:38:32 -05:00
parent 51dffa79a1
commit c942dd3410
3 changed files with 39 additions and 40 deletions

View File

@@ -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;
}