mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-28 17:27:50 +01:00
safari tabs apis
This commit is contained in:
parent
97d1e0c98a
commit
698632a1df
@ -148,13 +148,13 @@ export default class MainBackground {
|
||||
// Background
|
||||
this.runtimeBackground = new RuntimeBackground(this, this.autofillService, this.cipherService,
|
||||
this.platformUtilsService, this.storageService);
|
||||
this.tabsBackground = new TabsBackground(this, this.platformUtilsService);
|
||||
|
||||
if (!this.isSafari) {
|
||||
this.commandsBackground = new CommandsBackground(this, this.passwordGenerationService);
|
||||
this.contextMenusBackground = new ContextMenusBackground(this, this.cipherService,
|
||||
this.passwordGenerationService);
|
||||
this.idleBackground = new IdleBackground(this, this.lockService, this.storageService);
|
||||
this.tabsBackground = new TabsBackground(this);
|
||||
this.webRequestBackground = new WebRequestBackground(this.platformUtilsService, this.cipherService);
|
||||
this.windowsBackground = new WindowsBackground(this);
|
||||
}
|
||||
@ -165,11 +165,11 @@ export default class MainBackground {
|
||||
this.containerService.attachToWindow(window);
|
||||
|
||||
await this.runtimeBackground.init();
|
||||
await this.tabsBackground.init();
|
||||
if (!this.isSafari) {
|
||||
await this.commandsBackground.init();
|
||||
await this.contextMenusBackground.init();
|
||||
await this.idleBackground.init();
|
||||
await this.tabsBackground.init();
|
||||
await this.webRequestBackground.init();
|
||||
await this.windowsBackground.init();
|
||||
}
|
||||
|
@ -1,10 +1,14 @@
|
||||
import MainBackground from './main.background';
|
||||
|
||||
import { PlatformUtilsService } from 'jslib/abstractions';
|
||||
|
||||
export default class TabsBackground {
|
||||
private tabs: any;
|
||||
private isSafari: boolean;
|
||||
|
||||
constructor(private main: MainBackground) {
|
||||
this.tabs = chrome.tabs;
|
||||
constructor(private main: MainBackground, private platformUtilsService: PlatformUtilsService) {
|
||||
this.isSafari = this.platformUtilsService.isSafari();
|
||||
this.tabs = this.isSafari ? safari.application : chrome.tabs;
|
||||
}
|
||||
|
||||
async init() {
|
||||
@ -12,6 +16,19 @@ 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.checkLoginsToAdd();
|
||||
await this.main.refreshBadgeAndMenu();
|
||||
}, true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this.tabs.onActivated.addListener(async (activeInfo: any) => {
|
||||
await this.main.refreshBadgeAndMenu();
|
||||
});
|
||||
|
@ -4,6 +4,13 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
var i18n = {};
|
||||
if (typeof safari !== 'undefined') {
|
||||
// TODO: load when we get i18n strings
|
||||
i18n.appName = 'bitwarden';
|
||||
i18n.close = 'close';
|
||||
i18n.yes = 'Yes';
|
||||
i18n.never = 'Never';
|
||||
i18n.notificationAddSave = 'Save Site';;
|
||||
i18n.notificationNeverSave = 'Never Save';
|
||||
i18n.notificationAddDesc = 'Want to Save?';
|
||||
setTimeout(load, 50);
|
||||
}
|
||||
else {
|
||||
|
Loading…
Reference in New Issue
Block a user