mirror of
https://github.com/bitwarden/browser
synced 2025-12-11 13:53:34 +00:00
get data for tab
This commit is contained in:
@@ -84,9 +84,8 @@ export default class RuntimeBackground {
|
|||||||
setTimeout(async () => await this.main.refreshBadgeAndMenu(), 2000);
|
setTimeout(async () => await this.main.refreshBadgeAndMenu(), 2000);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'bgGetAutofillOnPageLoadEnabled':
|
case 'bgGetDataForTab':
|
||||||
await this.sendStorageValueToTab(ConstantsService.enableAutoFillOnPageLoadKey, sender.tab,
|
await this.getDataForTab(sender.tab, msg.responseCommand);
|
||||||
msg.responseCommand);
|
|
||||||
break;
|
break;
|
||||||
case 'bgOpenNotificationBar':
|
case 'bgOpenNotificationBar':
|
||||||
await BrowserApi.tabSendMessageData(sender.tab, 'openNotificationBar', msg.data);
|
await BrowserApi.tabSendMessageData(sender.tab, 'openNotificationBar', msg.data);
|
||||||
@@ -265,4 +264,18 @@ export default class RuntimeBackground {
|
|||||||
const val = await this.storageService.get<any>(storageKey);
|
const val = await this.storageService.get<any>(storageKey);
|
||||||
await BrowserApi.tabSendMessageData(tab, responseCommand, val);
|
await BrowserApi.tabSendMessageData(tab, responseCommand, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async getDataForTab(tab: any, responseCommand: string) {
|
||||||
|
const responseVal: any = {};
|
||||||
|
if (responseCommand === 'notificationBarDataResponse') {
|
||||||
|
responseVal.neverDomains = await this.storageService.get<string[]>(ConstantsService.neverDomainsKey);
|
||||||
|
responseVal.disableAddLoginNotification = await this.storageService.get<boolean>(
|
||||||
|
ConstantsService.disableAddLoginNotificationKey);
|
||||||
|
} else if (responseCommand === 'autofillerAutofillOnPageLoadEnabledResponse') {
|
||||||
|
responseVal.enableAutoFillOnPageLoadKey = await this.storageService.get<boolean>(
|
||||||
|
ConstantsService.enableAutoFillOnPageLoadKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
await BrowserApi.tabSendMessageData(tab, responseCommand, responseVal);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,12 +5,12 @@ document.addEventListener('DOMContentLoaded', (event) => {
|
|||||||
if ((typeof safari !== 'undefined')) {
|
if ((typeof safari !== 'undefined')) {
|
||||||
const responseCommand = 'autofillerAutofillOnPageLoadEnabledResponse';
|
const responseCommand = 'autofillerAutofillOnPageLoadEnabledResponse';
|
||||||
safari.self.tab.dispatchMessage('bitwarden', {
|
safari.self.tab.dispatchMessage('bitwarden', {
|
||||||
command: 'bgGetAutofillOnPageLoadEnabled',
|
command: 'bgGetDataForTab',
|
||||||
responseCommand: responseCommand
|
responseCommand: responseCommand
|
||||||
});
|
});
|
||||||
safari.self.addEventListener('message', function (msgEvent) {
|
safari.self.addEventListener('message', function (msgEvent) {
|
||||||
const msg = msgEvent.message;
|
const msg = msgEvent.message;
|
||||||
if (msg.command === responseCommand && msg.data === true) {
|
if (msg.command === responseCommand && msg.data[enabledKey] === true) {
|
||||||
setInterval(doFillIfNeeded, 500);
|
setInterval(doFillIfNeeded, 500);
|
||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ document.addEventListener('DOMContentLoaded', function (event) {
|
|||||||
if (isSafariApi) {
|
if (isSafariApi) {
|
||||||
const responseCommand = 'notificationBarDataResponse';
|
const responseCommand = 'notificationBarDataResponse';
|
||||||
safari.self.tab.dispatchMessage('bitwarden', {
|
safari.self.tab.dispatchMessage('bitwarden', {
|
||||||
command: 'bgGetNotificationBarData',
|
command: 'bgGetDataForTab',
|
||||||
responseCommand: responseCommand
|
responseCommand: responseCommand
|
||||||
});
|
});
|
||||||
safari.self.addEventListener('message', function (msgEvent) {
|
safari.self.addEventListener('message', function (msgEvent) {
|
||||||
|
|||||||
Reference in New Issue
Block a user