Finish up policy work for now & fix crash on page load.

This commit is contained in:
ben%netscape.com 2002-04-05 01:17:39 +00:00
Родитель d0385fe4ca
Коммит c6f95f45bf
6 изменённых файлов: 58 добавлений и 12 удалений

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

@ -36,6 +36,8 @@ Contributor(s): ______________________________________. -->
%buildDTD;
<!ENTITY % navigatorDTD SYSTEM "chrome://browser/locale/navigator.dtd" >
%navigatorDTD;
<!ENTITY % policyDTD SYSTEM "chrome://browser/locale/policy/policy.dtd" >
%policyDTD;
]>
<window id="main-window"
@ -387,18 +389,22 @@ Contributor(s): ______________________________________. -->
</statusbarpanel>
<statusbarpanel class="statusbarpanel-iconic" id="offline-status"/>
<statusbarpanel class="statusbarpanel-iconic" id="security-button" onclick="displayPageInfo()"/>
<!--
<statusbarpanel>
<button id="policy-menu" type="menu" label="Policy"
oncommand="policyMenuAction(event);">
<menupopup onpopupshowing="policyMenuShowing(event);"
popupanchor="topright" popupalign="topleft">
<menuitem id="policyMenu-noregions" label="Add to New Region..."/>
popupanchor="topleft" popupalign="topleft">
<label>&addCurrentPageTo.label;</label>
<menuitem id="policyMenu-newregion" label="&addToNewRegion.label;"/>
<menuseparator id="customPolicySeparator"/>
<menuitem id="policyMenu-cookies" label="Can set cookies"/>
<menuitem id="policyMenu-scripts" label="Can execute scripts"/>
<label>&currentPageDetails.label;</label>
<menuitem id="policyMenu-cookies" label="&currentPageCanSetCookies.label;"/>
<menuitem id="policyMenu-scripts" label="&currentPageCanExecuteJavaScript.label;"/>
</menupopup>
</button>
</statusbarpanel>
-->
</statusbar>
</window>

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

@ -42,6 +42,6 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = bookmarks build policy
DIRS = bookmarks policy
include $(topsrcdir)/config/rules.mk

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

@ -26,7 +26,7 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = public src resources
DIRS = resources
include $(topsrcdir)/config/rules.mk

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

@ -51,7 +51,26 @@ function getPolicyBranch()
function policyMenuAction(aEvent)
{
var branch = getPolicyBranch();
var prePath = gBrowser.mCurrentBrowser.currentURI.prePath;
if (aEvent.target.id == "policyMenu-newregion") {
// XXXben replace with full selection UI.
var name = prompt("(PLACEHOLDER) Enter a new region name: ", "New Region");
// XXXben normalize, strip whitespace, etc.
// XXXben user defined from selection UI
branch.setCharPref(name + ".sites", prePath);
branch.setCharPref(name + ".policyName", name);
branch.setCharPref(name + ".Window.open", "noAccess");
}
else if (aEvent.target.hasAttribute("region")) {
var region = aEvent.target.getAttribute("region");
var sites = branch.getCharPref(region + ".sites");
sites += " " + prePath;
branch.setCharPref(region + ".sites", sites);
}
}
function policyMenuShowing(aEvent)
@ -61,14 +80,24 @@ function policyMenuShowing(aEvent)
var regions = branch.getCharPref("policynames");
regions = regions.split(", ");
var noRegionsItem = document.getElementById("policyMenu-noregions");
var prePath = gBrowser.mCurrentBrowser.currentURI.prePath;
var noRegionsItem = document.getElementById("policyMenu-newregion");
for (var i = 0; i < regions.length; ++i) {
var menuitem = document.createElement("menuitem");
var label = branch.getCharPref(regions[i] + ".policyName");
menuitem.setAttribute("label", label);
menuitem.setAttribute("id", "policyMenuRegion-" + regions[i]);
aEvent.target.insertBefore(menuitem, noRegionsItem);
var itemElement = document.getElementById("policyMenuRegion-" + regions[i]);
if (!itemElement) {
var menuitem = document.createElement("menuitem");
var label = branch.getCharPref(regions[i] + ".policyName");
menuitem.setAttribute("label", label);
menuitem.setAttribute("id", "policyMenuRegion-" + regions[i]);
menuitem.setAttribute("region", regions[i]);
var sites = branch.getCharPref(regions[i] + ".sites");
if (sites.indexOf(prePath) != -1)
menuitem.setAttribute("disaled", "true");
aEvent.target.insertBefore(menuitem, noRegionsItem);
}
}
}

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

@ -19,4 +19,7 @@
browser.jar:
content/browser/policy/policy.js (content/policy.js)
en-US.jar:
locale/en-US/browser/policy/policy.dtd (locale/policy.dtd)

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

@ -0,0 +1,8 @@
<!ENTITY addCurrentPageTo.label "Add Current Site to:">
<!ENTITY addToNewRegion.label "New Region...">
<!ENTITY currentPageDetails.label "Current Site can:">
<!ENTITY currentPageCanSetCookies.label "Set Cookies">
<!ENTITY currentPageCanExecuteJavaScript.label "Execute Scripts">