Bug 1429161 - Policy: Disable Forget Button. r=jaws
authorFelipe Gomes <felipc@gmail.com>
Tue, 03 Apr 2018 15:39:35 -0300
changeset 411485 b69de0df02ceb5dc5aad18c65da8874d5124cccf
parent 411484 6df42e55dbbd2b475745dedb18319481abea89c6
child 411486 79f16e24a288ded97b3b942e71ebfe74f8e7425a
push id101677
push userfelipc@gmail.com
push dateTue, 03 Apr 2018 18:39:49 +0000
treeherdermozilla-inbound@b69de0df02ce [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1429161
milestone61.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 1429161 - Policy: Disable Forget Button. r=jaws
browser/components/customizableui/CustomizableWidgets.jsm
browser/components/enterprisepolicies/Policies.jsm
browser/components/enterprisepolicies/schemas/policies-schema.json
browser/components/enterprisepolicies/tests/browser/disable_forget_button/browser.ini
browser/components/enterprisepolicies/tests/browser/disable_forget_button/browser_policy_disable_forgetbutton.js
browser/components/enterprisepolicies/tests/browser/disable_forget_button/forget_button.json
browser/components/enterprisepolicies/tests/moz.build
--- a/browser/components/customizableui/CustomizableWidgets.jsm
+++ b/browser/components/customizableui/CustomizableWidgets.jsm
@@ -799,16 +799,17 @@ if (AppConstants.platform == "win") {
 }
 CustomizableWidgets.push(preferencesButton);
 
 if (Services.prefs.getBoolPref("privacy.panicButton.enabled")) {
   CustomizableWidgets.push({
     id: "panic-button",
     type: "view",
     viewId: "PanelUI-panicView",
+    disabled: !Services.policies.isAllowed("panicButton"),
 
     forgetButtonCalled(aEvent) {
       let doc = aEvent.target.ownerDocument;
       let group = doc.getElementById("PanelUI-panic-timeSpan");
       BrowserUITelemetry.countPanicEvent(group.selectedItem.id);
       let itemsToClear = [
         "cookies", "history", "openWindows", "formdata", "sessions", "cache", "downloads"
       ];
--- a/browser/components/enterprisepolicies/Policies.jsm
+++ b/browser/components/enterprisepolicies/Policies.jsm
@@ -252,16 +252,24 @@ var Policies = {
   "DisableFirefoxStudies": {
     onBeforeAddons(manager, param) {
       if (param) {
         manager.disallowFeature("Shield");
       }
     }
   },
 
+  "DisableForgetButton": {
+    onProfileAfterChange(manager, param) {
+      if (param) {
+        manager.disallowFeature("panicButton");
+      }
+    }
+  },
+
   "DisableFormHistory": {
     onBeforeUIStartup(manager, param) {
       if (param) {
         setAndLockPref("browser.formfill.enable", false);
       }
     }
   },
 
--- a/browser/components/enterprisepolicies/schemas/policies-schema.json
+++ b/browser/components/enterprisepolicies/schemas/policies-schema.json
@@ -201,16 +201,23 @@
 
     "DisableFirefoxStudies": {
       "description": "Prevents Firefox from running studies.",
       "first_available": "60.0",
 
       "type": "boolean"
     },
 
+    "DisableForgetButton": {
+      "description": "Prevents access to the \"Forget\" button.",
+      "first_available": "60.0",
+
+      "type": "boolean"
+    },
+
     "DisableFormHistory": {
       "description": "Don't remember search and form history.",
       "first_available": "60.0",
 
       "type": "boolean"
     },
 
     "DisablePocket": {
new file mode 100644
--- /dev/null
+++ b/browser/components/enterprisepolicies/tests/browser/disable_forget_button/browser.ini
@@ -0,0 +1,7 @@
+[DEFAULT]
+prefs =
+  browser.policies.alternatePath='<test-root>/browser/components/enterprisepolicies/tests/browser/disable_forget_button/forget_button.json'
+support-files =
+  forget_button.json
+
+[browser_policy_disable_forgetbutton.js]
new file mode 100644
--- /dev/null
+++ b/browser/components/enterprisepolicies/tests/browser/disable_forget_button/browser_policy_disable_forgetbutton.js
@@ -0,0 +1,9 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+add_task(async function test_policy_disable_forget_button() {
+  let widget = CustomizableUI.getWidget("panic-button");
+  is(widget.disabled, true, "Forget Button is disabled");
+});
new file mode 100644
--- /dev/null
+++ b/browser/components/enterprisepolicies/tests/browser/disable_forget_button/forget_button.json
@@ -0,0 +1,5 @@
+{
+  "policies": {
+    "DisableForgetButton": true
+  }
+}
--- a/browser/components/enterprisepolicies/tests/moz.build
+++ b/browser/components/enterprisepolicies/tests/moz.build
@@ -7,14 +7,15 @@
 with Files("**"):
     BUG_COMPONENT = ("Firefox", "General")
 
 BROWSER_CHROME_MANIFESTS += [
     'browser/browser.ini',
     'browser/disable_app_update/browser.ini',
     'browser/disable_default_bookmarks/browser.ini',
     'browser/disable_developer_tools/browser.ini',
+    'browser/disable_forget_button/browser.ini',
     'browser/disable_fxscreenshots/browser.ini',
 ]
 
 TESTING_JS_MODULES += [
     'EnterprisePolicyTesting.jsm',
 ]