Add UI for browser.block.target_new_window (used to be named

browser.target_new_blocked).  Bug 78037, patch by  Jonas Jorgensen
<jonasj@jonasj.dk>, r=bzbarsky, sr=alecf, a=asa
This commit is contained in:
bzbarsky%mit.edu 2002-02-25 23:38:02 +00:00
parent 9964703a40
commit 0ca37a0405
5 changed files with 40 additions and 10 deletions

View File

@ -2526,7 +2526,7 @@ nsDocShell::Create()
// so read it in once here and be done with it...
mPrefs->GetBoolPref("network.protocols.useSystemDefaults",
&mUseExternalProtocolHandler);
mPrefs->GetBoolPref("browser.target_new_blocked", &mDisallowPopupWindows);
mPrefs->GetBoolPref("browser.block.target_new_window", &mDisallowPopupWindows);
mPrefs->GetBoolPref("browser.frames.enabled", &mAllowSubframes);
// Check pref to see if we should prevent frameset spoofing

View File

@ -158,7 +158,7 @@ pref("browser.PICS.reenable_for_this_session", false);
pref("browser.PICS.service.http___home_netscape_com_default_rating.service_enabled", true);
pref("browser.PICS.service.http___home_netscape_com_default_rating.s", 0);
pref("browser.target_new_blocked", false);
pref("browser.block.target_new_window", false);
// loading and rendering of framesets and iframes
pref("browser.frames.enabled", true);

View File

@ -19,6 +19,7 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Jonas Jørgensen <jonasj@jonasj.dk>
*
* 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
@ -43,6 +44,10 @@ function doAllowWindowOpen(){
data.scriptData["allowWindowOpenChanged"].value = !data.scriptData["allowWindowOpenChanged"].value;
}
function doAllowTargetNew(){
data.scriptData["allowTargetNewChanged"].value = !data.scriptData["allowTargetNewChanged"].value;
}
function doWindowMoveResize(){
data.scriptData["allowWindowMoveResizeChanged"].value = !data.scriptData["allowWindowMoveResizeChanged"].value;
}
@ -115,10 +120,10 @@ function Startup(){
//If scriptData does not exist, then it is the first time the panel was shown and we default to false
if (!("scriptData" in data)){
var changedList = ["allowWindowOpenChanged", "allowWindowMoveResizeChanged",
"allowWindowStatusChangeChanged", "allowWindowFlipChanged",
"allowDocumentCookieSetChanged", "allowDocumentCookieGetChanged",
"allowImageSrcChangeChanged"];
var changedList = ["allowWindowOpenChanged", "allowTargetNewChanged",
"allowWindowMoveResizeChanged", "allowWindowStatusChangeChanged",
"allowWindowFlipChanged", "allowDocumentCookieSetChanged",
"allowDocumentCookieGetChanged", "allowImageSrcChangeChanged"];
data.scriptData = [];
for(var run = 0; run < changedList.length; run++ ){
data.scriptData[ changedList[run] ] = [];
@ -133,6 +138,14 @@ function Startup(){
document.getElementById("allowWindowOpen").checked = true;
}
try{
document.getElementById("allowTargetNew").checked =
!pref.GetBoolPref("browser.block.target_new_window");
} catch (e){
//We will only get an error if the preference doesn't exist, when that happens we default to true
document.getElementById("allowTargetNew").checked = true;
}
//If one of the security capability prefs is set, then the checkbox becomes unchecked
document.getElementById("allowWindowMoveResize").checked =
getPrefValueForCheckbox("capability.policy.default.Window.resizeTo") &&
@ -167,6 +180,8 @@ function Startup(){
document.getElementById("allowWindowOpen").checked = data["allowWindowOpen"].checked;
document.getElementById("allowTargetNew").checked = data["allowTargetNew"].checked;
document.getElementById("allowWindowMoveResize").checked = data["allowWindowMoveResize"].checked;
document.getElementById("allowWindowFlip").checked = data["allowWindowFlip"].checked;
@ -226,6 +241,11 @@ function doOnOk(){
!getCheckboxValue('allowWindowOpen'));
}
if (data.scriptData["allowTargetNewChanged"].value){
parent.hPrefWindow.setPref("bool", "browser.block.target_new_window",
!getCheckboxValue('allowTargetNew'));
}
if (data.scriptData["allowWindowMoveResizeChanged"].value){
var allowWindowMoveResize = getCheckboxValue("allowWindowMoveResize");

View File

@ -37,7 +37,13 @@
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://communicator/locale/pref/pref-scripts.dtd" >
<!DOCTYPE window [
<!ENTITY % brandDTD SYSTEM "chrome://global/locale/brand.dtd" >
%brandDTD;
<!ENTITY % prefScriptsDTD SYSTEM "chrome://communicator/locale/pref/pref-scripts.dtd" >
%prefScriptsDTD;
]>
<page id="scriptsAndWindowPanel" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="parent.initPanel('chrome://communicator/content/pref/pref-scripts.xul');"
headertitle="&lHeader;">
@ -45,7 +51,7 @@
<script type="application/x-javascript">
<![CDATA[
var panel = "chrome://communicator/content/pref/pref-scripts.xul";
var _elementIDs = ["javascriptAllowNavigator", "allowWindowOpen", "allowWindowMoveResize", "allowWindowFlip", "allowWindowStatusChange", "allowImageSrcChange", "allowDocumentCookieSet", "allowDocumentCookieGet"];
var _elementIDs = ["javascriptAllowNavigator", "allowWindowOpen", "allowTargetNew", "allowWindowMoveResize", "allowWindowFlip", "allowWindowStatusChange", "allowImageSrcChange", "allowDocumentCookieSet", "allowDocumentCookieGet"];
]]>
</script>
@ -64,6 +70,9 @@
<treerow>
<checkbox id="allowWindowOpen" label="&allowWindowOpen.label;" oncommand="doAllowWindowOpen();"/>
</treerow>
<treerow>
<checkbox id="allowTargetNew" label="&allowTargetNew.label;" oncommand="doAllowTargetNew();"/>
</treerow>
<treerow>
<checkbox id="allowWindowMoveResize" label="&allowWindowMoveResize.label;" oncommand="doWindowMoveResize();"/>
</treerow>

View File

@ -3,13 +3,14 @@
<!--LOCALIZATION NOTE : FILE The 'Scripts & Windows' preferences dialog -->
<!ENTITY lHeader "Scripts &amp; Windows">
<!--LOCALIZATION NOTE (enbableJsCheck.label): 'JavaScript' should never be translated -->
<!--LOCALIZATION NOTE (enableJsCheck.label): 'JavaScript' should never be translated -->
<!ENTITY navigator.label "Navigator">
<!ENTITY navigator.accesskey "r">
<!ENTITY enableJavaScript.label "Enable JavaScript for:">
<!ENTITY allowScripts.label "Allow scripts to:">
<!ENTITY allowScripts.label "Allow webpages to:">
<!ENTITY allowWindowOpen.label "Open unrequested windows">
<!ENTITY allowTargetNew.label "Open a link in a new window (requires restarting &brandShortName;)">
<!ENTITY allowWindowMoveResize.label "Move or resize existing windows">
<!ENTITY allowWindowFlip.label "Raise or lower windows">
<!ENTITY allowWindowStatusChange.label "Change status bar text">