safari tabs apis
This commit is contained in:
parent
97d1e0c98a
commit
698632a1df
|
@ -148,13 +148,13 @@ export default class MainBackground {
|
||||||
// Background
|
// Background
|
||||||
this.runtimeBackground = new RuntimeBackground(this, this.autofillService, this.cipherService,
|
this.runtimeBackground = new RuntimeBackground(this, this.autofillService, this.cipherService,
|
||||||
this.platformUtilsService, this.storageService);
|
this.platformUtilsService, this.storageService);
|
||||||
|
this.tabsBackground = new TabsBackground(this, this.platformUtilsService);
|
||||||
|
|
||||||
if (!this.isSafari) {
|
if (!this.isSafari) {
|
||||||
this.commandsBackground = new CommandsBackground(this, this.passwordGenerationService);
|
this.commandsBackground = new CommandsBackground(this, this.passwordGenerationService);
|
||||||
this.contextMenusBackground = new ContextMenusBackground(this, this.cipherService,
|
this.contextMenusBackground = new ContextMenusBackground(this, this.cipherService,
|
||||||
this.passwordGenerationService);
|
this.passwordGenerationService);
|
||||||
this.idleBackground = new IdleBackground(this, this.lockService, this.storageService);
|
this.idleBackground = new IdleBackground(this, this.lockService, this.storageService);
|
||||||
this.tabsBackground = new TabsBackground(this);
|
|
||||||
this.webRequestBackground = new WebRequestBackground(this.platformUtilsService, this.cipherService);
|
this.webRequestBackground = new WebRequestBackground(this.platformUtilsService, this.cipherService);
|
||||||
this.windowsBackground = new WindowsBackground(this);
|
this.windowsBackground = new WindowsBackground(this);
|
||||||
}
|
}
|
||||||
|
@ -165,11 +165,11 @@ export default class MainBackground {
|
||||||
this.containerService.attachToWindow(window);
|
this.containerService.attachToWindow(window);
|
||||||
|
|
||||||
await this.runtimeBackground.init();
|
await this.runtimeBackground.init();
|
||||||
|
await this.tabsBackground.init();
|
||||||
if (!this.isSafari) {
|
if (!this.isSafari) {
|
||||||
await this.commandsBackground.init();
|
await this.commandsBackground.init();
|
||||||
await this.contextMenusBackground.init();
|
await this.contextMenusBackground.init();
|
||||||
await this.idleBackground.init();
|
await this.idleBackground.init();
|
||||||
await this.tabsBackground.init();
|
|
||||||
await this.webRequestBackground.init();
|
await this.webRequestBackground.init();
|
||||||
await this.windowsBackground.init();
|
await this.windowsBackground.init();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
import MainBackground from './main.background';
|
import MainBackground from './main.background';
|
||||||
|
|
||||||
|
import { PlatformUtilsService } from 'jslib/abstractions';
|
||||||
|
|
||||||
export default class TabsBackground {
|
export default class TabsBackground {
|
||||||
private tabs: any;
|
private tabs: any;
|
||||||
|
private isSafari: boolean;
|
||||||
|
|
||||||
constructor(private main: MainBackground) {
|
constructor(private main: MainBackground, private platformUtilsService: PlatformUtilsService) {
|
||||||
this.tabs = chrome.tabs;
|
this.isSafari = this.platformUtilsService.isSafari();
|
||||||
|
this.tabs = this.isSafari ? safari.application : chrome.tabs;
|
||||||
}
|
}
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
|
@ -12,6 +16,19 @@ export default class TabsBackground {
|
||||||
return;
|
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) => {
|
this.tabs.onActivated.addListener(async (activeInfo: any) => {
|
||||||
await this.main.refreshBadgeAndMenu();
|
await this.main.refreshBadgeAndMenu();
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,6 +4,13 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||||
var i18n = {};
|
var i18n = {};
|
||||||
if (typeof safari !== 'undefined') {
|
if (typeof safari !== 'undefined') {
|
||||||
// TODO: load when we get i18n strings
|
// 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);
|
setTimeout(load, 50);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in New Issue