diff --git a/browser/base/resources/content/browser.xul b/browser/base/resources/content/browser.xul index 32a24fce5413..6b819cef9dae 100644 --- a/browser/base/resources/content/browser.xul +++ b/browser/base/resources/content/browser.xul @@ -36,6 +36,8 @@ Contributor(s): ______________________________________. --> %buildDTD; %navigatorDTD; + +%policyDTD; ]> + diff --git a/browser/components/Makefile.in b/browser/components/Makefile.in index 9cad80b0c5a7..a42d540fb7d0 100644 --- a/browser/components/Makefile.in +++ b/browser/components/Makefile.in @@ -42,6 +42,6 @@ VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk -DIRS = bookmarks build policy +DIRS = bookmarks policy include $(topsrcdir)/config/rules.mk diff --git a/browser/components/bookmarks/Makefile.in b/browser/components/bookmarks/Makefile.in index 136dc7a99268..aff55ca11aa5 100644 --- a/browser/components/bookmarks/Makefile.in +++ b/browser/components/bookmarks/Makefile.in @@ -26,7 +26,7 @@ VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk -DIRS = public src resources +DIRS = resources include $(topsrcdir)/config/rules.mk diff --git a/browser/components/policy/resources/content/policy.js b/browser/components/policy/resources/content/policy.js index e2c806925a9b..bbe96aae4c17 100644 --- a/browser/components/policy/resources/content/policy.js +++ b/browser/components/policy/resources/content/policy.js @@ -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); + } } } diff --git a/browser/components/policy/resources/jar.mn b/browser/components/policy/resources/jar.mn index b81f5f7a7141..8f5526220cfa 100644 --- a/browser/components/policy/resources/jar.mn +++ b/browser/components/policy/resources/jar.mn @@ -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) diff --git a/browser/components/policy/resources/locale/policy.dtd b/browser/components/policy/resources/locale/policy.dtd new file mode 100644 index 000000000000..79e2cf3e4fff --- /dev/null +++ b/browser/components/policy/resources/locale/policy.dtd @@ -0,0 +1,8 @@ + + + + + + + +