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