From 17c2f506fdd3a83e8dd8b57976d3f48bcba521bc Mon Sep 17 00:00:00 2001 From: Micah Tigley Date: Thu, 25 Jul 2019 16:05:01 +0000 Subject: [PATCH] Bug 1568226 - Hide Lockwise data in Monitor card if a master password is set. r=ewright Differential Revision: https://phabricator.services.mozilla.com/D39228 --HG-- extra : moz-landing-system : lando --- .../about/AboutProtectionsHandler.jsm | 19 ++++++---- .../protections/content/monitor-card.js | 20 ++++++++--- .../protections/content/protections.css | 3 +- .../protections/content/protections.html | 2 +- .../browser/browser_protections_monitor.js | 36 ++++++++++++++++--- 5 files changed, 62 insertions(+), 18 deletions(-) diff --git a/browser/components/about/AboutProtectionsHandler.jsm b/browser/components/about/AboutProtectionsHandler.jsm index 86fdbfe18b3a..96fa45c537ac 100644 --- a/browser/components/about/AboutProtectionsHandler.jsm +++ b/browser/components/about/AboutProtectionsHandler.jsm @@ -182,7 +182,7 @@ var AboutProtectionsHandler = { */ async getMonitorData() { let monitorData = {}; - let potentiallyBreachedLogins = 0; + let potentiallyBreachedLogins = null; const hasFxa = await fxAccounts.accountStatus(); if (hasFxa) { @@ -214,11 +214,14 @@ var AboutProtectionsHandler = { } } - // Get the stats for number of potentially breached Lockwise passwords - const logins = await LoginHelper.getAllUserFacingLogins(); - potentiallyBreachedLogins = await LoginHelper.getBreachesForLogins( - logins - ); + // Get the stats for number of potentially breached Lockwise passwords if no master + // password is set. + if (!LoginHelper.isMasterPasswordSet()) { + const logins = await LoginHelper.getAllUserFacingLogins(); + potentiallyBreachedLogins = await LoginHelper.getBreachesForLogins( + logins + ); + } } else { // If no account exists, then the user is not logged in with an fxAccount. monitorData = { @@ -228,7 +231,9 @@ var AboutProtectionsHandler = { return { ...monitorData, - potentiallyBreachedLogins: potentiallyBreachedLogins.size, + potentiallyBreachedLogins: potentiallyBreachedLogins + ? potentiallyBreachedLogins.size + : 0, error: !!monitorData.errorMessage, }; }, diff --git a/browser/components/protections/content/monitor-card.js b/browser/components/protections/content/monitor-card.js index acc531515765..c00907288004 100644 --- a/browser/components/protections/content/monitor-card.js +++ b/browser/components/protections/content/monitor-card.js @@ -77,14 +77,24 @@ export default class MonitorClass { const exposedPasswords = this.doc.querySelector( "span[data-type='exposed-passwords']" ); - const exposedLockwisePasswords = this.doc.querySelector( - "span[data-type='breached-lockwise-passwords']" - ); storedEmail.textContent = monitorData.monitoredEmails; knownBreaches.textContent = monitorData.numBreaches; exposedPasswords.textContent = monitorData.passwords; - exposedLockwisePasswords.textContent = - monitorData.potentiallyBreachedLogins; + + // Display Lockwise section if there are any potential breached logins to report. + if (monitorData.potentiallyBreachedLogins > 0) { + const lockwiseSection = this.doc.querySelector( + ".monitor-breached-passwords" + ); + const exposedLockwisePasswords = this.doc.querySelector( + "span[data-type='breached-lockwise-passwords']" + ); + + exposedLockwisePasswords.textContent = + monitorData.potentiallyBreachedLogins; + + lockwiseSection.classList.remove("hidden"); + } } } diff --git a/browser/components/protections/content/protections.css b/browser/components/protections/content/protections.css index 765e6db5f35c..277bc32866e1 100644 --- a/browser/components/protections/content/protections.css +++ b/browser/components/protections/content/protections.css @@ -77,7 +77,8 @@ a.hidden, .monitor-card.no-logins .card-body, .monitor-card.no-logins #monitor-header-content a, .monitor-card.no-logins .inline-text-icon.monitor-scanned-text, -.monitor-card.has-logins #sign-up-for-monitor-button { +.monitor-card.has-logins #sign-up-for-monitor-button, +#monitor-body-content .monitor-breached-passwords.hidden { display: none; } diff --git a/browser/components/protections/content/protections.html b/browser/components/protections/content/protections.html index 4a04ac70ecb0..b9b405917c34 100644 --- a/browser/components/protections/content/protections.html +++ b/browser/components/protections/content/protections.html @@ -137,7 +137,7 @@ View full report on Firefox Monitor -
+