gecko-dev/suite/common/pref/pref-advanced.xul

377 lines
14 KiB
XML

<?xml version="1.0"?>
<!-- ***** 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 Communicator client code, released
March 31, 1998.
The Initial Developer of the Original Code is
Netscape Communications Corporation.
Portions created by the Initial Developer are Copyright (C) 1998-1999
the Initial Developer. All Rights Reserved.
Contributor(s):
Mike Kowalski <mikejk@ameritech.net>
Alternatively, the contents of this file may be used under the terms of
either of 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 ***** -->
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
<!DOCTYPE page [
<!ENTITY % brandDTD SYSTEM "chrome://global/locale/brand.dtd">
%brandDTD;
<!ENTITY % prefAdvancedDTD SYSTEM "chrome://communicator/locale/pref/pref-advanced.dtd"> %prefAdvancedDTD;
]>
<page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="parent.initPanel('chrome://communicator/content/pref/pref-advanced.xul');"
headertitle="&lHeader;">
<script type="application/x-javascript">
<![CDATA[
var panel = "chrome://communicator/content/pref/pref-advanced.xul";
var _elementIDs = ["advancedJavaAllow", "systemPrefCheck"];
function Startup() {
turboCheck();
sysPrefCheck();
initJVMConfigList();
}
/*
* Name: turboCheck()
*
* Arguments: none
*
* Description: This function is called when the root advanced prefs panel
* is loaded. The turbo mode setting is not exactly a preference -- setting
* the checkbox should (on leaving the prefs with an "Ok") result in a call
* to the backend to do the necessary win32 registry twiddling needed for
* turbo mode to go into effect. Clearing it should undo this work. We need
* to call the backend to determine if turbo mode is enabled (since we are
* required to check for it in a non-trivial way) and then explicitly set the
* checkbox here based on what we find. Finally, we have to hide the checkbox
* (and the group box that frames it) if we are not executing on a Win32
* platform.
*
* Return Value: void
*
* Original Code: syd@netscape.com 6/8/2001
*
*/
function turboCheck()
{
var frame = document.getElementById("perfSettings");
if (navigator.platform != "Win32") {
frame.hidden = true;
return;
}
if (!("isTurboEnabled" in parent))
parent.isTurboEnabled = -1;
else {
document.getElementById("enableTurbo").checked = parent.isTurboEnabled;
return;
}
var winhooksService = Components.classes["@mozilla.org/winhooks;1"].getService(Components.interfaces.nsIWindowsHooks);
if (winhooksService) {
parent.isTurboEnabled = winhooksService.isOptionEnabled("-turbo");
document.getElementById("enableTurbo").checked = parent.isTurboEnabled;
}
parent.hPrefWindow.registerOKCallbackFunc( saveTurboSetting );
}
/*
* Name: saveTurboSetting()
*
* Arguments: none
*
* Description: This function is called when the user hits the OK button in
* the preferences panel. The function determines what the turbo "preference"
* setting is and performs the appropriate action to enable or disable turbo mode.
*
* Return Value: void
*
* Original Code: syd@netscape.com 6/9/2001
*
*/
function saveTurboSetting() {
if (navigator.platform != "Win32")
return;
var winhooksService = Components.classes["@mozilla.org/winhooks;1"].getService(Components.interfaces.nsIWindowsHooks);
if (winhooksService && parent.isTurboEnabled != -1) {
if (parent.isTurboEnabled)
winhooksService.startupAddOption("-turbo");
else
winhooksService.startupRemoveOption("-turbo");
var appStartup = Components.classes["@mozilla.org/toolkit/app-startup;1"].
getService(Components.interfaces.nsIAppStartup);
var nativeAppSupport = null;
try {
nativeAppSupport = appStartup.nativeAppSupport;
}
catch ( ex ) {
}
if (nativeAppSupport)
nativeAppSupport.isServerMode = parent.isTurboEnabled;
}
}
function sysPrefCheck() {
var frame = document.getElementById("systemPrefs");
if ("@mozilla.org/system-preference-service;1" in Components.classes)
try {
var appShell = Components.classes["@mozilla.org/system-preference-service;1"].getService(Components.interfaces.nsIPrefBranch);
return;
}
catch(e) {}
frame.hidden = true;
}
function sysPrefUpdate() {
var checkObj = document.getElementById("systemPrefCheck");
var prefstring = checkObj.getAttribute( "prefstring" );
parent.hPrefWindow.setPref("bool", prefstring, checkObj.checked);
parent.hPrefWindow.pagePrefChanged = true;
parent.hPrefWindow.pagePrefUpdated = [];
}
]]>
</script>
<groupbox id="advancedSettings" align="start">
<caption label="&advancedTitle.label;"/>
<vbox align="start" id="contentEnablingBox">
<checkbox id="advancedJavaAllow" label="&enbJavaCheck.label;" accesskey="&enbJavaCheck.accesskey;"
prefstring="security.enable_java"
oncommand="javaCheck(true)"/>
</vbox>
<separator/>
</groupbox>
<script type="application/x-javascript">
<![CDATA[
function javaCheck(setFocus) {
if (!jvmConfigList) return;
var checked = document.getElementById("advancedJavaAllow").checked;
setVisible(checked);
}
const nsIJVMConfig = Components.interfaces.nsIJVMConfig;
var jvmConfigMgr;
var jvmConfigList = getJVMConfigList();
const currentJVMPluginPath = getCurrentJVMPluginPath();
var oldJVMConfig = null;
function getJVMConfigMgr() {
return "@mozilla.org/oji/jvm-config-mgr;1" in Components.classes
&& Components.classes["@mozilla.org/oji/jvm-config-mgr;1"]
.getService(Components.interfaces.nsIJVMConfigManager);
}
function getJVMConfigList() {
if (!jvmConfigMgr)
jvmConfigMgr = getJVMConfigMgr();
return jvmConfigMgr && jvmConfigMgr.getJVMConfigList();
}
function getCurrentJVMPluginPath() {
var result = "";
if ("application/x-java-vm" in navigator.mimeTypes)
try {
var prefs = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
// Since we don't have a fullPath attribute in nsIDOMPlugin,
// we have to set the set pref "plugin.expose_full_path"
// to true and then get it. Related bug is 204476
var oldValue = prefs.getBoolPref("plugin.expose_full_path");
if (!oldValue)
prefs.setBoolPref("plugin.expose_full_path", true);
try {
result = navigator.mimeTypes["application/x-java-vm"]
.enabledPlugin.filename;
} catch (e) {};
// Set the pref to original value.
if (!oldValue)
prefs.setBoolPref("plugin.expose_full_path", oldValue);
} catch (e) {}
return result;
}
const jvmConfigListView = {
currentJVMConfig : null,
rowCount : 0,
setTree : function(tree) {},
getImageSrc : function(row, column) {},
getProgressMode : function(row, column) {},
getCellValue : function(row, column) {},
isSeparator : function(index) {return false;},
isSorted: function() { return false; },
isContainer : function(index) {return false;},
cycleHeader : function(column) {},
getRowProperties : function(index, prop) {},
getColumnProperties : function(column, prop) {},
getCellProperties : function(row, column, prop) {},
getCellText : function(row,column) {
if (jvmConfigList) {
var jvmConfig = jvmConfigList.queryElementAt(row, nsIJVMConfig);
if (column.id == "name")
return jvmConfig.version;
if (column.id == "home")
return jvmConfig.path.path;
}
return "";
},
refresh : function(jvmConfigListObj) {
if (jvmConfigList) {
this.rowCount = jvmConfigList.length;
var currentIndex = -1;
for (i = 0; i < this.rowCount; i++) {
var jvmConfig = jvmConfigList.queryElementAt(i, nsIJVMConfig)
var jvmHome = jvmConfig.path.path;
if (currentJVMPluginPath.indexOf(jvmHome + "/") >= 0) {
this.currentJVMConfig = jvmConfig;
currentIndex = i;
}
}
// Only show the panel if we have the choice.
if (jvmConfigList.length == 0 ||
(jvmConfigList.length == 1 && currentIndex >= 0)) {
setVisible(false);
return;
}
jvmConfigListObj.treeBoxObject.view = this;
if (currentIndex >= 0)
jvmConfigListView.selection.select(currentIndex);
} else {
this.rowCount = 0;
}
},
getCurrentJVMConfig : function() {
return this.currentJVMConfig;
}
};
function setVisible(visible) {
var javaConfigPanel = document.getElementById("javaPluginSettings");
javaConfigPanel.hidden = !visible;
}
function initJVMConfigList() {
var javaChecked = document.getElementById("advancedJavaAllow").checked;
if (jvmConfigList) {
var jvmConfigListObj = document.getElementById("jvmConfigListObj");
if (jvmConfigListObj) {
jvmConfigListView.refresh(jvmConfigListObj);
oldJVMConfig = jvmConfigListView.getCurrentJVMConfig();
parent.hPrefWindow.registerOKCallbackFunc(switchJVM);
}
if (!javaChecked) setVisible(false);
} else {
setVisible(false);
}
}
function switchJVM() {
var currentIndex = jvmConfigListView.selection.currentIndex;
if (currentIndex >= 0 && jvmConfigMgr && jvmConfigList) {
var currentJVMConfig =
jvmConfigList.queryElementAt(currentIndex, nsIJVMConfig);
if (currentJVMConfig && currentJVMConfig != oldJVMConfig) {
var promptService =
Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var navbundle = document.getElementById("navBundle");
var brandbundle = document.getElementById("brandBundle");
var dialogTitle = navbundle.getString("switchJVMTitle");
try {
jvmConfigMgr.setCurrentJVMConfig(currentJVMConfig);
} catch (e) {
errorMsg = navbundle.getString("switchJVMFailed");
promptService.alert(window, dialogTitle, errorMsg);
return;
}
oldJVMConfig = currentJVMConfig;
}
}
}
]]>
</script>
<stringbundle id="navBundle"
src="chrome://navigator/locale/navigator.properties"/>
<stringbundle id="brandBundle"
src="chrome://global/locale/brand.properties"/>
<groupbox id="javaPluginSettings" align="start">
<caption label="&jvm.configuration;"/>
<tree id="jvmConfigListObj" style="width: 60em; height: 10em"
hidecolumnpicker="true">
<treecols>
<treecol id="name" label="&jvm.name;" flex="2"/>
<splitter class="tree-splitter"/>
<treecol id="home" label="&jvm.home;" flex="13"/>
</treecols>
<treechildren/>
</tree>
</groupbox>
<groupbox id="perfSettings">
<caption id="perfLabel" label="&perfTitle.label;"/>
<vbox id="perfBox" align="start">
<checkbox id="enableTurbo" label="&enableTurbo.label;" accesskey="&enableTurboCheck.accesskey;"
oncommand="parent.isTurboEnabled = this.checked;"/>
<vbox class="indent" flex="1">
<description>&perfdescription.label;</description>
</vbox>
</vbox>
</groupbox>
<groupbox id="systemPrefs">
<caption id="systemPrefCaption" label="&systemPrefCaption.label;"/>
<vbox id="systemPrefBox" align="start">
<checkbox id="systemPrefCheck" label="&systemPrefCheck.label;" accesskey="&systemPrefCheck.accesskey;"
prefstring="config.use_system_prefs"
oncommand="sysPrefUpdate();"/>
<vbox class="indent" flex="1">
<description>&systemPrefDescription.label;</description>
</vbox>
</vbox>
</groupbox>
</page>