зеркало из https://github.com/mozilla/gecko-dev.git
Bug 732125 - Content pane for in-content preferences. r=jaws,bmcbride
This commit is contained in:
Родитель
ce61db5b10
Коммит
144123e231
|
@ -0,0 +1,243 @@
|
||||||
|
/* 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 gContentPane = {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the fonts dropdowns displayed in this pane.
|
||||||
|
*/
|
||||||
|
init: function ()
|
||||||
|
{
|
||||||
|
this._rebuildFonts();
|
||||||
|
var menulist = document.getElementById("defaultFont");
|
||||||
|
if (menulist.selectedIndex == -1) {
|
||||||
|
menulist.insertItemAt(0, "", "", "");
|
||||||
|
menulist.selectedIndex = 0;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// UTILITY FUNCTIONS
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility function to enable/disable the button specified by aButtonID based
|
||||||
|
* on the value of the Boolean preference specified by aPreferenceID.
|
||||||
|
*/
|
||||||
|
updateButtons: function (aButtonID, aPreferenceID)
|
||||||
|
{
|
||||||
|
var button = document.getElementById(aButtonID);
|
||||||
|
var preference = document.getElementById(aPreferenceID);
|
||||||
|
button.disabled = preference.value != true;
|
||||||
|
return undefined;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The exceptions types which may be passed to this._showExceptions().
|
||||||
|
*/
|
||||||
|
_exceptionsParams: {
|
||||||
|
popup: { blockVisible: false, sessionVisible: false, allowVisible: true,
|
||||||
|
prefilledHost: "", permissionType: "popup" },
|
||||||
|
image: { blockVisible: true, sessionVisible: false, allowVisible: true,
|
||||||
|
prefilledHost: "", permissionType: "image" }
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays the exceptions dialog of the given type, where types map onto the
|
||||||
|
* the fields in this._exceptionsParams.
|
||||||
|
*/
|
||||||
|
_showExceptions: function (aPermissionType)
|
||||||
|
{
|
||||||
|
var bundlePreferences = document.getElementById("bundlePreferences");
|
||||||
|
var params = this._exceptionsParams[aPermissionType];
|
||||||
|
params.windowTitle = bundlePreferences.getString(aPermissionType + "permissionstitle");
|
||||||
|
params.introText = bundlePreferences.getString(aPermissionType + "permissionstext");
|
||||||
|
|
||||||
|
openDialog("chrome://browser/content/preferences/permissions.xul",
|
||||||
|
"Browser:Permissions", "resizable=yes", params);
|
||||||
|
},
|
||||||
|
|
||||||
|
// BEGIN UI CODE
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Preferences:
|
||||||
|
*
|
||||||
|
* dom.disable_open_during_load
|
||||||
|
* - true if popups are blocked by default, false otherwise
|
||||||
|
* permissions.default.image
|
||||||
|
* - an integer:
|
||||||
|
* 1 all images should be loaded,
|
||||||
|
* 2 no images should be loaded,
|
||||||
|
* 3 load only images from the site on which the current page resides
|
||||||
|
* (i.e., if viewing foo.example.com, foo.example.com/foo.jpg and
|
||||||
|
* bar.foo.example.com/bar.jpg load but example.com/quux.jpg does not)
|
||||||
|
* javascript.enabled
|
||||||
|
* - true if JavaScript is enabled, false otherwise
|
||||||
|
*/
|
||||||
|
|
||||||
|
// POP-UPS
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays the popup exceptions dialog where specific site popup preferences
|
||||||
|
* can be set.
|
||||||
|
*/
|
||||||
|
showPopupExceptions: function ()
|
||||||
|
{
|
||||||
|
this._showExceptions("popup");
|
||||||
|
},
|
||||||
|
|
||||||
|
// IMAGES
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts the value of the permissions.default.image preference into a
|
||||||
|
* Boolean value for use in determining the state of the "load images"
|
||||||
|
* checkbox, returning true if images should be loaded and false otherwise.
|
||||||
|
*/
|
||||||
|
readLoadImages: function ()
|
||||||
|
{
|
||||||
|
var pref = document.getElementById("permissions.default.image");
|
||||||
|
return (pref.value == 1 || pref.value == 3);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the "load images" preference value which maps to the state of the
|
||||||
|
* preferences UI.
|
||||||
|
*/
|
||||||
|
writeLoadImages: function ()
|
||||||
|
{
|
||||||
|
return (document.getElementById("loadImages").checked) ? 1 : 2;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays image exception preferences for which websites can and cannot
|
||||||
|
* load images.
|
||||||
|
*/
|
||||||
|
showImageExceptions: function ()
|
||||||
|
{
|
||||||
|
this._showExceptions("image");
|
||||||
|
},
|
||||||
|
|
||||||
|
// JAVASCRIPT
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays the advanced JavaScript preferences for enabling or disabling
|
||||||
|
* various annoying behaviors.
|
||||||
|
*/
|
||||||
|
showAdvancedJS: function ()
|
||||||
|
{
|
||||||
|
openDialog("chrome://browser/content/preferences/advanced-scripts.xul",
|
||||||
|
"Browser:AdvancedScripts", null);
|
||||||
|
},
|
||||||
|
|
||||||
|
// FONTS
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Populates the default font list in UI.
|
||||||
|
*/
|
||||||
|
_rebuildFonts: function ()
|
||||||
|
{
|
||||||
|
var langGroupPref = document.getElementById("font.language.group");
|
||||||
|
this._selectDefaultLanguageGroup(langGroupPref.value,
|
||||||
|
this._readDefaultFontTypeForLanguage(langGroupPref.value) == "serif");
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
_selectDefaultLanguageGroup: function (aLanguageGroup, aIsSerif)
|
||||||
|
{
|
||||||
|
const kFontNameFmtSerif = "font.name.serif.%LANG%";
|
||||||
|
const kFontNameFmtSansSerif = "font.name.sans-serif.%LANG%";
|
||||||
|
const kFontNameListFmtSerif = "font.name-list.serif.%LANG%";
|
||||||
|
const kFontNameListFmtSansSerif = "font.name-list.sans-serif.%LANG%";
|
||||||
|
const kFontSizeFmtVariable = "font.size.variable.%LANG%";
|
||||||
|
|
||||||
|
var prefs = [{ format : aIsSerif ? kFontNameFmtSerif : kFontNameFmtSansSerif,
|
||||||
|
type : "fontname",
|
||||||
|
element : "defaultFont",
|
||||||
|
fonttype : aIsSerif ? "serif" : "sans-serif" },
|
||||||
|
{ format : aIsSerif ? kFontNameListFmtSerif : kFontNameListFmtSansSerif,
|
||||||
|
type : "unichar",
|
||||||
|
element : null,
|
||||||
|
fonttype : aIsSerif ? "serif" : "sans-serif" },
|
||||||
|
{ format : kFontSizeFmtVariable,
|
||||||
|
type : "int",
|
||||||
|
element : "defaultFontSize",
|
||||||
|
fonttype : null }];
|
||||||
|
var preferences = document.getElementById("contentPreferences");
|
||||||
|
for (var i = 0; i < prefs.length; ++i) {
|
||||||
|
var preference = document.getElementById(prefs[i].format.replace(/%LANG%/, aLanguageGroup));
|
||||||
|
if (!preference) {
|
||||||
|
preference = document.createElement("preference");
|
||||||
|
var name = prefs[i].format.replace(/%LANG%/, aLanguageGroup);
|
||||||
|
preference.id = name;
|
||||||
|
preference.setAttribute("name", name);
|
||||||
|
preference.setAttribute("type", prefs[i].type);
|
||||||
|
preferences.appendChild(preference);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!prefs[i].element)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var element = document.getElementById(prefs[i].element);
|
||||||
|
if (element) {
|
||||||
|
element.setAttribute("preference", preference.id);
|
||||||
|
|
||||||
|
if (prefs[i].fonttype)
|
||||||
|
FontBuilder.buildFontList(aLanguageGroup, prefs[i].fonttype, element);
|
||||||
|
|
||||||
|
preference.setElementValue(element);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the type of the current default font for the language denoted by
|
||||||
|
* aLanguageGroup.
|
||||||
|
*/
|
||||||
|
_readDefaultFontTypeForLanguage: function (aLanguageGroup)
|
||||||
|
{
|
||||||
|
const kDefaultFontType = "font.default.%LANG%";
|
||||||
|
var defaultFontTypePref = kDefaultFontType.replace(/%LANG%/, aLanguageGroup);
|
||||||
|
var preference = document.getElementById(defaultFontTypePref);
|
||||||
|
if (!preference) {
|
||||||
|
preference = document.createElement("preference");
|
||||||
|
preference.id = defaultFontTypePref;
|
||||||
|
preference.setAttribute("name", defaultFontTypePref);
|
||||||
|
preference.setAttribute("type", "string");
|
||||||
|
preference.setAttribute("onchange", "gContentPane._rebuildFonts();");
|
||||||
|
document.getElementById("contentPreferences").appendChild(preference);
|
||||||
|
}
|
||||||
|
return preference.value;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays the fonts dialog, where web page font names and sizes can be
|
||||||
|
* configured.
|
||||||
|
*/
|
||||||
|
configureFonts: function ()
|
||||||
|
{
|
||||||
|
openDialog("chrome://browser/content/preferences/fonts.xul",
|
||||||
|
"Browser:FontPreferences", null);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays the colors dialog, where default web page/link/etc. colors can be
|
||||||
|
* configured.
|
||||||
|
*/
|
||||||
|
configureColors: function ()
|
||||||
|
{
|
||||||
|
openDialog("chrome://browser/content/preferences/colors.xul",
|
||||||
|
"Browser:ColorPreferences", null);
|
||||||
|
},
|
||||||
|
|
||||||
|
// LANGUAGES
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows a dialog in which the preferred language for web content may be set.
|
||||||
|
*/
|
||||||
|
showLanguages: function ()
|
||||||
|
{
|
||||||
|
openDialog("chrome://browser/content/preferences/languages.xul",
|
||||||
|
"Browser:LanguagePreferences", null);
|
||||||
|
}
|
||||||
|
};
|
|
@ -0,0 +1,165 @@
|
||||||
|
<!-- 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/. -->
|
||||||
|
|
||||||
|
<preferences id="contentPreferences">
|
||||||
|
|
||||||
|
<!-- Popups, images, and JavaScript -->
|
||||||
|
<preference id="dom.disable_open_during_load"
|
||||||
|
name="dom.disable_open_during_load"
|
||||||
|
type="bool"/>
|
||||||
|
<preference id="permissions.default.image"
|
||||||
|
name="permissions.default.image"
|
||||||
|
type="int"/>
|
||||||
|
<preference id="javascript.enabled"
|
||||||
|
name="javascript.enabled"
|
||||||
|
type="bool"/>
|
||||||
|
<preference id="pref.advanced.images.disable_button.view_image"
|
||||||
|
name="pref.advanced.images.disable_button.view_image"
|
||||||
|
type="bool"/>
|
||||||
|
<preference id="pref.advanced.javascript.disable_button.advanced"
|
||||||
|
name="pref.advanced.javascript.disable_button.advanced"
|
||||||
|
type="bool"/>
|
||||||
|
|
||||||
|
<!-- Fonts -->
|
||||||
|
<preference id="font.language.group"
|
||||||
|
name="font.language.group"
|
||||||
|
type="wstring"
|
||||||
|
onchange="gContentPane._rebuildFonts();"/>
|
||||||
|
</preferences>
|
||||||
|
|
||||||
|
<script type="application/javascript"
|
||||||
|
src="chrome://mozapps/content/preferences/fontbuilder.js"/>
|
||||||
|
<script type="application/javascript"
|
||||||
|
src="chrome://browser/content/preferences/in-content/content.js"/>
|
||||||
|
|
||||||
|
<hbox class="heading" data-category="paneContent" hidden="true">
|
||||||
|
<image class="preference-icon" type="content"/>
|
||||||
|
<html:h1>&paneContent.title;</html:h1>
|
||||||
|
</hbox>
|
||||||
|
|
||||||
|
<groupbox id="miscGroup" data-category="paneContent" hidden="true">
|
||||||
|
<grid id="contentGrid">
|
||||||
|
<columns>
|
||||||
|
<column flex="1"/>
|
||||||
|
<column/>
|
||||||
|
</columns>
|
||||||
|
<rows id="contentRows-1">
|
||||||
|
<row id="popupPolicyRow">
|
||||||
|
<vbox align="start">
|
||||||
|
<checkbox id="popupPolicy" preference="dom.disable_open_during_load"
|
||||||
|
label="&blockPopups.label;" accesskey="&blockPopups.accesskey;"
|
||||||
|
onsyncfrompreference="return gContentPane.updateButtons('popupPolicyButton',
|
||||||
|
'dom.disable_open_during_load');"/>
|
||||||
|
</vbox>
|
||||||
|
<button id="popupPolicyButton" label="&popupExceptions.label;"
|
||||||
|
oncommand="gContentPane.showPopupExceptions();"
|
||||||
|
accesskey="&popupExceptions.accesskey;"/>
|
||||||
|
</row>
|
||||||
|
<row id="enableImagesRow">
|
||||||
|
<vbox align="start">
|
||||||
|
<checkbox id="loadImages"
|
||||||
|
label="&loadImages.label;"
|
||||||
|
accesskey="&loadImages.accesskey;"
|
||||||
|
preference="permissions.default.image"
|
||||||
|
onsyncfrompreference="return gContentPane.readLoadImages();"
|
||||||
|
onsynctopreference="return gContentPane.writeLoadImages();"/>
|
||||||
|
</vbox>
|
||||||
|
<vbox>
|
||||||
|
<button label="&exceptions.label;"
|
||||||
|
accesskey="&exceptions.accesskey;"
|
||||||
|
oncommand="gContentPane.showImageExceptions();"
|
||||||
|
preference="pref.advanced.images.disable_button.view_image"/>
|
||||||
|
</vbox>
|
||||||
|
</row>
|
||||||
|
<row id="enableJavaScriptRow">
|
||||||
|
<vbox align="start">
|
||||||
|
<checkbox id="enableJavaScript" preference="javascript.enabled"
|
||||||
|
label="&enableJavaScript.label;" accesskey="&enableJavaScript.accesskey;"
|
||||||
|
onsyncfrompreference="return gContentPane.updateButtons('advancedJSButton',
|
||||||
|
'javascript.enabled');"/>
|
||||||
|
</vbox>
|
||||||
|
<vbox>
|
||||||
|
<button id="advancedJSButton" label="&advancedJS.label;"
|
||||||
|
accesskey="&advancedJS.accesskey;"
|
||||||
|
oncommand="gContentPane.showAdvancedJS();"
|
||||||
|
preference="pref.advanced.javascript.disable_button.advanced"/>
|
||||||
|
</vbox>
|
||||||
|
</row>
|
||||||
|
</rows>
|
||||||
|
</grid>
|
||||||
|
</groupbox>
|
||||||
|
|
||||||
|
<!-- Fonts and Colors -->
|
||||||
|
<groupbox id="fontsGroup" data-category="paneContent" hidden="true">
|
||||||
|
<caption label="&fontsAndColors.label;"/>
|
||||||
|
|
||||||
|
<grid id="fontsGrid">
|
||||||
|
<columns>
|
||||||
|
<column flex="1"/>
|
||||||
|
<column/>
|
||||||
|
</columns>
|
||||||
|
<rows id="fontsRows">
|
||||||
|
<row id="fontRow">
|
||||||
|
<hbox align="center">
|
||||||
|
<label control="defaultFont" accesskey="&defaultFont.accesskey;">&defaultFont.label;</label>
|
||||||
|
<menulist id="defaultFont" />
|
||||||
|
<label control="defaultFontSize" accesskey="&defaultSize.accesskey;">&defaultSize.label;</label>
|
||||||
|
<menulist id="defaultFontSize">
|
||||||
|
<menupopup>
|
||||||
|
<menuitem value="9" label="9"/>
|
||||||
|
<menuitem value="10" label="10"/>
|
||||||
|
<menuitem value="11" label="11"/>
|
||||||
|
<menuitem value="12" label="12"/>
|
||||||
|
<menuitem value="13" label="13"/>
|
||||||
|
<menuitem value="14" label="14"/>
|
||||||
|
<menuitem value="15" label="15"/>
|
||||||
|
<menuitem value="16" label="16"/>
|
||||||
|
<menuitem value="17" label="17"/>
|
||||||
|
<menuitem value="18" label="18"/>
|
||||||
|
<menuitem value="20" label="20"/>
|
||||||
|
<menuitem value="22" label="22"/>
|
||||||
|
<menuitem value="24" label="24"/>
|
||||||
|
<menuitem value="26" label="26"/>
|
||||||
|
<menuitem value="28" label="28"/>
|
||||||
|
<menuitem value="30" label="30"/>
|
||||||
|
<menuitem value="32" label="32"/>
|
||||||
|
<menuitem value="34" label="34"/>
|
||||||
|
<menuitem value="36" label="36"/>
|
||||||
|
<menuitem value="40" label="40"/>
|
||||||
|
<menuitem value="44" label="44"/>
|
||||||
|
<menuitem value="48" label="48"/>
|
||||||
|
<menuitem value="56" label="56"/>
|
||||||
|
<menuitem value="64" label="64"/>
|
||||||
|
<menuitem value="72" label="72"/>
|
||||||
|
</menupopup>
|
||||||
|
</menulist>
|
||||||
|
</hbox>
|
||||||
|
<button id="advancedFonts" icon="select-font"
|
||||||
|
label="&advancedFonts.label;"
|
||||||
|
accesskey="&advancedFonts.accesskey;"
|
||||||
|
oncommand="gContentPane.configureFonts();"/>
|
||||||
|
</row>
|
||||||
|
<row id="colorsRow">
|
||||||
|
<hbox/>
|
||||||
|
<button id="colors" icon="select-color"
|
||||||
|
label="&colors.label;"
|
||||||
|
accesskey="&colors.accesskey;"
|
||||||
|
oncommand="gContentPane.configureColors();"/>
|
||||||
|
</row>
|
||||||
|
</rows>
|
||||||
|
</grid>
|
||||||
|
</groupbox>
|
||||||
|
|
||||||
|
<!-- Languages -->
|
||||||
|
<groupbox id="languagesGroup" data-category="paneContent" hidden="true">
|
||||||
|
<caption label="&languages.label;"/>
|
||||||
|
|
||||||
|
<hbox id="languagesBox" align="center">
|
||||||
|
<description flex="1" control="chooseLanguage">&chooseLanguage.label;</description>
|
||||||
|
<button id="chooseLanguage"
|
||||||
|
label="&chooseButton.label;"
|
||||||
|
accesskey="&chooseButton.accesskey;"
|
||||||
|
oncommand="gContentPane.showLanguages();"/>
|
||||||
|
</hbox>
|
||||||
|
</groupbox>
|
|
@ -11,4 +11,6 @@ browser.jar:
|
||||||
* content/browser/preferences/in-content/advanced.xul
|
* content/browser/preferences/in-content/advanced.xul
|
||||||
* content/browser/preferences/in-content/advanced.js
|
* content/browser/preferences/in-content/advanced.js
|
||||||
* content/browser/preferences/in-content/applications.xul
|
* content/browser/preferences/in-content/applications.xul
|
||||||
* content/browser/preferences/in-content/applications.js
|
* content/browser/preferences/in-content/applications.js
|
||||||
|
content/browser/preferences/in-content/content.xul
|
||||||
|
content/browser/preferences/in-content/content.js
|
||||||
|
|
|
@ -24,6 +24,7 @@ function init_all() {
|
||||||
gPrivacyPane.init();
|
gPrivacyPane.init();
|
||||||
gAdvancedPane.init();
|
gAdvancedPane.init();
|
||||||
gApplicationsPane.init();
|
gApplicationsPane.init();
|
||||||
|
gContentPane.init();
|
||||||
var initFinished = document.createEvent("Event");
|
var initFinished = document.createEvent("Event");
|
||||||
initFinished.initEvent("Initialized", true, true);
|
initFinished.initEvent("Initialized", true, true);
|
||||||
document.dispatchEvent(initFinished);
|
document.dispatchEvent(initFinished);
|
||||||
|
|
|
@ -95,6 +95,7 @@
|
||||||
#include privacy.xul
|
#include privacy.xul
|
||||||
#include advanced.xul
|
#include advanced.xul
|
||||||
#include applications.xul
|
#include applications.xul
|
||||||
|
#include content.xul
|
||||||
</prefpane>
|
</prefpane>
|
||||||
</hbox>
|
</hbox>
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче