Bug 441403 - Migrate SeaMonkey's popup preferences to new pref window

r=mnyromyr sr=neil
This commit is contained in:
Ian Neal 2008-09-05 22:24:09 +01:00
Родитель f35faae108
Коммит f3a62627a7
9 изменённых файлов: 335 добавлений и 225 удалений

Просмотреть файл

@ -397,6 +397,7 @@ pref("alerts.totalOpenTime", 4000);
pref("browser.downloadmanager.behavior", 0);
pref("privacy.popups.sound_enabled", false);
pref("privacy.popups.sound_type", 1);
pref("privacy.popups.sound_url", "");
pref("privacy.popups.statusbar_icon_enabled", true);
pref("privacy.popups.prefill_whitelist", false);

Просмотреть файл

@ -279,28 +279,29 @@
<method name="playSoundForBlockedPopup">
<body>
<![CDATA[
const kCustomSound = 1;
var playSound = this._prefs.getBoolPref("privacy.popups.sound_enabled");
if (playSound) {
var sound = Components.classes["@mozilla.org/sound;1"]
.createInstance(Components.interfaces.nsISound);
var soundUrlSpec = this._prefs.getCharPref("privacy.popups.sound_url");
if (!soundUrlSpec) {
sound.beep();
return;
}
if (soundUrlSpec.substr(0, 7) == "file://") {
var soundType = this._prefs.getIntPref("privacy.popups.sound_type");
if (soundType == kCustomSound) {
var soundUrlSpec = this._prefs.getCharPref("privacy.popups.sound_url");
var fileHandler = Components.classes["@mozilla.org/network/protocol;1?name=file"]
.getService(Components.interfaces.nsIFileProtocolHandler);
var file = fileHandler.getFileFromURLSpec(soundUrlSpec);
if (file.exists()) {
var soundUrl = fileHandler.newFileURI(file);
sound.play(soundUrl);
return;
}
} else {
sound.playSystemSound(soundUrlSpec);
}
// Either a custom sound is selected which does not exist
// or the system beep was selected, so make the system beep.
sound.beep();
}
]]>
</body>

Просмотреть файл

@ -189,6 +189,7 @@ comm.jar:
content/communicator/pref/pref-navigator.xul (pref/pref-navigator.xul)
content/communicator/pref/pref-offline.xul (pref/pref-offline.xul)
content/communicator/pref/pref-policies.xul (pref/pref-policies.xul)
content/communicator/pref/pref-popups.js (pref/pref-popups.js)
content/communicator/pref/pref-popups.xul (pref/pref-popups.xul)
content/communicator/pref/pref-proxies.js (pref/pref-proxies.js)
content/communicator/pref/pref-proxies.xul (pref/pref-proxies.xul)

Просмотреть файл

@ -0,0 +1,184 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Ian Neal <iann_bugzilla@blueyonder.co.uk>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
const nsIFileProtocolHandler = Components.interfaces.nsIFileProtocolHandler;
var gSoundUrlPref;
var gSelectSound;
var gIOService;
var gFileHandler;
function Startup()
{
gSoundUrlPref = document.getElementById("privacy.popups.sound_url");
gSelectSound = document.getElementById("selectSound");
gIOService = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
gFileHandler = gIOService.getProtocolHandler("file")
.QueryInterface(nsIFileProtocolHandler);
SetLists();
SetButtons();
}
function SetLists()
{
const kPopupType = "popup";
const nsIPermissionManager = Components.interfaces.nsIPermissionManager;
const nsIPermission = Components.interfaces.nsIPermission;
var permissionManager = Components.classes["@mozilla.org/permissionmanager;1"]
.getService(nsIPermissionManager);
var pref = document.getElementById("privacy.popups.remove_blacklist");
if (pref.value)
{
var enumerator = permissionManager.enumerator;
var hosts = [];
while (enumerator.hasMoreElements())
{
var permission = enumerator.getNext();
if (permission instanceof nsIPermission)
{
if ((permission.type == kPopupType) &&
(permission.capability == nsIPermissionManager.DENY_ACTION))
hosts.push(permission.host);
}
}
for (var i in hosts)
permissionManager.remove(hosts[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 = gIOService.newURI(host, null, null);
permissionManager.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);
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);
EnableElement(gSelectSound, aCustomSelected, false);
EnableElementById("previewSound", aCustomSelected, false);
}
function ReadSoundLocation(aElement)
{
aElement.value = gSoundUrlPref.value;
if (aElement.value)
aElement.file = gFileHandler.getFileFromURLSpec(aElement.value);
}
function SelectSound()
{
const nsILocalFile = Components.interfaces.nsILocalFile;
const nsIFilePicker = Components.interfaces.nsIFilePicker;
var filepicker = Components.classes["@mozilla.org/filepicker;1"]
.createInstance(nsIFilePicker);
filepicker.init(window,
gSelectSound.getAttribute("filepickertitle"),
nsIFilePicker.modeOpen);
if (gSoundUrlPref.value)
filepicker.displayDirectory = gFileHandler.getFileFromURLSpec(gSoundUrlPref.value).parent;
filepicker.appendFilter(gSelectSound.getAttribute("filepickerfilter"),
"*.wav; *.wave");
filepicker.appendFilters(nsIFilePicker.filterAll);
if (filepicker.show() == nsIFilePicker.returnOK)
gSoundUrlPref.value = filepicker.fileURL.spec;
}
function PreviewSound()
{
var soundUrl = gSoundUrlPref.value;
var sound = Components.classes["@mozilla.org/sound;1"]
.createInstance(Components.interfaces.nsISound);
if (soundUrl)
sound.play(gIOService.newURI(soundUrl, null, null));
else
sound.beep();
}

Просмотреть файл

@ -1,4 +1,4 @@
<?xml version="1.0"?>
<?xml version="1.0"?>
<!-- ***** BEGIN LICENSE BLOCK *****
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
@ -21,6 +21,7 @@
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
- Ian Neal <iann_bugzilla@blueyonder.co.uk>
-
- Alternatively, the contents of this file may be used under the terms of
- either the GNU General Public License Version 2 or later (the "GPL"), or
@ -30,7 +31,7 @@
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the LGPL or the GPL. If you do not delete
- and other provisions required by the GPL or the LGPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
@ -38,215 +39,122 @@
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
<!DOCTYPE page [
<!ENTITY % prefPopupsDTD SYSTEM "chrome://communicator/locale/pref/pref-popups.dtd" >
<!DOCTYPE overlay [
<!ENTITY % prefPopupsDTD SYSTEM "chrome://communicator/locale/pref/pref-popups.dtd">
%prefPopupsDTD;
]>
<page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
id="popupsPanel"
onload="parent.initPanel('chrome://communicator/content/pref/pref-popups.xul');"
headertitle="&pref.popups.title;">
<script type="application/x-javascript" src="chrome://communicator/content/permissions/permissionsOverlay.js"/>
<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<prefpane id="popups_pane"
label="&pref.popups.title;"
script="chrome://communicator/content/pref/pref-popups.js">
<preferences id="popups_preferences">
<preference id="dom.disable_open_during_load"
name="dom.disable_open_during_load"
type="bool"
onchange="SetButtons();"/>
<preference id="pref.advanced.popups.disable_button.view_popups"
name="pref.advanced.popups.disable_button.view_popups"
type="bool"/>
<preference id="privacy.popups.sound_enabled"
name="privacy.popups.sound_enabled"
type="bool"
onchange="EnableSoundRadio(this.value);"/>
<preference id="privacy.popups.sound_type"
name="privacy.popups.sound_type"
type="int"
onchange="EnableSoundUrl(this.value == 1);"/>
<preference id="privacy.popups.sound_url"
name="privacy.popups.sound_url"
type="string"
onchange="EnableElementById('previewSound', true, false);"/>
<preference id="pref.advanced.popups.disable_button.select_sound"
name="pref.advanced.popups.disable_button.select_sound"
type="bool"/>
<preference id="pref.advanced.popups.disable_button.preview_sound"
name="pref.advanced.popups.disable_button.preview_sound"
type="bool"/>
<preference id="privacy.popups.statusbar_icon_enabled"
name="privacy.popups.statusbar_icon_enabled"
type="bool"/>
<preference id="privacy.popups.prefill_whitelist"
name="privacy.popups.prefill_whitelist"
type="bool"/>
<preference id="privacy.popups.remove_blacklist"
name="privacy.popups.remove_blacklist"
type="bool"/>
<preference id="privacy.popups.default_whitelist"
name="privacy.popups.default_whitelist"
type="string"/>
</preferences>
<script type="application/x-javascript">
<![CDATA[
<groupbox id="popupsArea">
<caption label="&pref.popups.caption;"/>
var _elementIDs = ["popupPolicy","playSound","playSoundUrl","displayIcon","removeBlacklist","prefillWhitelist"];
const nsIPermissionManager = Components.interfaces.nsIPermissionManager;
const popupType = "popup";
var gPolicyCheckbox;
var gSoundCheckbox;
var gSoundUrlBox;
var gSoundUrlButton;
var gPreviewSoundButton;
var gIconCheckbox;
var permissionManager;
var ioService;
function Startup() {
permissionManager = Components.classes["@mozilla.org/permissionmanager;1"]
.getService(nsIPermissionManager);
ioService = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
gPolicyCheckbox = document.getElementById("popupPolicy");
gSoundCheckbox = document.getElementById("playSound");
gSoundUrlBox = document.getElementById("playSoundUrl");
gSoundUrlButton = document.getElementById("selectSound");
gPreviewSoundButton = document.getElementById("previewSound");
gIconCheckbox = document.getElementById("displayIcon");
var removeBlacklist = (document.getElementById("removeBlacklist").getAttribute("value") == "true");
if (removeBlacklist) {
clearBlacklist();
document.getElementById("removeBlacklist").setAttribute("value", false);
}
var prefillWhitelist = (document.getElementById("prefillWhitelist").getAttribute("value") == "true");
if (prefillWhitelist) {
loadWhitelist();
document.getElementById("prefillWhitelist").setAttribute("value", false);
}
if (parent.queuedTag == "chrome://communicator/content/pref/pref-popups.xul") {
// opened from About Popups menuitem
gPolicyCheckbox.checked = true;
parent.queuedTag = null;
}
setButtons();
}
function clearBlacklist() {
var enumerator = permissionManager.enumerator;
var hosts = [];
while (enumerator.hasMoreElements()) {
var permission = enumerator.getNext();
if (permission) {
permission = permission.QueryInterface(Components.interfaces.nsIPermission);
if ((permission.type == popupType) && (permission.capability == nsIPermissionManager.DENY_ACTION))
hosts[hosts.length] = permission.host;
}
}
for (var i in hosts) {
permissionManager.remove(hosts[i], popupType);
}
}
function loadWhitelist() {
try {
var whitelist = parent.hPrefWindow.getPref("localizedstring",
"privacy.popups.default_whitelist");
var hosts = whitelist.split(",");
for (var i in hosts) {
var host = hosts[i];
host = "http://" + host;
var uri = ioService.newURI(host, null, null);
permissionManager.add(uri, popupType, true);
}
}
catch (ex) { }
}
function setButtons() {
var exceptionsButton = document.getElementById("exceptionsButton");
exceptionsButton.disabled = !gPolicyCheckbox.checked;
if (!gPolicyCheckbox.checked) {
gSoundCheckbox.disabled = true;
gSoundUrlBox.disabled = true;
gSoundUrlButton.disabled = true;
gPreviewSoundButton.disabled = true;
gIconCheckbox.disabled = true;
}
else {
gSoundCheckbox.disabled = false;
gSoundUrlBox.disabled = false;
gSoundUrlButton.disabled = false;
gPreviewSoundButton.disabled = false;
gIconCheckbox.disabled = false;
enableSoundUrl(gSoundCheckbox.checked);
}
}
function selectSound() {
var nsIFilePicker = Components.interfaces.nsIFilePicker;
var filepicker = Components.classes["@mozilla.org/filepicker;1"]
.createInstance(nsIFilePicker);
filepicker.init(window, document.getElementById("selectSound").getAttribute("filepickertitle"), nsIFilePicker.modeOpen);
filepicker.appendFilters(nsIFilePicker.filterAll);
var ret = filepicker.show();
if (ret == nsIFilePicker.returnOK)
gSoundUrlBox.value = filepicker.file.path;
onSoundInput();
}
function previewSound() {
var soundUrl = gSoundUrlBox.value;
var sound = Components.classes["@mozilla.org/sound;1"]
.createInstance(Components.interfaces.nsISound);
if (soundUrl.indexOf("file://") == -1) {
sound.playSystemSound(soundUrl);
}
else {
var url = Components.classes["@mozilla.org/network/standard-url;1"]
.createInstance(Components.interfaces.nsIURL);
url.spec = soundUrl;
sound.play(url)
}
}
function enableSoundUrl(soundChecked) {
gSoundUrlBox.disabled = !soundChecked;
gSoundUrlButton.disabled = !soundChecked;
if (soundChecked && gSoundUrlBox.value) {
gPreviewSoundButton.disabled = false;
}
else
gPreviewSoundButton.disabled = true;
}
function onSoundInput() {
gPreviewSoundButton.disabled = gSoundUrlBox.value == "";
}
]]>
</script>
<groupbox id="popupsArea">
<caption label="&pref.popups.caption;"/>
<hbox align="center">
<checkbox id="popupPolicy" label="&popupBlock.label;" accesskey="&popupBlock.accesskey;"
oncommand="setButtons()"
preftype="bool" prefstring="dom.disable_open_during_load"
prefattribute="checked"/>
<spacer flex="1"/>
<button id="exceptionsButton" label="&popupExceptions.label;"
accesskey="&popupExceptions.accesskey;"
oncommand="viewPopups('');"/>
</hbox>
<separator class="thin"/>
<description id="whenBlock">&whenBlock.description;</description>
<hbox align="center">
<checkbox id="playSound" label="&playSound.label;"
accesskey="&playSound.accesskey;"
oncommand="enableSoundUrl(this.checked);"
preftype="bool" prefstring="privacy.popups.sound_enabled"
prefattribute="checked"/>
</hbox>
<hbox align="center">
<textbox flex="1" id="playSoundUrl"
prefstring="privacy.popups.sound_url" oninput="onSoundInput()"/>
<button id="selectSound" label="&selectSound.label;" accesskey="&selectSound.accesskey;"
filepickertitle="&selectSound.title;" oncommand="selectSound();"/>
<button id="previewSound" label="&previewSound.label;" accesskey="&previewSound.accesskey;"
oncommand="previewSound();"/>
</hbox>
<hbox align="center">
<checkbox id="displayIcon" label="&displayIcon.label;"
accesskey="&displayIcon.accesskey;"
preftype="bool" prefstring="privacy.popups.statusbar_icon_enabled"
prefattribute="checked"/>
</hbox>
<separator class="thin"/>
<description>&popupNote.description;</description>
<data id="prefillWhitelist" preftype="bool" prefattribute="value" prefstring="privacy.popups.prefill_whitelist"/>
<data id="removeBlacklist" preftype="bool" prefattribute="value" prefstring="privacy.popups.remove_blacklist"/>
</groupbox>
</page>
<hbox>
<checkbox id="popupPolicy"
label="&popupBlock.label;"
accesskey="&popupBlock.accesskey;"
preference="dom.disable_open_during_load"/>
<spacer flex="1"/>
<button id="exceptionsButton"
label="&popupExceptions.label;"
accesskey="&popupExceptions.accesskey;"
preference="pref.advanced.popups.disable_button.view_popups"
oncommand="viewPopups('');"/>
</hbox>
<separator class="thin"/>
<description id="whenBlock">&whenBlock.description;</description>
<hbox>
<checkbox id="playSound"
label="&playSound.label;"
accesskey="&playSound.accesskey;"
preference="privacy.popups.sound_enabled"/>
</hbox>
<hbox class="indent">
<radiogroup id="popupSoundType"
preference="privacy.popups.sound_type"
aria-labelledby="playSound">
<radio id="popupSystemSound"
class="iconic"
value="0"
label="&systemSound.label;"
accesskey="&systemSound.accesskey;"/>
<radio id="popupCustomSound"
class="iconic"
value="1"
label="&customSound.label;"
accesskey="&customSound.accesskey;"/>
</radiogroup>
</hbox>
<hbox class="indent">
<filefield id="playSoundUrl"
flex="1"
preference="privacy.popups.sound_url"
preference-editable="true"
onsyncfrompreference="return document.getElementById('popups_pane').ReadSoundLocation(this);"
aria-labelledby="popupCustomSound"/>
<button id="selectSound"
label="&selectSound.label;"
accesskey="&selectSound.accesskey;"
preference="pref.advanced.popups.disable_button.select_sound"
filepickertitle="&selectSound.title;"
filepickerfilter="&selectSound.filter;"
oncommand="SelectSound();"/>
<button id="previewSound"
label="&previewSound.label;"
accesskey="&previewSound.accesskey;"
preference="pref.advanced.popups.disable_button.preview_sound"
oncommand="PreviewSound();"/>
</hbox>
<hbox>
<checkbox id="displayIcon"
label="&displayIcon.label;"
accesskey="&displayIcon.accesskey;"
preference="privacy.popups.statusbar_icon_enabled"/>
</hbox>
<separator class="thin"/>
<description>&popupNote.description;</description>
</groupbox>
</prefpane>
</overlay>

Просмотреть файл

@ -162,10 +162,12 @@
<treeitem id="imagesItem" label="&images.label;"
prefpane="images_pane" helpTopic="images_prefs"
url="chrome://communicator/content/pref/pref-images.xul"/>
<!--
<treeitem id="popupspref"
<treeitem id="popupsItem"
label="&popups.label;"
prefpane="popups_pane"
helpTopic="pop_up_blocking"
url="chrome://communicator/content/pref/pref-popups.xul"/>
<!--
<treeitem id="masterpassItem"
label="&masterpass.label;"
prefpane="masterpass_pane"

Просмотреть файл

@ -139,8 +139,7 @@
</treeitem>
<treeitem id="popupspref">
<treerow>
<treecell url="chrome://communicator/content/pref/pref-popups.xul"
label="&popups.label;"/>
<treecell label="(Migrated: &popups.label;)"/>
</treerow>
</treeitem>
</treechildren>

Просмотреть файл

@ -12,13 +12,18 @@
<!ENTITY whenBlock.description "When a popup window has been blocked:">
<!ENTITY playSound.label "Play a sound:">
<!ENTITY playSound.accesskey "s">
<!ENTITY playSound.accesskey "P">
<!ENTITY systemSound.label "System beep">
<!ENTITY systemSound.accesskey "S">
<!ENTITY customSound.label "Custom sound file">
<!ENTITY customSound.accesskey "C">
<!ENTITY selectSound.label "Browse…">
<!ENTITY selectSound.accesskey "r">
<!ENTITY selectSound.accesskey "o">
<!ENTITY previewSound.label "Preview">
<!ENTITY previewSound.accesskey "P">
<!ENTITY previewSound.accesskey "v">
<!ENTITY selectSound.title "Select Popup Block Sound">
<!ENTITY selectSound.filter "Sounds">
<!ENTITY displayIcon.label "Display an icon in the browser status bar">
<!ENTITY displayIcon.accesskey "D">

Просмотреть файл

@ -553,6 +553,14 @@ nsSeamonkeyProfileMigrator::PrefTransform gTransforms[] = {
MAKESAMETYPEPREFTRANSFORM("plugin.override_internal_types", Bool),
MAKESAMETYPEPREFTRANSFORM("plugin.expose_full_path", Bool),
MAKESAMETYPEPREFTRANSFORM("privacy.popups.disable_from_plugins", Int),
MAKESAMETYPEPREFTRANSFORM("privacy.popups.prefill_whitelist", Bool),
MAKESAMETYPEPREFTRANSFORM("privacy.popups.remove_blacklist", Bool),
MAKESAMETYPEPREFTRANSFORM("privacy.popups.showBrowserMessage", Bool),
MAKESAMETYPEPREFTRANSFORM("privacy.popups.sound_enabled", Bool),
MAKEPREFTRANSFORM("privacy.popups.sound_url", "privacy.popups.sound_type", String, File),
MAKESAMETYPEPREFTRANSFORM("privacy.popups.statusbar_icon_enabled", Bool),
MAKESAMETYPEPREFTRANSFORM("security.default_personal_cert", String),
MAKESAMETYPEPREFTRANSFORM("security.enable_ssl2", Bool),
MAKESAMETYPEPREFTRANSFORM("security.enable_ssl3", Bool),
@ -653,7 +661,8 @@ nsSeamonkeyProfileMigrator::TransformPreferences(const char* aSourcePrefFileName
"mousewheel.",
"network.http.",
"print.",
"privacy.",
"privacy.item.",
"privacy.sanitize.",
"security.OSCP.",
"security.crl.",
"ui.key."