1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-20 10:13:31 +00:00

cleanup for safari

This commit is contained in:
Kyle Spearrin
2019-08-21 09:42:34 -04:00
parent d8f423711a
commit d2083c2665
7 changed files with 15 additions and 153 deletions

View File

@@ -53,7 +53,7 @@ export default class CommandsBackground {
private async generatePasswordToClipboard() {
if (this.isEdge) {
// Safari does not support access to clipboard from background
// Edge does not support access to clipboard from background
return;
}

View File

@@ -200,11 +200,11 @@ export default class MainBackground {
this.runtimeBackground = new RuntimeBackground(this, this.autofillService, this.cipherService,
this.platformUtilsService as BrowserPlatformUtilsService, this.storageService, this.i18nService,
this.analytics, this.notificationsService, this.systemService, this.lockService);
this.tabsBackground = new TabsBackground(this, this.platformUtilsService);
this.commandsBackground = new CommandsBackground(this, this.passwordGenerationService,
this.platformUtilsService, this.analytics, this.lockService);
if (!this.isSafari) {
this.tabsBackground = new TabsBackground(this);
this.contextMenusBackground = new ContextMenusBackground(this, this.cipherService,
this.passwordGenerationService, this.analytics, this.platformUtilsService, this.lockService,
this.eventService);
@@ -224,10 +224,10 @@ export default class MainBackground {
await (this.i18nService as I18nService).init();
await (this.eventService as EventService).init(true);
await this.runtimeBackground.init();
await this.tabsBackground.init();
await this.commandsBackground.init();
if (!this.isSafari) {
await this.tabsBackground.init();
await this.contextMenusBackground.init();
await this.idleBackground.init();
await this.webRequestBackground.init();
@@ -364,20 +364,6 @@ export default class MainBackground {
return;
}
await SafariApp.sendMessageToApp('showPopover');
/*
if (!this.isSafari || !safari.extension.toolbarItems || !safari.extension.toolbarItems.length) {
return;
}
const activeToolBars = safari.extension.toolbarItems.filter((tb: any) => {
return tb.browserWindow === safari.application.activeBrowserWindow;
});
if (activeToolBars && activeToolBars.length) {
activeToolBars[0].showPopover();
}
*/
}
async reseedStorage() {

View File

@@ -54,27 +54,7 @@ export default class RuntimeBackground {
return;
}
if (this.isSafari) {
// Reload the popup when it's opened
/*
this.runtime.addEventListener('popover', (event: any) => {
const win: Window = event.target.contentWindow;
let href = win.location.href;
if (href.indexOf('#') > -1) {
href = href.substr(0, href.indexOf('#'));
}
if (win.location.toString() === href) {
win.location.reload();
} else {
win.location.href = href;
}
}, true);
*/
}
await this.checkOnInstalled();
BrowserApi.messageListener('runtime.background', async (msg: any, sender: any, sendResponse: any) => {
await this.processMessage(msg, sender, sendResponse);
});

View File

@@ -1,14 +1,10 @@
import MainBackground from './main.background';
import { PlatformUtilsService } from 'jslib/abstractions';
export default class TabsBackground {
private tabs: any;
private isSafari: boolean;
constructor(private main: MainBackground, private platformUtilsService: PlatformUtilsService) {
this.isSafari = this.platformUtilsService.isSafari();
this.tabs = this.isSafari ? {} : chrome.tabs;
constructor(private main: MainBackground) {
this.tabs = chrome.tabs;
}
async init() {
@@ -16,21 +12,6 @@ export default class TabsBackground {
return;
}
if (this.isSafari) {
/*
this.tabs.addEventListener('activate', async (ev: any) => {
await this.main.refreshBadgeAndMenu();
}, true);
this.tabs.addEventListener('navigate', async (ev: any) => {
await this.main.checkNotificationQueue();
await this.main.refreshBadgeAndMenu();
}, true);
*/
return;
}
this.tabs.onActivated.addListener(async (activeInfo: any) => {
await this.main.refreshBadgeAndMenu();
});