home *** CD-ROM | disk | FTP | other *** search
/ ftp.swcp.com / ftp.swcp.com.zip / ftp.swcp.com / mac / mozilla-macos9-1.3.1.sea.bin / Mozilla1.3.1 / Chrome / comm.jar / content / cookie / cookieContextOverlay.xul < prev    next >
Extensible Markup Language  |  2003-06-07  |  5KB  |  148 lines

  1. <?xml version="1.0"?>
  2.  
  3. <!--
  4.    The contents of this file are subject to the Netscape Public
  5.    License Version 1.1 (the "License"); you may not use this file
  6.    except in compliance with the License. You may obtain a copy of
  7.    the License at http://www.mozilla.org/NPL/
  8.     
  9.    Software distributed under the License is distributed on an "AS
  10.    IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  11.    implied. See the License for the specific language governing
  12.    rights and limitations under the License.
  13.     
  14.    The Original Code is Mozilla Communicator client code, released
  15.    March 31, 1998.
  16.    
  17.    The Initial Developer of the Original Code is Netscape
  18.    Communications Corporation. Portions created by Netscape are
  19.    Copyright (C) 1998-1999 Netscape Communications Corporation. All
  20.    Rights Reserved.
  21.    
  22.    Contributor(s): 
  23.   -->
  24.  
  25. <!DOCTYPE window SYSTEM "chrome://cookie/locale/cookieContextOverlay.dtd">
  26.  
  27. <overlay id="cookieContextOverlay"
  28.          xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  29.  
  30.   <script type="application/x-javascript" src="chrome://cookie/content/cookieOverlay.js"/>
  31.  
  32.   <script type="application/x-javascript">
  33.   <![CDATA[
  34.  
  35.     // Code from nsContextMenu.js. Note that we extend the prototype here, rather 
  36.     // than making these methods on a new object, as some methods require access
  37.     // to data maintained by nsContextMenu.  
  38.  
  39.     var cookieContextMenu = {
  40.  
  41.       // Determine if "Block Image" is to appear in the menu.
  42.       // Return true if "imageBlocker.enabled" pref is set and image is not already blocked.
  43.       isBlockingImages : function () {
  44.         /* determine if image is already being blocked */
  45.         var permissionmanager =
  46.           Components.classes["@mozilla.org/permissionmanager;1"]
  47.             .getService(Components.interfaces.nsIPermissionManager);
  48.         if(!permissionmanager) {
  49.           return true;
  50.         }
  51.         return !permissionmanager.testForBlocking(gContextMenu.imageURL, IMAGEPERMISSION);
  52.       },
  53.  
  54.       // Determine if "imageBlocker.enabled" pref is set
  55.       isPrefSet: function () {
  56.         var pref = gContextMenu.getService('@mozilla.org/preferences-service;1', 'nsIPrefBranch');
  57.         var result = false;
  58.         try {
  59.           result = pref.getBoolPref( "imageblocker.enabled" );
  60.         } catch(e) {
  61.         }
  62.         return result;
  63.       },
  64.  
  65.       // Block image from loading in the future.
  66.       blockImage : function () {
  67.         var permissionmanager =
  68.           Components.classes["@mozilla.org/permissionmanager;1"]
  69.             .getService(Components.interfaces.nsIPermissionManager);
  70.         if (!permissionmanager) {
  71.           return;
  72.         }
  73.         permissionmanager.add(gContextMenu.imageURL, false, IMAGEPERMISSION);
  74.       },
  75.  
  76.       // Unblock image from loading in the future.
  77.       unblockImage : function () {
  78.         var permissionmanager =
  79.           Components.classes["@mozilla.org/permissionmanager;1"]
  80.             .getService().QueryInterface(Components.interfaces.nsIPermissionManager);
  81.         if (!permissionmanager) {
  82.           return;
  83.         }
  84.         permissionmanager.add(gContextMenu.imageURL, true, IMAGEPERMISSION);
  85.       },
  86.  
  87.       initImageBlocking : function () {
  88.         try {
  89.         // Block image depends on whether an image was clicked on, and,
  90.         // whether the user pref is enabled.
  91.  
  92.         gContextMenu.showItem
  93.           ("context-blockimage",
  94.            gContextMenu.onImage && cookieContextMenu.isPrefSet() &&
  95.            cookieContextMenu.isBlockingImages());
  96.  
  97.         gContextMenu.showItem
  98.           ("context-unblockimage",
  99.            gContextMenu.onImage && cookieContextMenu.isPrefSet() &&
  100.            !cookieContextMenu.isBlockingImages());
  101.         } catch (e) {}
  102.       },
  103.  
  104.       addContextMenuItemListeners : function (aEvent) {
  105.         var contextPopup = document.getElementById("contentAreaContextSet");
  106.         if (contextPopup)
  107.           contextPopup.addEventListener("popupshowing", cookieContextMenu.initImageBlocking, false);
  108.  
  109.         var mailContextPopup = document.getElementById("messagePaneContext");
  110.         if (mailContextPopup)
  111.           mailContextPopup.addEventListener("popupshowing", cookieContextMenu.initImageBlocking, false);
  112.       }
  113.     }
  114.     window.addEventListener("load", cookieContextMenu.addContextMenuItemListeners, false);
  115.  
  116.    ]]>
  117.   </script>         
  118.  
  119.   <!-- context menu -->
  120.   <popup id="contentAreaContextMenu">
  121.     <menuitem id="context-blockimage"
  122.               label="&blockImageCmd.label;"
  123.               accesskey=""
  124.               oncommand="cookieContextMenu.blockImage();"
  125.               insertafter="context-viewimage"/>
  126.     <menuitem id="context-unblockimage"
  127.               label="&unblockImageCmd.label;"
  128.               accesskey=""
  129.               oncommand="cookieContextMenu.unblockImage();"
  130.               insertafter="context-viewimage"/>
  131.   </popup>
  132.  
  133.   <!-- Mail Message Pane context menu -->
  134.   <popup id="messagePaneContext">
  135.     <menuitem id="context-blockimage"
  136.               label="&blockImageCmd.label;"
  137.               accesskey=""
  138.               oncommand="cookieContextMenu.blockImage();"
  139.               insertafter="context-viewimage"/>
  140.     <menuitem id="context-unblockimage"
  141.               label="&unblockImageCmd.label;"
  142.               accesskey=""
  143.               oncommand="cookieContextMenu.unblockImage();"
  144.               insertafter="context-viewimage"/>
  145.   </popup>
  146.   
  147. </overlay>
  148.