bitwarden-estensione-browser/src/background/tabs.background.ts

57 lines
1.7 KiB
TypeScript
Raw Normal View History

import MainBackground from './main.background';
2018-01-13 20:56:38 +01:00
import { PlatformUtilsService } from 'jslib/abstractions';
export default class TabsBackground {
private tabs: any;
2018-01-13 20:56:38 +01:00
private isSafari: boolean;
2018-01-13 20:56:38 +01:00
constructor(private main: MainBackground, private platformUtilsService: PlatformUtilsService) {
this.isSafari = this.platformUtilsService.isSafari();
2019-08-17 02:46:53 +02:00
this.tabs = this.isSafari ? {} : chrome.tabs;
}
async init() {
if (!this.tabs) {
return;
}
2018-01-13 20:56:38 +01:00
if (this.isSafari) {
2019-08-13 21:47:03 +02:00
/*
2018-01-13 20:56:38 +01:00
this.tabs.addEventListener('activate', async (ev: any) => {
await this.main.refreshBadgeAndMenu();
}, true);
2018-01-13 21:09:05 +01:00
2018-01-13 20:56:38 +01:00
this.tabs.addEventListener('navigate', async (ev: any) => {
2018-08-01 05:24:11 +02:00
await this.main.checkNotificationQueue();
2018-01-13 20:56:38 +01:00
await this.main.refreshBadgeAndMenu();
}, true);
2019-08-13 21:47:03 +02:00
*/
2018-01-13 20:56:38 +01:00
return;
}
this.tabs.onActivated.addListener(async (activeInfo: any) => {
await this.main.refreshBadgeAndMenu();
});
this.tabs.onReplaced.addListener(async (addedTabId: any, removedTabId: any) => {
if (this.main.onReplacedRan) {
return;
}
this.main.onReplacedRan = true;
2018-08-01 05:24:11 +02:00
await this.main.checkNotificationQueue();
await this.main.refreshBadgeAndMenu();
});
this.tabs.onUpdated.addListener(async (tabId: any, changeInfo: any, tab: any) => {
if (this.main.onUpdatedRan) {
return;
}
this.main.onUpdatedRan = true;
2018-08-01 05:24:11 +02:00
await this.main.checkNotificationQueue();
await this.main.refreshBadgeAndMenu();
});
}
}