mirror of
https://github.com/bitwarden/browser
synced 2025-12-13 14:53:33 +00:00
remove ols safari api dependencies
This commit is contained in:
@@ -9,7 +9,6 @@ import { PasswordGenerationService } from 'jslib/abstractions/passwordGeneration
|
|||||||
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
|
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
|
||||||
|
|
||||||
export default class CommandsBackground {
|
export default class CommandsBackground {
|
||||||
private commands: any;
|
|
||||||
private isSafari: boolean;
|
private isSafari: boolean;
|
||||||
private isEdge: boolean;
|
private isEdge: boolean;
|
||||||
private isVivaldi: boolean;
|
private isVivaldi: boolean;
|
||||||
@@ -20,22 +19,17 @@ export default class CommandsBackground {
|
|||||||
this.isSafari = this.platformUtilsService.isSafari();
|
this.isSafari = this.platformUtilsService.isSafari();
|
||||||
this.isEdge = this.platformUtilsService.isEdge();
|
this.isEdge = this.platformUtilsService.isEdge();
|
||||||
this.isVivaldi = this.platformUtilsService.isVivaldi();
|
this.isVivaldi = this.platformUtilsService.isVivaldi();
|
||||||
this.commands = this.isSafari ? safari.application : chrome.commands;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
if (!this.commands && !this.isEdge) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.isSafari || this.isEdge || this.isVivaldi) {
|
if (this.isSafari || this.isEdge || this.isVivaldi) {
|
||||||
BrowserApi.messageListener(async (msg: any, sender: any, sendResponse: any) => {
|
BrowserApi.messageListener(async (msg: any, sender: any, sendResponse: any) => {
|
||||||
if (msg.command === 'keyboardShortcutTriggered' && msg.shortcut) {
|
if (msg.command === 'keyboardShortcutTriggered' && msg.shortcut) {
|
||||||
await this.processCommand(msg.shortcut, sender);
|
await this.processCommand(msg.shortcut, sender);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else if (chrome && chrome.commands && !this.isEdge) {
|
||||||
this.commands.onCommand.addListener(async (command: any) => {
|
chrome.commands.onCommand.addListener(async (command: any) => {
|
||||||
await this.processCommand(command);
|
await this.processCommand(command);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -367,6 +367,10 @@ export default class MainBackground {
|
|||||||
|
|
||||||
async openPopup() {
|
async openPopup() {
|
||||||
// Chrome APIs cannot open popup
|
// Chrome APIs cannot open popup
|
||||||
|
|
||||||
|
// TODO: Do we need to open this popup?
|
||||||
|
|
||||||
|
/*
|
||||||
if (!this.isSafari || !safari.extension.toolbarItems || !safari.extension.toolbarItems.length) {
|
if (!this.isSafari || !safari.extension.toolbarItems || !safari.extension.toolbarItems.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -378,6 +382,7 @@ export default class MainBackground {
|
|||||||
if (activeToolBars && activeToolBars.length) {
|
if (activeToolBars && activeToolBars.length) {
|
||||||
activeToolBars[0].showPopover();
|
activeToolBars[0].showPopover();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
async reseedStorage() {
|
async reseedStorage() {
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export default class RuntimeBackground {
|
|||||||
private analytics: Analytics, private notificationsService: NotificationsService,
|
private analytics: Analytics, private notificationsService: NotificationsService,
|
||||||
private systemService: SystemService, private lockService: LockService) {
|
private systemService: SystemService, private lockService: LockService) {
|
||||||
this.isSafari = this.platformUtilsService.isSafari();
|
this.isSafari = this.platformUtilsService.isSafari();
|
||||||
this.runtime = this.isSafari ? safari.application : chrome.runtime;
|
this.runtime = this.isSafari ? {} : chrome.runtime;
|
||||||
|
|
||||||
// onInstalled listener must be wired up before anything else, so we do it in the ctor
|
// onInstalled listener must be wired up before anything else, so we do it in the ctor
|
||||||
if (!this.isSafari) {
|
if (!this.isSafari) {
|
||||||
@@ -56,6 +56,8 @@ export default class RuntimeBackground {
|
|||||||
|
|
||||||
if (this.isSafari) {
|
if (this.isSafari) {
|
||||||
// Reload the popup when it's opened
|
// Reload the popup when it's opened
|
||||||
|
// TODO
|
||||||
|
/*
|
||||||
this.runtime.addEventListener('popover', (event: any) => {
|
this.runtime.addEventListener('popover', (event: any) => {
|
||||||
const win: Window = event.target.contentWindow;
|
const win: Window = event.target.contentWindow;
|
||||||
let href = win.location.href;
|
let href = win.location.href;
|
||||||
@@ -69,6 +71,7 @@ export default class RuntimeBackground {
|
|||||||
win.location.href = href;
|
win.location.href = href;
|
||||||
}
|
}
|
||||||
}, true);
|
}, true);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.checkOnInstalled();
|
await this.checkOnInstalled();
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export default class TabsBackground {
|
|||||||
|
|
||||||
constructor(private main: MainBackground, private platformUtilsService: PlatformUtilsService) {
|
constructor(private main: MainBackground, private platformUtilsService: PlatformUtilsService) {
|
||||||
this.isSafari = this.platformUtilsService.isSafari();
|
this.isSafari = this.platformUtilsService.isSafari();
|
||||||
this.tabs = this.isSafari ? safari.application : chrome.tabs;
|
this.tabs = this.isSafari ? null : chrome.tabs;
|
||||||
}
|
}
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
@@ -17,6 +17,7 @@ export default class TabsBackground {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.isSafari) {
|
if (this.isSafari) {
|
||||||
|
/*
|
||||||
this.tabs.addEventListener('activate', async (ev: any) => {
|
this.tabs.addEventListener('activate', async (ev: any) => {
|
||||||
await this.main.refreshBadgeAndMenu();
|
await this.main.refreshBadgeAndMenu();
|
||||||
}, true);
|
}, true);
|
||||||
@@ -25,6 +26,7 @@ export default class TabsBackground {
|
|||||||
await this.main.checkNotificationQueue();
|
await this.main.checkNotificationQueue();
|
||||||
await this.main.refreshBadgeAndMenu();
|
await this.main.refreshBadgeAndMenu();
|
||||||
}, true);
|
}, true);
|
||||||
|
*/
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user