|
1 From: various contributors |
|
2 Subject: toolkit ui lockdown hooks |
|
3 |
|
4 diff --git a/toolkit/components/passwordmgr/content/passwordManager.js b/toolkit/components/passwordmgr/content/passwordManager.js |
|
5 --- a/toolkit/components/passwordmgr/content/passwordManager.js |
|
6 +++ b/toolkit/components/passwordmgr/content/passwordManager.js |
|
7 @@ -119,19 +119,28 @@ function LoadSignons() { |
|
8 // SignonColumnSort) assumes we want to toggle the sort |
|
9 // direction but here we don't so we have to trick it |
|
10 lastSignonSortAscending = !lastSignonSortAscending; |
|
11 SignonColumnSort(lastSignonSortColumn); |
|
12 |
|
13 // disable "remove all signons" button if there are no signons |
|
14 var element = document.getElementById("removeAllSignons"); |
|
15 var toggle = document.getElementById("togglePasswords"); |
|
16 + try { |
|
17 + var viewLocked = Components.classes["@mozilla.org/preferences-service;1"] |
|
18 + .getService(Components.interfaces.nsIPrefBranch) |
|
19 + .getBoolPref("config.lockdown.showsavedpasswords"); |
|
20 + } catch (e) { |
|
21 + var viewLocked = false; |
|
22 + } |
|
23 if (signons.length == 0 || gSelectUserInUse) { |
|
24 element.setAttribute("disabled","true"); |
|
25 toggle.setAttribute("disabled","true"); |
|
26 + } else if (viewLocked) { |
|
27 + toggle.setAttribute("disabled","true"); |
|
28 } else { |
|
29 element.removeAttribute("disabled"); |
|
30 toggle.removeAttribute("disabled"); |
|
31 } |
|
32 |
|
33 return true; |
|
34 } |
|
35 |
|
36 @@ -166,16 +175,28 @@ function DeleteAllSignons() { |
|
37 var syncNeeded = (signonsTreeView._filterSet.length != 0); |
|
38 DeleteAllFromTree(signonsTree, signonsTreeView, |
|
39 signonsTreeView._filterSet.length ? signonsTreeView._filterSet : signons, |
|
40 deletedSignons, "removeSignon", "removeAllSignons"); |
|
41 FinalizeSignonDeletions(syncNeeded); |
|
42 } |
|
43 |
|
44 function TogglePasswordVisible() { |
|
45 + try { |
|
46 + var viewLocked = Components.classes["@mozilla.org/preferences-service;1"] |
|
47 + .getService(Components.interfaces.nsIPrefBranch) |
|
48 + .getBoolPref("config.lockdown.showsavedpasswords"); |
|
49 + } catch (e) { |
|
50 + var viewLocked = false; |
|
51 + } |
|
52 + // at that point if viewLocked is true, we shouldn't reach this code, |
|
53 + // but better be safe than sorry. |
|
54 + if (viewLocked) { |
|
55 + return; |
|
56 + } |
|
57 if (showingPasswords || ConfirmShowPasswords()) { |
|
58 showingPasswords = !showingPasswords; |
|
59 document.getElementById("togglePasswords").label = kSignonBundle.getString(showingPasswords ? "hidePasswords" : "showPasswords"); |
|
60 document.getElementById("togglePasswords").accessKey = kSignonBundle.getString(showingPasswords ? "hidePasswordsAccessKey" : "showPasswordsAccessKey"); |
|
61 document.getElementById("passwordCol").hidden = !showingPasswords; |
|
62 _filterPasswords(); |
|
63 } |
|
64 |
|
65 diff --git a/toolkit/components/printing/content/printdialog.js b/toolkit/components/printing/content/printdialog.js |
|
66 --- a/toolkit/components/printing/content/printdialog.js |
|
67 +++ b/toolkit/components/printing/content/printdialog.js |
|
68 @@ -45,16 +45,17 @@ var printService = null; |
|
69 var gOriginalNumCopies = 1; |
|
70 |
|
71 var paramBlock; |
|
72 var gPrefs = null; |
|
73 var gPrintSettings = null; |
|
74 var gWebBrowserPrint = null; |
|
75 var gPrintSetInterface = Components.interfaces.nsIPrintSettings; |
|
76 var doDebug = false; |
|
77 +var gPrefService = null; |
|
78 |
|
79 //--------------------------------------------------- |
|
80 function initDialog() |
|
81 { |
|
82 dialog = new Object; |
|
83 |
|
84 dialog.propertiesButton = document.getElementById("properties"); |
|
85 dialog.descText = document.getElementById("descText"); |
|
86 @@ -82,21 +83,33 @@ function initDialog() |
|
87 |
|
88 dialog.printButton = document.documentElement.getButton("accept"); |
|
89 |
|
90 // <data> elements |
|
91 dialog.printName = document.getElementById("printButton"); |
|
92 dialog.fpDialog = document.getElementById("fpDialog"); |
|
93 |
|
94 dialog.enabled = false; |
|
95 + |
|
96 + gPrefService = Components.classes["@mozilla.org/preferences-service;1"] |
|
97 + .getService(Components.interfaces.nsIPrefService).getBranch(null); |
|
98 + if (gPrefService.getBoolPref("config.lockdown.savepage")) { |
|
99 + dialog.fileCheck.setAttribute("disabled", "true"); |
|
100 + } |
|
101 + if (gPrefService.getBoolPref("config.lockdown.printing")) { |
|
102 + dialog.printButton.setAttribute("disabled", "true"); |
|
103 + } |
|
104 } |
|
105 |
|
106 //--------------------------------------------------- |
|
107 function checkInteger(element) |
|
108 { |
|
109 + if (gPrefService.getBoolPref("config.lockdown.printing")) |
|
110 + return; |
|
111 + |
|
112 var value = element.value; |
|
113 if (value && value.length > 0) { |
|
114 value = value.replace(/[^0-9]/g,""); |
|
115 if (!value) value = ""; |
|
116 element.value = value; |
|
117 } |
|
118 if (!value || value < 1 || value > 999) |
|
119 dialog.printButton.setAttribute("disabled","true"); |