mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-31 17:57:43 +01:00
load i18n in notificat bar for safari
This commit is contained in:
parent
698632a1df
commit
561de6df04
@ -166,6 +166,7 @@ export default class MainBackground {
|
|||||||
|
|
||||||
await this.runtimeBackground.init();
|
await this.runtimeBackground.init();
|
||||||
await this.tabsBackground.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();
|
||||||
|
@ -23,7 +23,7 @@ export default class RuntimeBackground {
|
|||||||
|
|
||||||
constructor(private main: MainBackground, private autofillService: AutofillService,
|
constructor(private main: MainBackground, private autofillService: AutofillService,
|
||||||
private cipherService: CipherService, private platformUtilsService: PlatformUtilsService,
|
private cipherService: CipherService, private platformUtilsService: PlatformUtilsService,
|
||||||
private storageService: StorageService) {
|
private storageService: StorageService, private i18nService: any) {
|
||||||
this.isSafari = this.platformUtilsService.isSafari();
|
this.isSafari = this.platformUtilsService.isSafari();
|
||||||
this.runtime = this.isSafari ? safari.application : chrome.runtime;
|
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) {
|
private async getDataForTab(tab: any, responseCommand: string) {
|
||||||
const responseVal: any = {};
|
const responseData: any = {};
|
||||||
if (responseCommand === 'notificationBarDataResponse') {
|
if (responseCommand === 'notificationBarDataResponse') {
|
||||||
responseVal.neverDomains = await this.storageService.get<any>(ConstantsService.neverDomainsKey);
|
responseData.neverDomains = await this.storageService.get<any>(ConstantsService.neverDomainsKey);
|
||||||
responseVal.disabledNotification = await this.storageService.get<boolean>(
|
responseData.disabledNotification = await this.storageService.get<boolean>(
|
||||||
ConstantsService.disableAddLoginNotificationKey);
|
ConstantsService.disableAddLoginNotificationKey);
|
||||||
} else if (responseCommand === 'autofillerAutofillOnPageLoadEnabledResponse') {
|
} else if (responseCommand === 'autofillerAutofillOnPageLoadEnabledResponse') {
|
||||||
responseVal.autofillEnabled = await this.storageService.get<boolean>(
|
responseData.autofillEnabled = await this.storageService.get<boolean>(
|
||||||
ConstantsService.enableAutoFillOnPageLoadKey);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,15 +3,18 @@ require('./bar.less');
|
|||||||
document.addEventListener('DOMContentLoaded', function () {
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
var i18n = {};
|
var i18n = {};
|
||||||
if (typeof safari !== 'undefined') {
|
if (typeof safari !== 'undefined') {
|
||||||
// TODO: load when we get i18n strings
|
const responseCommand = 'notificationBarFrameDataResponse';
|
||||||
i18n.appName = 'bitwarden';
|
sendPlatformMessage({
|
||||||
i18n.close = 'close';
|
command: 'bgGetDataForTab',
|
||||||
i18n.yes = 'Yes';
|
responseCommand: responseCommand
|
||||||
i18n.never = 'Never';
|
});
|
||||||
i18n.notificationAddSave = 'Save Site';;
|
safari.self.addEventListener('message', function (msgEvent) {
|
||||||
i18n.notificationNeverSave = 'Never Save';
|
const msg = msgEvent.message;
|
||||||
i18n.notificationAddDesc = 'Want to Save?';
|
if (msg.command === responseCommand && msg.data) {
|
||||||
setTimeout(load, 50);
|
i18n = msg.data.i18n;
|
||||||
|
load();
|
||||||
|
}
|
||||||
|
}, false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
i18n.appName = chrome.i18n.getMessage('appName');
|
i18n.appName = chrome.i18n.getMessage('appName');
|
||||||
|
Loading…
Reference in New Issue
Block a user