old/toolkit-ui-lockdown.patch
author Wolfgang Rosenauer <wr@rosenauer.org>
Mon, 30 Nov 2009 08:50:50 +0100
changeset 8 19a8c8d53349
parent 4 523b1d92948c
permissions -rw-r--r--
Fixed patch comments
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     1
From: Robert O'Callahan
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     2
Subject: Lockdown feature for Toolkit UI
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     3
References:
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     4
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     5
diff --git a/toolkit/components/passwordmgr/content/passwordManager.js b/toolkit/components/passwordmgr/content/passwordManager.js
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     6
--- a/toolkit/components/passwordmgr/content/passwordManager.js
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     7
+++ b/toolkit/components/passwordmgr/content/passwordManager.js
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     8
@@ -120,8 +120,17 @@ function LoadSignons() {
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     9
   // disable "remove all signons" button if there are no signons
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    10
   var element = document.getElementById("removeAllSignons");
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    11
   var toggle = document.getElementById("togglePasswords");
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    12
+  try {
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    13
+    var viewLocked = Components.classes["@mozilla.org/preferences-service;1"]
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    14
+      .getService(Components.interfaces.nsIPrefBranch)
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    15
+      .getBoolPref("config.lockdown.showsavedpasswords");
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    16
+  } catch (e) {
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    17
+    var viewLocked = false;
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    18
+  }
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    19
   if (signons.length == 0 || gSelectUserInUse) {
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    20
     element.setAttribute("disabled","true");
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    21
+    toggle.setAttribute("disabled","true");
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    22
+  } else if (viewLocked) {
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    23
     toggle.setAttribute("disabled","true");
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    24
   } else {
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    25
     element.removeAttribute("disabled");
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    26
@@ -167,6 +176,18 @@ function DeleteAllSignons() {
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    27
 }
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    28
 
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    29
 function TogglePasswordVisible() {
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    30
+  try {
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    31
+    var viewLocked = Components.classes["@mozilla.org/preferences-service;1"]
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    32
+      .getService(Components.interfaces.nsIPrefBranch)
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    33
+      .getBoolPref("config.lockdown.showsavedpasswords");
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    34
+  } catch (e) {
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    35
+    var viewLocked = false;
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    36
+  }
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    37
+  // at that point if viewLocked is true, we shouldn't reach this code,
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    38
+  // but better be safe than sorry.
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    39
+  if (viewLocked) {
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    40
+    return;
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    41
+  }
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    42
   if (showingPasswords || ConfirmShowPasswords()) {
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    43
     showingPasswords = !showingPasswords;
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    44
     document.getElementById("togglePasswords").label = kSignonBundle.getString(showingPasswords ? "hidePasswords" : "showPasswords");
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    45
diff --git a/toolkit/components/printing/content/printdialog.js b/toolkit/components/printing/content/printdialog.js
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    46
--- a/toolkit/components/printing/content/printdialog.js
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    47
+++ b/toolkit/components/printing/content/printdialog.js
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    48
@@ -50,6 +50,7 @@ var gWebBrowserPrint   = null;
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    49
 var gWebBrowserPrint   = null;
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    50
 var gPrintSetInterface = Components.interfaces.nsIPrintSettings;
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    51
 var doDebug            = false;
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    52
+var gPrefService       = null;
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    53
 
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    54
 //---------------------------------------------------
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    55
 function initDialog()
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    56
@@ -87,11 +88,23 @@ function initDialog()
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    57
   dialog.fpDialog        = document.getElementById("fpDialog");
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    58
 
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    59
   dialog.enabled         = false;
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    60
+
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    61
+  gPrefService = Components.classes["@mozilla.org/preferences-service;1"]
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    62
+      .getService(Components.interfaces.nsIPrefService).getBranch(null);
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    63
+  if (gPrefService.getBoolPref("config.lockdown.savepage")) {
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    64
+    dialog.fileCheck.setAttribute("disabled", "true");
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    65
+  }
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    66
+  if (gPrefService.getBoolPref("config.lockdown.printing")) {
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    67
+    dialog.printButton.setAttribute("disabled", "true");
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    68
+  }
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    69
 }
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    70
 
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    71
 //---------------------------------------------------
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    72
 function checkInteger(element)
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    73
 {
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    74
+  if (gPrefService.getBoolPref("config.lockdown.printing"))
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    75
+    return;
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    76
+
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    77
   var value = element.value;
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    78
   if (value && value.length > 0) {
523b1d92948c Add mozilla-xulrunner192 package
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    79
     value = value.replace(/[^0-9]/g,"");