gecko-dev/xpfe/components/permissions/content/cookieTasksOverlay.xul

162 lines
6.0 KiB
Plaintext
Raw Normal View History

2001-02-21 05:14:11 +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):
-->
<!DOCTYPE window SYSTEM "chrome://cookie/locale/cookieTasksOverlay.dtd">
2001-02-21 05:14:11 +00:00
<overlay id="cookieTasksOverlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript" src="chrome://cookie/content/cookieOverlay.js"/>
2001-02-21 05:14:11 +00:00
<script type="application/x-javascript">
2001-02-21 05:14:11 +00:00
<![CDATA[
// Remove the image entries from the task menu
function HideImage() {
var element;
element = document.getElementById("image");
element.setAttribute("style","display: none;" );
element.setAttribute("disabled","true" );
}
// 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;
2001-02-21 05:14:11 +00:00
// determine if we need to remove the image entries from the task menu
function CheckForImage()
{
if (alreadyCheckedForImage) {
return;
}
alreadyCheckedForImage = true;
2001-02-21 05:14:11 +00:00
// remove image functions (unless overruled by the "imageblocker.enabled" pref)
var pref;
pref = Components.classes['@mozilla.org/preferences;1'];
pref = pref.getService();
pref = pref.QueryInterface(Components.interfaces.nsIPrefBranch);
2001-02-21 05:14:11 +00:00
try {
if (!pref.getBoolPref("imageblocker.enabled")) {
2001-02-21 05:14:11 +00:00
HideImage();
}
} catch(e) {
HideImage();
2001-02-21 05:14:11 +00:00
}
}
// perform a Cookie or Image action
function CookieImageAction(action) {
if (!("_content" in window)) {
// this occurs if doing tasks->privacy->cookie->block from java console
return;
}
var permissionmanager =
Components.classes["@mozilla.org/permissionmanager;1"]
.getService().QueryInterface(Components.interfaces.nsIPermissionManager);
if (!permissionmanager) {
return;
}
2001-02-21 05:14:11 +00:00
var COOKIEPERMISSION = 0;
var IMAGEPERMISSION = 1;
var element;
2001-02-21 05:14:11 +00:00
switch (action) {
case "cookieAllow":
permissionmanager.add(window._content.location, true, COOKIEPERMISSION);
2001-02-21 05:14:11 +00:00
element = document.getElementById("AllowCookies");
alert(element.getAttribute("msg"));
break;
case "cookieBlock":
permissionmanager.add(window._content.location, false, COOKIEPERMISSION);
2001-02-21 05:14:11 +00:00
element = document.getElementById("BlockCookies");
alert(element.getAttribute("msg"));
break;
case "imageAllow":
permissionmanager.add(window._content.location, true, IMAGEPERMISSION);
2001-02-21 05:14:11 +00:00
element = document.getElementById("AllowImages");
alert(element.getAttribute("msg"));
break;
case "imageBlock":
permissionmanager.add(window._content.location, false, IMAGEPERMISSION);
2001-02-21 05:14:11 +00:00
element = document.getElementById("BlockImages");
alert(element.getAttribute("msg"));
break;
default:
}
}
]]>
</script>
<!-- tasksOverlay menu items -->
2001-08-06 21:49:35 +00:00
<menupopup id="taskPopup" onpopupshowing="CheckForImage()"/>
<menupopup id="personalManagers">
<menu label="&cookieCookieManager.label;"
2001-02-21 05:14:11 +00:00
accesskey="&cookieCookieManager.accesskey;"
position="1">
<menupopup>
<menuitem label="&cookieDisplayCookiesCmd.label;"
2001-02-21 05:14:11 +00:00
accesskey="&cookieDisplayCookiesCmd.accesskey;"
oncommand="viewCookies();"/>
<menuitem id="AllowCookies" label="&cookieAllowCookiesCmd.label;"
2001-02-21 05:14:11 +00:00
accesskey="&cookieAllowCookiesCmd.accesskey;"
msg="&cookieAllowCookiesMsg.label;"
oncommand="CookieImageAction('cookieAllow');"/>
<menuitem id="BlockCookies" label="&cookieBlockCookiesCmd.label;"
2001-02-21 05:14:11 +00:00
accesskey="&cookieBlockCookiesCmd.accesskey;"
msg="&cookieBlockCookiesMsg.label;"
oncommand="CookieImageAction('cookieBlock');"/>
</menupopup>
</menu>
<menu label="&cookieImageManager.label;"
accesskey="&cookieImageManager.accesskey;"
id="image"
2001-02-21 05:14:11 +00:00
position="2">
<menupopup>
<menuitem label="&cookieDisplayImagesCmd.label;"
2001-02-21 05:14:11 +00:00
accesskey="&cookieDisplayImagesCmd.accesskey;"
oncommand="viewImages();"/>
<menuitem id="AllowImages" label="&cookieAllowImagesCmd.label;"
2001-02-21 05:14:11 +00:00
accesskey="&cookieAllowImagesCmd.accesskey;"
msg="&cookieAllowImagesMsg.label;"
oncommand="CookieImageAction('imageAllow');"/>
<menuitem id="BlockImages" label="&cookieBlockImagesCmd.label;"
2001-02-21 05:14:11 +00:00
accesskey="&cookieBlockImagesCmd.accesskey;"
msg="&cookieBlockImagesMsg.label;"
oncommand="CookieImageAction('imageBlock');"/>
</menupopup>
</menu>
<menuseparator insertbefore="lastInPersonalManagers"/>
<menuitem label="&cookieTutorialCmd.label;"
2001-02-21 05:14:11 +00:00
accesskey="&cookieTutorialCmd.accesskey;"
oncommand="viewTutorial();"
insertbefore="lastInPersonalManagers"/>
</menupopup>
</overlay>