1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-19 01:33:33 +00:00

separating background apis to their own classes

This commit is contained in:
Kyle Spearrin
2017-12-07 15:06:37 -05:00
parent 142e33eb05
commit 8f1757401e
6 changed files with 199 additions and 75 deletions

View File

@@ -0,0 +1,37 @@
import MainBackground from './main.background';
export default class TabsBackground {
private tabs: any;
constructor(private main: MainBackground) {
this.tabs = chrome.tabs;
}
async init() {
if (!this.tabs) {
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;
await this.main.checkLoginsToAdd();
await this.main.refreshBadgeAndMenu();
});
this.tabs.onUpdated.addListener(async (tabId: any, changeInfo: any, tab: any) => {
if (this.main.onUpdatedRan) {
return;
}
this.main.onUpdatedRan = true;
await this.main.checkLoginsToAdd();
await this.main.refreshBadgeAndMenu();
});
}
}