1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var gSoundUrlPref;
function Startup()
{
gSoundUrlPref = document.getElementById("privacy.popups.sound_url");
SetLists();
SetButtons();
}
function SetLists()
{
const kPopupType = "popup";
var pref = document.getElementById("privacy.popups.remove_blacklist");
if (pref.value)
{
var enumerator = Services.perms.enumerator;
var uris = [];
while (enumerator.hasMoreElements())
{
var permission = enumerator.getNext();
if (permission instanceof Ci.nsIPermission)
{
if ((permission.type == kPopupType) &&
(permission.capability == Ci.nsIPermissionManager.DENY_ACTION))
uris.push(permission.principal.URI);
}
}
for (var i in uris)
Services.perms.remove(uris[i], kPopupType);
pref.value = false;
}
pref = document.getElementById("privacy.popups.prefill_whitelist");
if (pref.value)
{
try
{
var whitelist = document.getElementById("privacy.popups.default_whitelist").value;
var hosts = whitelist.split(",");
for (var i in hosts)
{
var host = "http://" + hosts[i];
var uri = Services.io.newURI(host);
Services.perms.add(uri, kPopupType, true);
}
}
catch (ex) {}
pref.value = false;
}
}
function SetButtons()
{
var prefString = document.getElementById("popupPolicy")
.getAttribute("preference");
var enable = document.getElementById(prefString).value;
EnableElementById("exceptionsButton", enable, false);
EnableElementById("displayIcon", enable, false);
EnableElementById("displayPopupsNotification", enable, false);
var element = document.getElementById("playSound");
EnableElement(element, enable, false);
prefString = element.getAttribute("preference");
EnableSoundRadio(enable && document.getElementById(prefString).value);
}
function EnableSoundRadio(aSoundChecked)
{
const kCustomSound = 1;
var element = document.getElementById("popupSoundType");
EnableElement(element, aSoundChecked, false);
var pref = document.getElementById(element.getAttribute("preference"));
EnableSoundUrl(aSoundChecked && (pref.value == kCustomSound));
}
function EnableSoundUrl(aCustomSelected)
{
EnableElementById("playSoundUrl", aCustomSelected, false);
EnableElementById("selectSound", aCustomSelected, false);
EnableElementById("playSoundButton", aCustomSelected, false);
}
|