diff --git a/src/background/notification.background.ts b/src/background/notification.background.ts index 12ded645c6..b92b58e245 100644 --- a/src/background/notification.background.ts +++ b/src/background/notification.background.ts @@ -45,6 +45,52 @@ export default class NotificationBackground { this.cleanupNotificationQueue(); } + async processMessage(msg: any, sender: any, sendResponse: any) { + switch (msg.command) { + case 'bgGetDataForTab': + await this.getDataForTab(sender.tab, msg.responseCommand); + break; + case 'bgCloseNotificationBar': + await BrowserApi.tabSendMessageData(sender.tab, 'closeNotificationBar'); + break; + case 'bgAdjustNotificationBar': + await BrowserApi.tabSendMessageData(sender.tab, 'adjustNotificationBar', msg.data); + break; + case 'bgAddLogin': + await this.addLogin(msg.login, sender.tab); + break; + case 'bgChangedPassword': + await this.changedPassword(msg.data, sender.tab); + break; + case 'bgAddClose': + case 'bgChangeClose': + this.removeTabFromNotificationQueue(sender.tab); + break; + case 'bgAddSave': + case 'bgChangeSave': + await this.saveOrUpdateCredentials(sender.tab, msg.folder); + break; + case 'bgNeverSave': + await this.saveNever(sender.tab); + break; + case 'collectPageDetailsResponse': + switch (msg.sender) { + case 'notificationBar': + const forms = this.autofillService.getFormsWithPasswordFields(msg.details); + await BrowserApi.tabSendMessageData(msg.tab, 'notificationBarPageDetails', { + details: msg.details, + forms: forms, + }); + break; + default: + break; + } + break; + default: + break; + } + } + async checkNotificationQueue(tab: any = null): Promise { if (this.notificationQueue.length === 0) { return; @@ -112,53 +158,6 @@ export default class NotificationBackground { } } - async processMessage(msg: any, sender: any, sendResponse: any) { - switch (msg.command) { - case 'bgGetDataForTab': - await this.getDataForTab(sender.tab, msg.responseCommand); - break; - case 'bgCloseNotificationBar': - await BrowserApi.tabSendMessageData(sender.tab, 'closeNotificationBar'); - break; - case 'bgAdjustNotificationBar': - await BrowserApi.tabSendMessageData(sender.tab, 'adjustNotificationBar', msg.data); - break; - case 'bgAddLogin': - await this.addLogin(msg.login, sender.tab); - break; - case 'bgChangedPassword': - await this.changedPassword(msg.data, sender.tab); - break; - case 'bgAddClose': - case 'bgChangeClose': - this.removeTabFromNotificationQueue(sender.tab); - break; - case 'bgAddSave': - case 'bgChangeSave': - await this.saveOrUpdateCredentials(sender.tab, msg.folder); - break; - case 'bgNeverSave': - await this.saveNever(sender.tab); - break; - case 'collectPageDetailsResponse': - switch (msg.sender) { - case 'notificationBar': - console.log('collectPageDetailsResponse for notificationBar received', msg.tab) - const forms = this.autofillService.getFormsWithPasswordFields(msg.details); - await BrowserApi.tabSendMessageData(msg.tab, 'notificationBarPageDetails', { - details: msg.details, - forms: forms, - }); - break; - default: - break; - } - break; - default: - break; - } - } - private async addLogin(loginInfo: any, tab: any) { const loginDomain = Utils.getDomain(loginInfo.url); if (loginDomain == null) { diff --git a/src/background/runtime.background.ts b/src/background/runtime.background.ts index 142f6d0973..4086a95740 100644 --- a/src/background/runtime.background.ts +++ b/src/background/runtime.background.ts @@ -13,14 +13,7 @@ import { BrowserApi } from '../browser/browserApi'; import MainBackground from './main.background'; import { Utils } from 'jslib-common/misc/utils'; - -import { PolicyType } from 'jslib-common/enums/policyType'; - -import AddChangePasswordQueueMessage from './models/addChangePasswordQueueMessage'; -import AddLoginQueueMessage from './models/addLoginQueueMessage'; - export default class RuntimeBackground { - private runtime: any; private autofillTimeout: any; private pageDetailsToAutoFill: any[] = []; private onInstalledReason: string = null; @@ -72,7 +65,7 @@ export default class RuntimeBackground { const retryMessage = { commandToRetry: { ...msg.retryItem, - sender: sender + sender: sender, }, from: msg.from, };