File toolkit-ui-lockdown.patch of Package mozilla-xulrunner190

From: Robert O'Callahan
Subject: Lockdown feature for Toolkit UI
References:


Index: mozilla/toolkit/components/printing/content/printdialog.js
===================================================================
--- mozilla.orig/toolkit/components/printing/content/printdialog.js
+++ mozilla/toolkit/components/printing/content/printdialog.js
@@ -50,6 +50,7 @@ var gPrintSettings     = null;
 var gWebBrowserPrint   = null;
 var gPrintSetInterface = Components.interfaces.nsIPrintSettings;
 var doDebug            = false;
+var gPrefService       = null;
 
 //---------------------------------------------------
 function initDialog()
@@ -87,11 +88,23 @@ function initDialog()
   dialog.fpDialog        = document.getElementById("fpDialog");
 
   dialog.enabled         = false;
+
+  gPrefService = Components.classes["@mozilla.org/preferences-service;1"]
+      .getService(Components.interfaces.nsIPrefService).getBranch(null);
+  if (gPrefService.getBoolPref("config.lockdown.savepage")) {
+    dialog.fileCheck.setAttribute("disabled", "true");
+  }
+  if (gPrefService.getBoolPref("config.lockdown.printing")) {
+    dialog.printButton.setAttribute("disabled", "true");
+  }
 }
 
 //---------------------------------------------------
 function checkInteger(element)
 {
+  if (gPrefService.getBoolPref("config.lockdown.printing"))
+    return;
+
   var value = element.value;
   if (value && value.length > 0) {
     value = value.replace(/[^0-9]/g,"");
Index: mozilla/toolkit/components/passwordmgr/content/passwordManager.js
===================================================================
--- mozilla.orig/toolkit/components/passwordmgr/content/passwordManager.js
+++ mozilla/toolkit/components/passwordmgr/content/passwordManager.js
@@ -107,9 +107,14 @@ function LoadSignons() {
   // disable "remove all signons" button if there are no signons
   var element = document.getElementById("removeAllSignons");
   var toggle = document.getElementById("togglePasswords");
+  var viewLocked = Components.classes["@mozilla.org/preferences-service;1"]
+    .getService(Components.interfaces.nsIPrefBranch)
+    .getBoolPref("config.lockdown.showsavedpasswords");
   if (signons.length == 0 || gSelectUserInUse) {
     element.setAttribute("disabled","true");
     toggle.setAttribute("disabled","true");
+  } else if (viewLocked) {
+    toggle.setAttribute("disabled","true");
   } else {
     element.removeAttribute("disabled");
     toggle.removeAttribute("disabled");
@@ -154,7 +159,12 @@ function DeleteAllSignons() {
 }
 
 function TogglePasswordVisible() {
-  if (!showingPasswords && !ConfirmShowPasswords())
+  var viewLocked = Components.classes["@mozilla.org/preferences-service;1"]
+    .getService(Components.interfaces.nsIPrefBranch)
+    .getBoolPref("config.lockdown.showsavedpasswords");
+  // at that point if viewLocked is true, we shouldn't reach this code,
+  // but better be safe than sorry.
+  if (!showingPasswords && (viewLocked || !ConfirmShowPasswords()))
     return;
 
   showingPasswords = !showingPasswords;
openSUSE Build Service is sponsored by