1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-18 17:23:37 +00:00

Remove old IE Edge hacks

This commit is contained in:
Chad Scharf
2020-09-15 10:50:45 -04:00
parent 8efb46eca2
commit dbbd07641a
20 changed files with 49 additions and 1271 deletions

View File

@@ -10,25 +10,23 @@ import { VaultTimeoutService } from 'jslib/abstractions/vaultTimeout.service';
export default class CommandsBackground {
private isSafari: boolean;
private isEdge: boolean;
private isVivaldi: boolean;
constructor(private main: MainBackground, private passwordGenerationService: PasswordGenerationService,
private platformUtilsService: PlatformUtilsService, private analytics: Analytics,
private vaultTimeoutService: VaultTimeoutService) {
this.isSafari = this.platformUtilsService.isSafari();
this.isEdge = this.platformUtilsService.isEdge();
this.isVivaldi = this.platformUtilsService.isVivaldi();
}
async init() {
if (this.isSafari || this.isEdge || this.isVivaldi) {
if (this.isSafari || this.isVivaldi) {
BrowserApi.messageListener('commands.background', async (msg: any, sender: any, sendResponse: any) => {
if (msg.command === 'keyboardShortcutTriggered' && msg.shortcut) {
await this.processCommand(msg.shortcut, sender);
}
});
} else if (chrome && chrome.commands && !this.isEdge) {
} else if (chrome && chrome.commands) {
chrome.commands.onCommand.addListener(async (command: any) => {
await this.processCommand(command);
});
@@ -52,11 +50,6 @@ export default class CommandsBackground {
}
private async generatePasswordToClipboard() {
if (this.isEdge) {
// Edge does not support access to clipboard from background
return;
}
const options = (await this.passwordGenerationService.getOptions())[0];
const password = await this.passwordGenerationService.generatePassword(options);
this.platformUtilsService.copyToClipboard(password, { window: window });

View File

@@ -165,7 +165,7 @@ export default class MainBackground {
this.storageService, this.i18nService, this.cipherService);
this.collectionService = new CollectionService(this.cryptoService, this.userService, this.storageService,
this.i18nService);
this.searchService = new SearchService(this.cipherService, this.platformUtilsService);
this.searchService = new SearchService(this.cipherService);
this.stateService = new StateService();
this.policyService = new PolicyService(this.userService, this.storageService);
this.vaultTimeoutService = new VaultTimeoutService(this.cipherService, this.folderService,
@@ -441,48 +441,45 @@ export default class MainBackground {
title: this.i18nService.t('autoFill'),
});
// Edge does not support writing to the clipboard from background
if (!this.platformUtilsService.isEdge()) {
await this.contextMenusCreate({
type: 'normal',
id: 'copy-username',
parentId: 'root',
contexts: ['all'],
title: this.i18nService.t('copyUsername'),
});
await this.contextMenusCreate({
type: 'normal',
id: 'copy-password',
parentId: 'root',
contexts: ['all'],
title: this.i18nService.t('copyPassword'),
});
if (await this.userService.canAccessPremium()) {
await this.contextMenusCreate({
type: 'normal',
id: 'copy-username',
id: 'copy-totp',
parentId: 'root',
contexts: ['all'],
title: this.i18nService.t('copyUsername'),
});
await this.contextMenusCreate({
type: 'normal',
id: 'copy-password',
parentId: 'root',
contexts: ['all'],
title: this.i18nService.t('copyPassword'),
});
if (await this.userService.canAccessPremium()) {
await this.contextMenusCreate({
type: 'normal',
id: 'copy-totp',
parentId: 'root',
contexts: ['all'],
title: this.i18nService.t('copyVerificationCode'),
});
}
await this.contextMenusCreate({
type: 'separator',
parentId: 'root',
});
await this.contextMenusCreate({
type: 'normal',
id: 'generate-password',
parentId: 'root',
contexts: ['all'],
title: this.i18nService.t('generatePasswordCopied'),
title: this.i18nService.t('copyVerificationCode'),
});
}
await this.contextMenusCreate({
type: 'separator',
parentId: 'root',
});
await this.contextMenusCreate({
type: 'normal',
id: 'generate-password',
parentId: 'root',
contexts: ['all'],
title: this.i18nService.t('generatePasswordCopied'),
});
this.buildingContextMenu = false;
}