home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 December / PCWorld_2005-12_cd.bin / komunikace / netscape / nsb-install-8-0.exe / chrome / comm.jar / content / cookie / cookieContextOverlay.xul < prev    next >
Extensible Markup Language  |  2005-09-26  |  6KB  |  155 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 overlay 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 image is not already blocked.
  43.       isBlockingImages : function () {
  44.         /* determine if image is already being blocked */
  45.         const nsIPermissionManager = Components.interfaces.nsIPermissionManager;
  46.         var permissionmanager =
  47.           Components.classes["@mozilla.org/permissionmanager;1"]
  48.             .getService(Components.interfaces.nsIPermissionManager);
  49.         if(!permissionmanager) {
  50.           return true;
  51.         }
  52.         var ioService = Components.classes["@mozilla.org/network/io-service;1"]
  53.                                   .getService(Components.interfaces.nsIIOService);
  54.         var uri = ioService.newURI(gContextMenu.imageURL, null, null);
  55.         return permissionmanager.testPermission(uri, "image") != nsIPermissionManager.DENY_ACTION;
  56.       },
  57.  
  58.       // Block image from loading in the future.
  59.       blockImage : function () {
  60.         const nsIPermissionManager = Components.interfaces.nsIPermissionManager;
  61.         var permissionmanager =
  62.           Components.classes["@mozilla.org/permissionmanager;1"]
  63.             .getService(Components.interfaces.nsIPermissionManager);
  64.         if (!permissionmanager) {
  65.           return;
  66.         }
  67.         var ioService = Components.classes["@mozilla.org/network/io-service;1"]
  68.                                   .getService(Components.interfaces.nsIIOService);
  69.         uri = ioService.newURI(gContextMenu.imageURL, null, null);
  70.         permissionmanager.add(uri, "image", nsIPermissionManager.DENY_ACTION);
  71.       },
  72.  
  73.       // Unblock image from loading in the future.
  74.       unblockImage : function () {
  75.         const nsIPermissionManager = Components.interfaces.nsIPermissionManager;
  76.         var permissionmanager =
  77.           Components.classes["@mozilla.org/permissionmanager;1"]
  78.             .getService().QueryInterface(Components.interfaces.nsIPermissionManager);
  79.         if (!permissionmanager) {
  80.           return;
  81.         }
  82.         var ioService = Components.classes["@mozilla.org/network/io-service;1"]
  83.                                   .getService(Components.interfaces.nsIIOService);
  84.         uri = ioService.newURI(gContextMenu.imageURL, null, null);
  85.         permissionmanager.remove(uri.host, "image");
  86.       },
  87.  
  88.       initImageBlocking : function () {
  89.         var showImageBlockingContextMenu;
  90.         try {
  91.           var prefs = Components.classes["@mozilla.org/preferences-service;1"]
  92.                      .getService(Components.interfaces.nsIPrefBranch);
  93.           showImageBlockingContextMenu = prefs.getBoolPref("imageblocker.enabled");
  94.         }
  95.         catch (ex) {
  96.           showImageBlockingContextMenu = true;
  97.         }
  98.         
  99.         try {        
  100.         // Block image depends on whether an image was clicked on
  101.         gContextMenu.showItem
  102.           ("context-blockimage",
  103.            showImageBlockingContextMenu && gContextMenu.onImage && cookieContextMenu.isBlockingImages());
  104.  
  105.         gContextMenu.showItem
  106.           ("context-unblockimage",
  107.            showImageBlockingContextMenu && gContextMenu.onImage && !cookieContextMenu.isBlockingImages());
  108.         } catch (e) {}
  109.       },
  110.  
  111.       addContextMenuItemListeners : function (aEvent) {
  112.         var contextPopup = document.getElementById("contentAreaContextSet");
  113.         if (contextPopup)
  114.           contextPopup.addEventListener("popupshowing", cookieContextMenu.initImageBlocking, false);
  115.  
  116.         var mailContextPopup = document.getElementById("messagePaneContext");
  117.         if (mailContextPopup)
  118.           mailContextPopup.addEventListener("popupshowing", cookieContextMenu.initImageBlocking, false);
  119.       }
  120.     }
  121.     window.addEventListener("load", cookieContextMenu.addContextMenuItemListeners, false);
  122.  
  123.    ]]>
  124.   </script>         
  125.  
  126.   <!-- context menu -->
  127.   <popup id="contentAreaContextMenu">
  128.     <menuitem id="context-blockimage"
  129.               label="&blockImageCmd.label;"
  130.               accesskey=""
  131.               oncommand="cookieContextMenu.blockImage();"
  132.               insertafter="context-viewimage"/>
  133.     <menuitem id="context-unblockimage"
  134.               label="&unblockImageCmd.label;"
  135.               accesskey=""
  136.               oncommand="cookieContextMenu.unblockImage();"
  137.               insertafter="context-viewimage"/>
  138.   </popup>
  139.  
  140.   <!-- Mail Message Pane context menu -->
  141.   <popup id="messagePaneContext">
  142.     <menuitem id="context-blockimage"
  143.               label="&blockImageCmd.label;"
  144.               accesskey=""
  145.               oncommand="cookieContextMenu.blockImage();"
  146.               insertafter="context-viewimage"/>
  147.     <menuitem id="context-unblockimage"
  148.               label="&unblockImageCmd.label;"
  149.               accesskey=""
  150.               oncommand="cookieContextMenu.unblockImage();"
  151.               insertafter="context-viewimage"/>
  152.   </popup>
  153.   
  154. </overlay>
  155.