1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-19 09:43:23 +00:00

load i18n in notificat bar for safari

This commit is contained in:
Kyle Spearrin
2018-01-13 15:09:05 -05:00
parent 698632a1df
commit 561de6df04
4 changed files with 30 additions and 21 deletions

View File

@@ -166,6 +166,7 @@ export default class MainBackground {
await this.runtimeBackground.init();
await this.tabsBackground.init();
if (!this.isSafari) {
await this.commandsBackground.init();
await this.contextMenusBackground.init();

View File

@@ -23,7 +23,7 @@ export default class RuntimeBackground {
constructor(private main: MainBackground, private autofillService: AutofillService,
private cipherService: CipherService, private platformUtilsService: PlatformUtilsService,
private storageService: StorageService) {
private storageService: StorageService, private i18nService: any) {
this.isSafari = this.platformUtilsService.isSafari();
this.runtime = this.isSafari ? safari.application : chrome.runtime;
}
@@ -260,22 +260,27 @@ export default class RuntimeBackground {
}
}
private async sendStorageValueToTab(storageKey: string, tab: any, responseCommand: string) {
const val = await this.storageService.get<any>(storageKey);
await BrowserApi.tabSendMessageData(tab, responseCommand, val);
}
private async getDataForTab(tab: any, responseCommand: string) {
const responseVal: any = {};
const responseData: any = {};
if (responseCommand === 'notificationBarDataResponse') {
responseVal.neverDomains = await this.storageService.get<any>(ConstantsService.neverDomainsKey);
responseVal.disabledNotification = await this.storageService.get<boolean>(
responseData.neverDomains = await this.storageService.get<any>(ConstantsService.neverDomainsKey);
responseData.disabledNotification = await this.storageService.get<boolean>(
ConstantsService.disableAddLoginNotificationKey);
} else if (responseCommand === 'autofillerAutofillOnPageLoadEnabledResponse') {
responseVal.autofillEnabled = await this.storageService.get<boolean>(
responseData.autofillEnabled = await this.storageService.get<boolean>(
ConstantsService.enableAutoFillOnPageLoadKey);
} else if (responseCommand === 'notificationBarFrameDataResponse') {
responseData.i18n = {
appName: this.i18nService.appName,
close: this.i18nService.close,
yes: this.i18nService.yes,
never: this.i18nService.never,
notificationAddSave: this.i18nService.notificationAddSave,
notificationNeverSave: this.i18nService.notificationNeverSave,
notificationAddDesc: this.i18nService.notificationAddDesc,
};
}
await BrowserApi.tabSendMessageData(tab, responseCommand, responseVal);
await BrowserApi.tabSendMessageData(tab, responseCommand, responseData);
}
}

View File

@@ -20,7 +20,7 @@ export default class TabsBackground {
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();