Bug 1586913 - Add policy for DisablePasswordReveal. r=jaws,flod,fluent-reviewers
authorMichael Kaply <mozilla@kaply.com>
Wed, 09 Oct 2019 20:04:39 +0000
changeset 497030 a728ab1710254a1dfae2cc0c78984cfe091839e0
parent 497029 16c3040fb3882c4d1e707c8d1e41d1c39f8e1035
child 497031 a2f59445b0ad59e5acef97bd4ecf918c5a0935d4
push id36674
push userccoroiu@mozilla.com
push dateThu, 10 Oct 2019 09:26:37 +0000
treeherdermozilla-central@f20fa8068ec2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws, flod, fluent-reviewers
bugs1586913
milestone71.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1586913 - Add policy for DisablePasswordReveal. r=jaws,flod,fluent-reviewers Differential Revision: https://phabricator.services.mozilla.com/D48592
browser/components/aboutlogins/AboutLoginsChild.jsm
browser/components/aboutlogins/AboutLoginsParent.jsm
browser/components/aboutlogins/content/components/login-item.js
browser/components/enterprisepolicies/Policies.jsm
browser/components/enterprisepolicies/schemas/policies-schema.json
browser/locales/en-US/browser/policies/policies-descriptions.ftl
--- a/browser/components/aboutlogins/AboutLoginsChild.jsm
+++ b/browser/components/aboutlogins/AboutLoginsChild.jsm
@@ -64,16 +64,17 @@ class AboutLoginsChild extends ActorChil
             };
 
             messageManager.sendAsyncMessage(
               "AboutLogins:MasterPasswordRequest"
             );
           },
           // Default to enabled just in case a search is attempted before we get a response.
           masterPasswordEnabled: true,
+          passwordRevealVisible: true,
         };
         waivedContent.AboutLoginsUtils = Cu.cloneInto(
           AboutLoginsUtils,
           waivedContent,
           {
             cloneFunctions: true,
           }
         );
@@ -225,16 +226,18 @@ class AboutLoginsChild extends ActorChil
         break;
       case "AboutLogins:SetBreaches":
         this.sendToContent("SetBreaches", message.data);
         break;
       case "AboutLogins:Setup":
         this.sendToContent("Setup", message.data);
         Cu.waiveXrays(this.content).AboutLoginsUtils.masterPasswordEnabled =
           message.data.masterPasswordEnabled;
+        Cu.waiveXrays(this.content).AboutLoginsUtils.passwordRevealVisible =
+          message.data.passwordRevealVisible;
         break;
       case "AboutLogins:ShowLoginItemError":
         this.sendToContent("ShowLoginItemError", message.data);
         break;
       case "AboutLogins:SyncState":
         this.sendToContent("SyncState", message.data);
         break;
       case "AboutLogins:UpdateBreaches":
--- a/browser/components/aboutlogins/AboutLoginsParent.jsm
+++ b/browser/components/aboutlogins/AboutLoginsParent.jsm
@@ -414,16 +414,19 @@ var AboutLoginsParent = {
             logins,
             selectedSort: Services.prefs.getCharPref(
               "signon.management.page.sort",
               "name"
             ),
             syncState,
             selectedBadgeLanguages,
             masterPasswordEnabled: LoginHelper.isMasterPasswordSet(),
+            passwordRevealVisible: Services.policies.isAllowed(
+              "passwordReveal"
+            ),
           });
 
           await this._sendAllLoginRelatedObjects(logins, messageManager);
         } catch (ex) {
           if (ex.result != Cr.NS_ERROR_NOT_INITIALIZED) {
             throw ex;
           }
 
--- a/browser/components/aboutlogins/content/components/login-item.js
+++ b/browser/components/aboutlogins/content/components/login-item.js
@@ -722,16 +722,24 @@ export default class LoginItem extends H
     } else {
       delete this.dataset.editing;
       // Only reset the reveal checkbox when exiting 'edit' mode
       this._revealCheckbox.checked = false;
     }
   }
 
   _updatePasswordRevealState() {
+    if (
+      window.AboutLoginsUtils &&
+      window.AboutLoginsUtils.passwordRevealVisible === false
+    ) {
+      this._revealCheckbox.hidden = true;
+      return;
+    }
+
     let titleId = this._revealCheckbox.checked
       ? "login-item-password-reveal-checkbox-hide"
       : "login-item-password-reveal-checkbox-show";
     document.l10n.setAttributes(this._revealCheckbox, titleId);
 
     let { checked } = this._revealCheckbox;
     let inputType = checked ? "text" : "password";
     this._passwordInput.type = inputType;
--- a/browser/components/enterprisepolicies/Policies.jsm
+++ b/browser/components/enterprisepolicies/Policies.jsm
@@ -445,16 +445,24 @@ var Policies = {
   DisableMasterPasswordCreation: {
     onBeforeUIStartup(manager, param) {
       if (param) {
         manager.disallowFeature("createMasterPassword");
       }
     },
   },
 
+  DisablePasswordReveal: {
+    onBeforeUIStartup(manager, param) {
+      if (param) {
+        manager.disallowFeature("passwordReveal");
+      }
+    },
+  },
+
   DisablePocket: {
     onBeforeAddons(manager, param) {
       if (param) {
         setAndLockPref("extensions.pocket.enabled", false);
       }
     },
   },
 
--- a/browser/components/enterprisepolicies/schemas/policies-schema.json
+++ b/browser/components/enterprisepolicies/schemas/policies-schema.json
@@ -206,16 +206,20 @@
     "DisableFormHistory": {
       "type": "boolean"
     },
 
     "DisableMasterPasswordCreation": {
       "type": "boolean"
     },
 
+    "DisablePasswordReveal": {
+      "type": "boolean"
+    },
+
     "DisablePocket": {
       "type": "boolean"
     },
 
     "DisablePrivateBrowsing": {
       "type": "boolean"
     },
 
--- a/browser/locales/en-US/browser/policies/policies-descriptions.ftl
+++ b/browser/locales/en-US/browser/policies/policies-descriptions.ftl
@@ -49,16 +49,18 @@ policy-DisableFirefoxScreenshots = Disab
 policy-DisableFirefoxStudies = Prevent { -brand-short-name } from running studies.
 
 policy-DisableForgetButton = Prevent access to the Forget button.
 
 policy-DisableFormHistory = Don’t remember search and form history.
 
 policy-DisableMasterPasswordCreation = If true, a master password can’t be created.
 
+policy-DisablePasswordReveal = Do not allow passwords to be revealed in saved logins.
+
 policy-DisablePocket = Disable the feature to save webpages to Pocket.
 
 policy-DisablePrivateBrowsing = Disable Private Browsing.
 
 policy-DisableProfileImport = Disable the menu command to Import data from another browser.
 
 policy-DisableProfileRefresh = Disable the Refresh { -brand-short-name } button in the about:support page.