From 2cee12df26207545c36102a794ef6e1419113551 Mon Sep 17 00:00:00 2001 From: Matthew Noorenberghe Date: Mon, 20 May 2019 02:56:08 +0000 Subject: [PATCH] Bug 1550131 - Remove about:logins master password login notifications when the user logs in. r=jaws Depends on D31699 Differential Revision: https://phabricator.services.mozilla.com/D31700 --HG-- extra : moz-landing-system : lando --- .../aboutlogins/AboutLoginsParent.jsm | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/browser/components/aboutlogins/AboutLoginsParent.jsm b/browser/components/aboutlogins/AboutLoginsParent.jsm index 8e9d37970b2a..7ec04d6f9f97 100644 --- a/browser/components/aboutlogins/AboutLoginsParent.jsm +++ b/browser/components/aboutlogins/AboutLoginsParent.jsm @@ -75,6 +75,7 @@ var AboutLoginsParent = { } case "AboutLogins:Subscribe": { if (!ChromeUtils.nondeterministicGetWeakSetKeys(this._subscribers).length) { + Services.obs.addObserver(this, "passwordmgr-crypto-login"); Services.obs.addObserver(this, "passwordmgr-crypto-loginCanceled"); Services.obs.addObserver(this, "passwordmgr-storage-changed"); } @@ -108,11 +109,18 @@ var AboutLoginsParent = { observe(subject, topic, type) { if (!ChromeUtils.nondeterministicGetWeakSetKeys(this._subscribers).length) { + Services.obs.removeObserver(this, "passwordmgr-crypto-login"); Services.obs.removeObserver(this, "passwordmgr-crypto-loginCanceled"); Services.obs.removeObserver(this, "passwordmgr-storage-changed"); return; } + if (topic == "passwordmgr-crypto-login") { + this.removeMasterPasswordLoginNotifications(); + this.messageSubscribers("AboutLogins:AllLogins", this.getAllLogins()); + return; + } + if (topic == "passwordmgr-crypto-loginCanceled") { this.showMasterPasswordLoginNotifications(); return; @@ -179,6 +187,19 @@ var AboutLoginsParent = { } }, + removeMasterPasswordLoginNotifications() { + for (let subscriber of this._subscriberIterator()) { + let {gBrowser} = subscriber.ownerGlobal; + let browser = subscriber; + let notificationBox = gBrowser.getNotificationBox(browser); + let notification = notificationBox.getNotificationWithValue(MASTER_PASSWORD_NOTIFICATION_ID); + if (!notification) { + continue; + } + notificationBox.removeNotification(notification); + } + }, + * _subscriberIterator() { let subscribers = ChromeUtils.nondeterministicGetWeakSetKeys(this._subscribers); for (let subscriber of subscribers) {