2001-02-21 08:14:11 +03: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):
|
|
|
|
-->
|
|
|
|
|
2003-03-18 01:55:42 +03:00
|
|
|
<!DOCTYPE overlay SYSTEM "chrome://cookie/locale/cookieContextOverlay.dtd">
|
2001-02-21 08:14:11 +03:00
|
|
|
|
|
|
|
<overlay id="cookieContextOverlay"
|
|
|
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
|
|
|
|
2001-03-13 18:35:07 +03:00
|
|
|
<script type="application/x-javascript" src="chrome://cookie/content/cookieOverlay.js"/>
|
2001-02-21 08:14:11 +03:00
|
|
|
|
2001-03-13 18:35:07 +03:00
|
|
|
<script type="application/x-javascript">
|
2001-02-21 08:14:11 +03:00
|
|
|
<![CDATA[
|
|
|
|
|
|
|
|
// Code from nsContextMenu.js. Note that we extend the prototype here, rather
|
|
|
|
// than making these methods on a new object, as some methods require access
|
|
|
|
// to data maintained by nsContextMenu.
|
|
|
|
|
|
|
|
var cookieContextMenu = {
|
|
|
|
|
|
|
|
// Determine if "Block Image" is to appear in the menu.
|
|
|
|
// Return true if "imageBlocker.enabled" pref is set and image is not already blocked.
|
|
|
|
isBlockingImages : function () {
|
|
|
|
/* determine if image is already being blocked */
|
2001-03-29 06:11:48 +04:00
|
|
|
var permissionmanager =
|
|
|
|
Components.classes["@mozilla.org/permissionmanager;1"]
|
2001-10-17 00:38:57 +04:00
|
|
|
.getService(Components.interfaces.nsIPermissionManager);
|
2002-05-29 01:42:29 +04:00
|
|
|
if(!permissionmanager) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return !permissionmanager.testForBlocking(gContextMenu.imageURL, IMAGEPERMISSION);
|
2001-02-21 08:14:11 +03:00
|
|
|
},
|
|
|
|
|
2001-10-17 00:38:57 +04:00
|
|
|
// Determine if "imageBlocker.enabled" pref is set
|
|
|
|
isPrefSet: function () {
|
2001-10-27 09:39:25 +04:00
|
|
|
var pref = gContextMenu.getService('@mozilla.org/preferences-service;1', 'nsIPrefBranch');
|
2001-10-17 00:38:57 +04:00
|
|
|
var result = false;
|
|
|
|
try {
|
2001-10-27 09:39:25 +04:00
|
|
|
result = pref.getBoolPref( "imageblocker.enabled" );
|
2001-10-17 00:38:57 +04:00
|
|
|
} catch(e) {
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
},
|
|
|
|
|
2001-02-21 08:14:11 +03:00
|
|
|
// Block image from loading in the future.
|
|
|
|
blockImage : function () {
|
2001-10-17 00:38:57 +04:00
|
|
|
var permissionmanager =
|
|
|
|
Components.classes["@mozilla.org/permissionmanager;1"]
|
|
|
|
.getService(Components.interfaces.nsIPermissionManager);
|
|
|
|
if (!permissionmanager) {
|
|
|
|
return;
|
|
|
|
}
|
2001-11-14 09:37:45 +03:00
|
|
|
permissionmanager.add(gContextMenu.imageURL, false, IMAGEPERMISSION);
|
2001-10-17 00:38:57 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
// Unblock image from loading in the future.
|
|
|
|
unblockImage : function () {
|
|
|
|
var permissionmanager =
|
|
|
|
Components.classes["@mozilla.org/permissionmanager;1"]
|
|
|
|
.getService().QueryInterface(Components.interfaces.nsIPermissionManager);
|
|
|
|
if (!permissionmanager) {
|
|
|
|
return;
|
|
|
|
}
|
2001-11-14 09:37:45 +03:00
|
|
|
permissionmanager.add(gContextMenu.imageURL, true, IMAGEPERMISSION);
|
2001-02-21 08:14:11 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
initImageBlocking : function () {
|
2001-08-13 08:39:31 +04:00
|
|
|
try {
|
2001-02-21 08:14:11 +03:00
|
|
|
// Block image depends on whether an image was clicked on, and,
|
|
|
|
// whether the user pref is enabled.
|
2001-10-17 00:38:57 +04:00
|
|
|
|
2001-08-14 02:44:43 +04:00
|
|
|
gContextMenu.showItem
|
2001-02-21 08:14:11 +03:00
|
|
|
("context-blockimage",
|
2001-10-17 00:38:57 +04:00
|
|
|
gContextMenu.onImage && cookieContextMenu.isPrefSet() &&
|
|
|
|
cookieContextMenu.isBlockingImages());
|
|
|
|
|
|
|
|
gContextMenu.showItem
|
|
|
|
("context-unblockimage",
|
|
|
|
gContextMenu.onImage && cookieContextMenu.isPrefSet() &&
|
|
|
|
!cookieContextMenu.isBlockingImages());
|
2001-08-13 08:39:31 +04:00
|
|
|
} catch (e) {}
|
2001-02-21 08:14:11 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
addContextMenuItemListeners : function (aEvent) {
|
|
|
|
var contextPopup = document.getElementById("contentAreaContextSet");
|
2002-05-31 22:40:39 +04:00
|
|
|
if (contextPopup)
|
|
|
|
contextPopup.addEventListener("popupshowing", cookieContextMenu.initImageBlocking, false);
|
|
|
|
|
|
|
|
var mailContextPopup = document.getElementById("messagePaneContext");
|
|
|
|
if (mailContextPopup)
|
|
|
|
mailContextPopup.addEventListener("popupshowing", cookieContextMenu.initImageBlocking, false);
|
2001-02-21 08:14:11 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
window.addEventListener("load", cookieContextMenu.addContextMenuItemListeners, false);
|
|
|
|
|
|
|
|
]]>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<!-- context menu -->
|
|
|
|
<popup id="contentAreaContextMenu">
|
|
|
|
<menuitem id="context-blockimage"
|
2001-03-22 03:59:29 +03:00
|
|
|
label="&blockImageCmd.label;"
|
2001-02-21 08:14:11 +03:00
|
|
|
accesskey=""
|
2001-02-24 05:48:51 +03:00
|
|
|
oncommand="cookieContextMenu.blockImage();"
|
2001-02-21 08:14:11 +03:00
|
|
|
insertafter="context-viewimage"/>
|
2001-10-17 00:38:57 +04:00
|
|
|
<menuitem id="context-unblockimage"
|
|
|
|
label="&unblockImageCmd.label;"
|
|
|
|
accesskey=""
|
|
|
|
oncommand="cookieContextMenu.unblockImage();"
|
|
|
|
insertafter="context-viewimage"/>
|
2001-02-21 08:14:11 +03:00
|
|
|
</popup>
|
2002-05-31 22:40:39 +04:00
|
|
|
|
|
|
|
<!-- Mail Message Pane context menu -->
|
|
|
|
<popup id="messagePaneContext">
|
|
|
|
<menuitem id="context-blockimage"
|
|
|
|
label="&blockImageCmd.label;"
|
|
|
|
accesskey=""
|
|
|
|
oncommand="cookieContextMenu.blockImage();"
|
|
|
|
insertafter="context-viewimage"/>
|
|
|
|
<menuitem id="context-unblockimage"
|
|
|
|
label="&unblockImageCmd.label;"
|
|
|
|
accesskey=""
|
|
|
|
oncommand="cookieContextMenu.unblockImage();"
|
|
|
|
insertafter="context-viewimage"/>
|
|
|
|
</popup>
|
|
|
|
|
2001-02-21 08:14:11 +03:00
|
|
|
</overlay>
|