Bug 1361364 - Implement chrome.privacy.services.passwordSavingEnabled, r?aswan draft
authorBob Silverberg <bsilverberg@mozilla.com>
Thu, 25 May 2017 15:31:12 -0400
changeset 595683 d0173de28a4c9b8058e06eaf6646d4c96f8a04f1
parent 595682 58c5151bfd62de934b2286dbd664e69886270e28
child 633772 8bca3c5459f8042555134176288ab6c4b461efd8
push id64410
push userbmo:bob.silverberg@gmail.com
push dateFri, 16 Jun 2017 17:03:50 +0000
reviewersaswan
bugs1361364
milestone56.0a1
Bug 1361364 - Implement chrome.privacy.services.passwordSavingEnabled, r?aswan MozReview-Commit-ID: Hkg2pG04KgH
toolkit/components/extensions/ext-privacy.js
toolkit/components/extensions/schemas/privacy.json
toolkit/components/extensions/test/xpcshell/test_ext_privacy.js
--- a/toolkit/components/extensions/ext-privacy.js
+++ b/toolkit/components/extensions/ext-privacy.js
@@ -100,16 +100,26 @@ ExtensionPreferencesManager.addSetting("
       case "disable_non_proxied_udp":
         prefs["media.peerconnection.ice.proxy_only"] = true;
         break;
     }
     return prefs;
   },
 });
 
+ExtensionPreferencesManager.addSetting("services.passwordSavingEnabled", {
+  prefNames: [
+    "signon.rememberSignons",
+  ],
+
+  setCallback(value) {
+    return {[this.prefNames[0]]: value};
+  },
+});
+
 ExtensionPreferencesManager.addSetting("websites.hyperlinkAuditingEnabled", {
   prefNames: [
     "browser.send_pings",
   ],
 
   setCallback(value) {
     return {[this.prefNames[0]]: value};
   },
@@ -161,16 +171,25 @@ this.privacy = class extends ExtensionAP
                   return "default_public_interface_only";
                 }
                 return "default_public_and_private_interfaces";
               }
 
               return "default";
             }),
         },
+
+        services: {
+          passwordSavingEnabled: getAPI(extension,
+            "services.passwordSavingEnabled",
+            () => {
+              return Preferences.get("signon.rememberSignons");
+            }),
+        },
+
         websites: {
           hyperlinkAuditingEnabled: getAPI(extension,
             "websites.hyperlinkAuditingEnabled",
             () => {
               return Preferences.get("browser.send_pings");
             }),
           referrersEnabled: getAPI(extension,
             "websites.referrersEnabled",
--- a/toolkit/components/extensions/schemas/privacy.json
+++ b/toolkit/components/extensions/schemas/privacy.json
@@ -44,16 +44,27 @@
       },
       "webRTCIPHandlingPolicy": {
         "$ref": "types.Setting",
         "description": "Allow users to specify the media performance/privacy tradeoffs which impacts how WebRTC traffic will be routed and how much local address information is exposed. This preference's value is of type IPHandlingPolicy, defaulting to <code>default</code>."
       }
     }
   },
   {
+    "namespace": "privacy.services",
+    "description": "Use the <code>browser.privacy</code> API to control usage of the features in the browser that can affect a user's privacy.",
+    "permissions": ["privacy"],
+    "properties": {
+      "passwordSavingEnabled": {
+        "$ref": "types.Setting",
+        "description": "If enabled, the password manager will ask if you want to save passwords. This preference's value is a boolean, defaulting to <code>true</code>."
+      }
+    }
+  },
+  {
     "namespace": "privacy.websites",
     "description": "Use the <code>browser.privacy</code> API to control usage of the features in the browser that can affect a user's privacy.",
     "permissions": ["privacy"],
     "properties": {
       "thirdPartyCookiesAllowed": {
         "$ref": "types.Setting",
         "description": "If disabled, the browser blocks third-party sites from setting cookies. The value of this preference is of type boolean, and the default value is <code>true</code>.",
         "unsupported": true
--- a/toolkit/components/extensions/test/xpcshell/test_ext_privacy.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_privacy.js
@@ -224,16 +224,19 @@ add_task(async function test_privacy_oth
     "network.webRTCIPHandlingPolicy": {
       "media.peerconnection.ice.default_address_only": false,
       "media.peerconnection.ice.no_host": false,
       "media.peerconnection.ice.proxy_only": false,
     },
     "network.peerConnectionEnabled": {
       "media.peerconnection.enabled": true,
     },
+    "services.passwordSavingEnabled": {
+      "signon.rememberSignons": true,
+    },
     "websites.referrersEnabled": {
       "network.http.sendRefererHeader": 2,
     },
   };
 
   async function background() {
     browser.test.onMessage.addListener(async (msg, ...args) => {
       let data = args[0];
@@ -331,16 +334,25 @@ add_task(async function test_privacy_oth
     {
       "network.http.sendRefererHeader": 0,
     });
   await testSetting("websites.referrersEnabled", true,
     {
       "network.http.sendRefererHeader": 2,
     });
 
+  await testSetting("services.passwordSavingEnabled", false,
+    {
+      "signon.rememberSignons": false,
+    });
+  await testSetting("services.passwordSavingEnabled", true,
+    {
+      "signon.rememberSignons": true,
+    });
+
   await extension.unload();
 
   await promiseShutdownManager();
 });
 
 add_task(async function test_exceptions() {
   async function background() {
     await browser.test.assertRejects(