home *** CD-ROM | disk | FTP | other *** search
- <?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/cookieContextOverlay.dtd">
-
- <overlay id="cookieContextOverlay"
- 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[
-
- // 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 "imageBlocker.enabled" pref is set */
- var pref = gContextMenu.getService('@mozilla.org/preferences;1', 'nsIPref');
- var result = false;
- try {
- result = pref.GetBoolPref( "imageblocker.enabled" );
- } catch(e) {
- }
- if (!result) {
- /* pref is not set so return false */
- return false;
- }
-
- /* determine if image is already being blocked */
- var permissionmanager =
- Components.classes["@mozilla.org/permissionmanager;1"]
- .getService().QueryInterface(Components.interfaces.nsIPermissionManager);
-
-
- var enumerator = permissionmanager.enumerator;
- while (enumerator.hasMoreElements()) {
- var nextPermission = enumerator.getNext();
- nextPermission = nextPermission.QueryInterface(Components.interfaces.nsIPermission);
- var imageType = 1;
- if (nextPermission.type == imageType &&
- !nextPermission.capability) {
- /* some image host is being blocked, need to find out if it's our image's host */
- var host = nextPermission.host;
- if(host.charAt(0) == ".") { // get rid of the ugly dot on the start of some domains
- host = host.substring(1,host.length);
- }
- if (host && gContextMenu.imageURL.search(host) != -1) {
- /* it's our image's host that's being blocked */
- return false;
- }
- }
- }
- /* image is not already being blocked, so "Block Image" can appear on the menu */
- return true;
- },
-
- // Block image from loading in the future.
- blockImage : function () {
- var imgmanager =
- Components.classes["@mozilla.org/imgmanager;1"]
- .getService().QueryInterface(Components.interfaces.nsIImgManager);
- imgmanager.block(gContextMenu.imageURL);
- },
-
- initImageBlocking : function () {
- try {
- // Block image depends on whether an image was clicked on, and,
- // whether the user pref is enabled.
- gContextMenu.showItem
- ("context-blockimage",
- gContextMenu.onImage && cookieContextMenu.isBlockingImages());
- } catch (e) {}
- },
-
- addContextMenuItemListeners : function (aEvent) {
- var contextPopup = document.getElementById("contentAreaContextSet");
- contextPopup.addEventListener("popupshowing", cookieContextMenu.initImageBlocking, false);
- }
- }
-
- window.addEventListener("load", cookieContextMenu.addContextMenuItemListeners, false);
-
- // For some unexplainable reason, this overlay is loaded twice as can be demonstrated
- // by uncommenting the following "dump" statement which will get displayed twice
- // dump("$$$$$$$$$$ HERE WE ARE IN cookieContextOverlay.xul $$$$$$$$$$\n");
- // As a consequence, the block-image item appears twice in the context menu. To
- // prevent that from happening, the "display:none" was added to the menuitem below
-
- ]]>
- </script>
-
- <!-- context menu -->
- <popup id="contentAreaContextMenu">
- <menuitem id="context-blockimage"
- label="&blockImageCmd.label;"
- accesskey=""
- oncommand="cookieContextMenu.blockImage();"
- style="display:none;"
- insertafter="context-viewimage"/>
- </popup>
- </overlay>
-