2006-07-27 14:56:33 +00:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
|
|
|
|
<!--
|
|
|
|
The contents of this file are subject to the Netscape 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/NPL/
|
|
|
|
|
|
|
|
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 Netscape are
|
|
|
|
Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
|
|
|
Rights Reserved.
|
|
|
|
|
|
|
|
Contributor(s):
|
|
|
|
-->
|
|
|
|
|
2006-07-27 14:57:09 +00:00
|
|
|
<!DOCTYPE overlay SYSTEM "chrome://cookie/locale/cookieNavigatorOverlay.dtd">
|
2006-07-27 14:56:33 +00:00
|
|
|
|
|
|
|
<overlay id="cookieNavigatorOverlay"
|
|
|
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
|
|
|
|
|
|
|
<script type="application/x-javascript" src="chrome://cookie/content/cookieOverlay.js"/>
|
|
|
|
<script type="application/x-javascript">
|
|
|
|
<![CDATA[
|
|
|
|
/******* THE FOLLOWING IS FOR THE TASKMENU OVERLAY *******/
|
|
|
|
|
2006-07-27 14:56:43 +00:00
|
|
|
// both are necessary. popupmanager is just a special case
|
|
|
|
// of permissionmanager but does extra work on add/remove
|
2006-07-27 14:57:10 +00:00
|
|
|
const nsIPermissionManager = Components.interfaces.nsIPermissionManager;
|
2006-07-27 14:56:33 +00:00
|
|
|
var permissionmanager;
|
2006-07-27 14:56:43 +00:00
|
|
|
var popupmanager;
|
2006-07-27 14:56:33 +00:00
|
|
|
|
|
|
|
// Remove the image entries from the task menu
|
|
|
|
function HideImage() {
|
2006-07-27 14:57:51 +00:00
|
|
|
document.getElementById("image").hidden = true;
|
2006-07-27 14:56:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// for some unexplainable reason, CheckForImage() keeps getting called repeatedly
|
|
|
|
// as we mouse over the task menu. IMO, that shouldn't be happening. To avoid
|
|
|
|
// taking a performance hit due to this, we will set the following flag to avoid
|
|
|
|
// reexecuting the routine
|
|
|
|
var alreadyCheckedForImage = false;
|
|
|
|
|
|
|
|
// determine which items we need to hide or disable from the task menu
|
|
|
|
function CheckForVisibility()
|
|
|
|
{
|
2006-07-27 14:57:10 +00:00
|
|
|
var uri = getBrowser().currentURI;
|
2006-07-27 14:56:33 +00:00
|
|
|
|
2006-07-27 14:56:43 +00:00
|
|
|
// obtain access to permissionmanager and popupmanager
|
|
|
|
// (popup manager is a wrapper around permission that does extra work)
|
2006-07-27 14:56:33 +00:00
|
|
|
permissionmanager =
|
|
|
|
Components.classes["@mozilla.org/permissionmanager;1"]
|
|
|
|
.getService(Components.interfaces.nsIPermissionManager);
|
2006-07-27 14:56:43 +00:00
|
|
|
popupmanager =
|
|
|
|
Components.classes["@mozilla.org/PopupWindowManager;1"]
|
|
|
|
.getService(Components.interfaces.nsIPopupWindowManager);
|
2006-07-27 14:56:33 +00:00
|
|
|
if (!("_content" in window) || !window._content) {
|
|
|
|
// this occurs if doing tasks->privacy->cookie->block from java console
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// determine current state (blocked or unblocked) and hide appropriate menu item
|
2006-07-27 14:57:10 +00:00
|
|
|
var blocked = nsIPermissionManager.UNKNOWN_ACTION;
|
2006-07-27 14:57:07 +00:00
|
|
|
|
2006-07-27 14:57:52 +00:00
|
|
|
blocked = permissionmanager.testPermission(uri, "cookie");
|
2006-07-27 14:57:10 +00:00
|
|
|
enableElement("AllowCookies", blocked != nsIPermissionManager.ALLOW_ACTION);
|
|
|
|
enableElement("BlockCookies", blocked != nsIPermissionManager.DENY_ACTION);
|
2006-07-27 14:56:33 +00:00
|
|
|
|
2006-07-27 14:57:52 +00:00
|
|
|
blocked = permissionmanager.testPermission(uri, "image");
|
2006-07-27 14:57:10 +00:00
|
|
|
enableElement("AllowImages", blocked != nsIPermissionManager.ALLOW_ACTION);
|
|
|
|
enableElement("BlockImages", blocked != nsIPermissionManager.DENY_ACTION);
|
2006-07-27 14:57:07 +00:00
|
|
|
|
2006-07-27 14:56:45 +00:00
|
|
|
SetPopupMenuEnabledState();
|
2006-07-27 14:56:43 +00:00
|
|
|
|
|
|
|
var pref;
|
|
|
|
pref = Components.classes['@mozilla.org/preferences-service;1'];
|
|
|
|
pref = pref.getService();
|
|
|
|
pref = pref.QueryInterface(Components.interfaces.nsIPrefBranch);
|
|
|
|
|
2006-07-27 14:56:33 +00:00
|
|
|
// determine if image manager should be in the UI
|
|
|
|
if (alreadyCheckedForImage) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
alreadyCheckedForImage = true;
|
|
|
|
// remove image functions (unless overruled by the "imageblocker.enabled" pref)
|
|
|
|
try {
|
|
|
|
if (!pref.getBoolPref("imageblocker.enabled")) {
|
|
|
|
HideImage();
|
|
|
|
}
|
|
|
|
} catch(e) {
|
|
|
|
HideImage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-27 14:56:45 +00:00
|
|
|
function SetPopupMenuEnabledState() {
|
2006-07-27 14:57:10 +00:00
|
|
|
var blocked = nsIPermissionManager.UNKNOWN_ACTION;
|
2006-07-27 14:57:07 +00:00
|
|
|
var policy = pref.getBoolPref("dom.disable_open_during_load");
|
|
|
|
|
2006-07-27 14:57:52 +00:00
|
|
|
blocked = permissionmanager.testPermission(getBrowser().currentURI, "popup");
|
2006-07-27 14:57:50 +00:00
|
|
|
|
|
|
|
document.getElementById("AboutPopups").hidden = policy;
|
|
|
|
document.getElementById("ManagePopups").hidden = !policy;
|
|
|
|
|
|
|
|
if (policy) {
|
|
|
|
enableElement("AllowPopups", blocked != nsIPermissionManager.ALLOW_ACTION);
|
|
|
|
return;
|
|
|
|
}
|
2006-07-27 14:57:07 +00:00
|
|
|
|
2006-07-27 14:57:50 +00:00
|
|
|
enableElement("AllowPopups", false);
|
2006-07-27 14:56:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function enableElement(elementID, enable) {
|
|
|
|
var element = document.getElementById(elementID);
|
|
|
|
if (enable)
|
|
|
|
element.removeAttribute("disabled");
|
|
|
|
else
|
|
|
|
element.setAttribute("disabled", "true");
|
|
|
|
}
|
|
|
|
|
2006-07-27 14:56:33 +00:00
|
|
|
// perform a Cookie or Image action
|
|
|
|
function CookieImageAction(action) {
|
|
|
|
|
|
|
|
if (!("_content" in window) || !window._content) {
|
|
|
|
// this occurs if doing tasks->privacy->cookie->block from java console
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var element;
|
2006-07-27 14:57:10 +00:00
|
|
|
var uri = getBrowser().currentURI;
|
2006-07-27 14:56:33 +00:00
|
|
|
switch (action) {
|
|
|
|
case "cookieAllow":
|
2006-07-27 14:57:52 +00:00
|
|
|
permissionmanager.add(uri, "cookie", nsIPermissionManager.ALLOW_ACTION);
|
2006-07-27 14:56:33 +00:00
|
|
|
element = document.getElementById("AllowCookies");
|
|
|
|
alert(element.getAttribute("msg"));
|
|
|
|
break;
|
|
|
|
case "cookieBlock":
|
2006-07-27 14:57:52 +00:00
|
|
|
permissionmanager.add(uri, "cookie", nsIPermissionManager.DENY_ACTION);
|
2006-07-27 14:56:33 +00:00
|
|
|
element = document.getElementById("BlockCookies");
|
|
|
|
alert(element.getAttribute("msg"));
|
|
|
|
break;
|
|
|
|
case "imageAllow":
|
2006-07-27 14:57:52 +00:00
|
|
|
permissionmanager.add(uri, "image", nsIPermissionManager.ALLOW_ACTION);
|
2006-07-27 14:56:33 +00:00
|
|
|
element = document.getElementById("AllowImages");
|
|
|
|
alert(element.getAttribute("msg"));
|
|
|
|
break;
|
|
|
|
case "imageBlock":
|
2006-07-27 14:57:52 +00:00
|
|
|
permissionmanager.add(uri, "image", nsIPermissionManager.DENY_ACTION);
|
2006-07-27 14:56:33 +00:00
|
|
|
element = document.getElementById("BlockImages");
|
|
|
|
alert(element.getAttribute("msg"));
|
|
|
|
break;
|
2006-07-27 14:57:07 +00:00
|
|
|
default:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-27 14:57:50 +00:00
|
|
|
function PopupAction() {
|
|
|
|
var hostPort = getBrowser().currentURI.hostPort;
|
|
|
|
window.openDialog("chrome://communicator/content/popupManager.xul", "",
|
|
|
|
"chrome,resizable=yes,modal=yes",
|
|
|
|
hostPort,
|
|
|
|
false);
|
|
|
|
}
|
2006-07-27 14:57:07 +00:00
|
|
|
|
2006-07-27 14:57:50 +00:00
|
|
|
function OpenAboutPopups() {
|
|
|
|
window.openDialog("chrome://communicator/content/aboutPopups.xul", "",
|
|
|
|
"chrome,centerscreen,resizable=yes",
|
|
|
|
false);
|
2006-07-27 14:57:07 +00:00
|
|
|
}
|
|
|
|
|
2006-07-27 14:57:50 +00:00
|
|
|
function OpenManagePopups() {
|
2006-07-27 14:57:07 +00:00
|
|
|
window.openDialog("chrome://communicator/content/popupManager.xul", "",
|
2006-07-27 14:57:50 +00:00
|
|
|
"chrome,resizable=yes",
|
2006-07-27 14:57:07 +00:00
|
|
|
"",
|
|
|
|
false);
|
|
|
|
}
|
2006-07-27 14:56:33 +00:00
|
|
|
|
|
|
|
]]>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<!-- tasksOverlay menu items -->
|
|
|
|
<menupopup id="taskPopup" onpopupshowing="CheckForVisibility()">
|
|
|
|
<menu insertbefore="navBeginGlobalItems"
|
|
|
|
label="&cookieCookieManager.label;"
|
|
|
|
accesskey="&cookieCookieManager.accesskey;">
|
|
|
|
<menupopup>
|
|
|
|
<menuitem id="BlockCookies" label="&cookieBlockCookiesCmd.label;"
|
|
|
|
accesskey="&cookieBlockCookiesCmd.accesskey;"
|
|
|
|
msg="&cookieBlockCookiesMsg.label;"
|
|
|
|
oncommand="CookieImageAction('cookieBlock');"/>
|
|
|
|
<menuitem id="AllowCookies" label="&cookieAllowCookiesCmd.label;"
|
|
|
|
accesskey="&cookieAllowCookiesCmd.accesskey;"
|
|
|
|
msg="&cookieAllowCookiesMsg.label;"
|
|
|
|
oncommand="CookieImageAction('cookieAllow');"/>
|
|
|
|
<menuseparator/>
|
|
|
|
<menuitem label="&cookieDisplayCookiesCmd.label;"
|
|
|
|
accesskey="&cookieDisplayCookiesCmd.accesskey;"
|
|
|
|
oncommand="viewCookies();"/>
|
|
|
|
</menupopup>
|
|
|
|
</menu>
|
|
|
|
<menu label="&cookieImageManager.label;"
|
|
|
|
accesskey="&cookieImageManager.accesskey;"
|
|
|
|
id="image"
|
|
|
|
insertbefore="navBeginGlobalItems">
|
|
|
|
<menupopup>
|
|
|
|
<menuitem id="BlockImages" label="&cookieBlockImagesCmd.label;"
|
|
|
|
accesskey="&cookieBlockImagesCmd.accesskey;"
|
|
|
|
msg="&cookieBlockImagesMsg.label;"
|
|
|
|
oncommand="CookieImageAction('imageBlock');"/>
|
2006-07-27 14:56:34 +00:00
|
|
|
<menuitem id="AllowImages" label="&cookieAllowImagesCmd.label;"
|
|
|
|
accesskey="&cookieAllowImagesCmd.accesskey;"
|
|
|
|
msg="&cookieAllowImagesMsg.label;"
|
|
|
|
oncommand="CookieImageAction('imageAllow');"/>
|
|
|
|
<menuseparator/>
|
|
|
|
<menuitem label="&cookieDisplayImagesCmd.label;"
|
|
|
|
accesskey="&cookieDisplayImagesCmd.accesskey;"
|
|
|
|
oncommand="viewImages();"/>
|
2006-07-27 14:56:33 +00:00
|
|
|
</menupopup>
|
|
|
|
</menu>
|
2006-07-27 14:56:43 +00:00
|
|
|
<menu label="&cookiePopupManager.label;"
|
|
|
|
accesskey="&cookiePopupManager.accesskey;"
|
|
|
|
id="popup"
|
|
|
|
insertbefore="navBeginGlobalItems">
|
|
|
|
<menupopup>
|
|
|
|
<menuitem id="AllowPopups" label="&cookieAllowPopupsCmd.label;"
|
|
|
|
accesskey="&cookieAllowPopupsCmd.accesskey;"
|
2006-07-27 14:57:50 +00:00
|
|
|
oncommand="PopupAction();"/>
|
|
|
|
<menuitem id="AboutPopups" label="&cookieAboutPopupBlocking.label;"
|
|
|
|
accesskey="&cookieAboutPopupBlocking.accesskey;"
|
|
|
|
oncommand="OpenAboutPopups();"
|
|
|
|
hidden="true"/>
|
|
|
|
<menuitem id="ManagePopups" label="&cookieManagePopups.label;"
|
|
|
|
accesskey="&cookieManagePopups.accesskey;"
|
|
|
|
oncommand="OpenManagePopups();"
|
|
|
|
hidden="true"/>
|
2006-07-27 14:56:43 +00:00
|
|
|
</menupopup>
|
|
|
|
</menu>
|
2006-07-27 14:56:33 +00:00
|
|
|
</menupopup>
|
|
|
|
</overlay>
|