diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index b842826403..b9caaa8def 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -485,6 +485,12 @@ "notificationNeverSave": { "message": "Never for this website" }, + "disableChangedPasswordNotification": { + "message": "Disable Changed Password Notification" + }, + "disableChangedPasswordNotificationDesc": { + "message": "The \"Changed Password Notification\" automatically prompts you to update a login's password in your vault whenever it detects that you have changed it on a website." + }, "notificationChangeDesc": { "message": "Do you want to update this password in Bitwarden?" }, diff --git a/src/background/runtime.background.ts b/src/background/runtime.background.ts index 67e27f390c..08b81d758e 100644 --- a/src/background/runtime.background.ts +++ b/src/background/runtime.background.ts @@ -200,6 +200,7 @@ export default class RuntimeBackground { } this.main.notificationQueue.splice(i, 1); + BrowserApi.tabSendMessageData(tab, 'closeNotificationBar'); const loginModel = new LoginView(); const loginUri = new LoginUriView(); @@ -218,8 +219,6 @@ export default class RuntimeBackground { hitType: 'event', eventAction: 'Added Login from Notification Bar', }); - - BrowserApi.tabSendMessageData(tab, 'closeNotificationBar'); } } @@ -236,6 +235,7 @@ export default class RuntimeBackground { } this.main.notificationQueue.splice(i, 1); + BrowserApi.tabSendMessageData(tab, 'closeNotificationBar'); const cipher = await this.cipherService.get(queueMessage.cipherId); if (cipher != null && cipher.type === CipherType.Login) { @@ -248,8 +248,6 @@ export default class RuntimeBackground { eventAction: 'Changed Password from Notification Bar', }); } - - BrowserApi.tabSendMessageData(tab, 'closeNotificationBar'); } } @@ -266,9 +264,10 @@ export default class RuntimeBackground { } this.main.notificationQueue.splice(i, 1); + BrowserApi.tabSendMessageData(tab, 'closeNotificationBar'); + const hostname = Utils.getHostname(tab.url); await this.cipherService.saveNeverDomain(hostname); - BrowserApi.tabSendMessageData(tab, 'closeNotificationBar'); } } @@ -418,8 +417,10 @@ export default class RuntimeBackground { const responseData: any = {}; if (responseCommand === 'notificationBarDataResponse') { responseData.neverDomains = await this.storageService.get(ConstantsService.neverDomainsKey); - responseData.disabledNotification = await this.storageService.get( + responseData.disabledAddLoginNotification = await this.storageService.get( ConstantsService.disableAddLoginNotificationKey); + responseData.disabledChangedPasswordNotification = await this.storageService.get( + ConstantsService.disableChangedPasswordNotificationKey); } else if (responseCommand === 'autofillerAutofillOnPageLoadEnabledResponse') { responseData.autofillEnabled = await this.storageService.get( ConstantsService.enableAutoFillOnPageLoadKey); diff --git a/src/content/notificationBar.ts b/src/content/notificationBar.ts index 4160561e97..410b3846af 100644 --- a/src/content/notificationBar.ts +++ b/src/content/notificationBar.ts @@ -17,6 +17,8 @@ document.addEventListener('DOMContentLoaded', (event) => { let notificationBarData = null; const isSafari = (typeof safari !== 'undefined') && navigator.userAgent.indexOf(' Safari/') !== -1 && navigator.userAgent.indexOf('Chrome') === -1; + let disabledAddLoginNotification = false; + let disabledChangedPasswordNotification = false; if (isSafari) { if (inIframe) { @@ -37,12 +39,11 @@ document.addEventListener('DOMContentLoaded', (event) => { return; } - if (notificationBarData.disabledNotification === true) { - return; + disabledAddLoginNotification = notificationBarData.disabledAddLoginNotification === true; + disabledChangedPasswordNotification = notificationBarData.disabledChangedPasswordNotification === true; + if (!disabledAddLoginNotification || !disabledChangedPasswordNotification) { + collectIfNeededWithTimeout(); } - - collectIfNeededWithTimeout(); - return; } processMessages(msg, () => { /* do nothing on send response for Safari */ }); @@ -55,10 +56,15 @@ document.addEventListener('DOMContentLoaded', (event) => { return; } - chrome.storage.local.get('disableAddLoginNotification', (disObj: any) => { - if (disObj == null || !disObj.disableAddLoginNotification) { - collectIfNeededWithTimeout(); - } + chrome.storage.local.get('disableAddLoginNotification', (disAddObj: any) => { + disabledAddLoginNotification = disAddObj != null && disAddObj.disableAddLoginNotification === true; + chrome.storage.local.get('disableChangedPasswordNotification', (disChangedObj: any) => { + disabledChangedPasswordNotification = disChangedObj != null && + disChangedObj.disableChangedPasswordNotification === true; + if (!disabledAddLoginNotification || !disabledChangedPasswordNotification) { + collectIfNeededWithTimeout(); + } + }); }); }); @@ -334,7 +340,7 @@ document.addEventListener('DOMContentLoaded', (event) => { if (formData[i].formEl !== form) { continue; } - if (formData[i].usernameEl != null && formData[i].passwordEl != null) { + if (!disabledAddLoginNotification && formData[i].usernameEl != null && formData[i].passwordEl != null) { const login = { username: formData[i].usernameEl.value, password: formData[i].passwordEl.value, @@ -351,7 +357,8 @@ document.addEventListener('DOMContentLoaded', (event) => { break; } } - if (formData[i].passwordEls != null && formData[i].passwordEls.length === 3) { + if (!disabledChangedPasswordNotification && formData[i].passwordEls != null && + formData[i].passwordEls.length === 3) { const passwords = formData[i].passwordEls .filter((el: HTMLInputElement) => el.value != null && el.value !== '') .map((el: HTMLInputElement) => el.value); diff --git a/src/popup/settings/options.component.html b/src/popup/settings/options.component.html index 326467b3be..f4f7ff9413 100644 --- a/src/popup/settings/options.component.html +++ b/src/popup/settings/options.component.html @@ -45,13 +45,23 @@
- - {{'disableAddLoginNotification' | i18n}} +
+
+
+
+ + +
+
+ +
diff --git a/src/popup/settings/options.component.ts b/src/popup/settings/options.component.ts index 1f2663c668..17772a32bd 100644 --- a/src/popup/settings/options.component.ts +++ b/src/popup/settings/options.component.ts @@ -24,6 +24,7 @@ export class OptionsComponent implements OnInit { disableAutoTotpCopy = false; disableContextMenuItem = false; disableAddLoginNotification = false; + disableChangedPasswordNotification = false; showDisableContextMenu = true; disableGa = false; theme: string; @@ -53,6 +54,9 @@ export class OptionsComponent implements OnInit { this.disableAddLoginNotification = await this.storageService.get( ConstantsService.disableAddLoginNotificationKey); + this.disableChangedPasswordNotification = await this.storageService.get( + ConstantsService.disableChangedPasswordNotificationKey); + this.disableContextMenuItem = await this.storageService.get( ConstantsService.disableContextMenuItemKey); @@ -79,6 +83,12 @@ export class OptionsComponent implements OnInit { this.callAnalytics('Add Login Notification', !this.disableAddLoginNotification); } + async updateChangedPasswordNotification() { + await this.storageService.save(ConstantsService.disableChangedPasswordNotificationKey, + this.disableChangedPasswordNotification); + this.callAnalytics('Changed Password Notification', !this.disableChangedPasswordNotification); + } + async updateDisableContextMenuItem() { await this.storageService.save(ConstantsService.disableContextMenuItemKey, this.disableContextMenuItem);