home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 January / 01_02.iso / software / netscape62win / browser.xpi / bin / chrome / comm.jar / content / cookie / cookieTasksOverlay.xul < prev    next >
Encoding:
Extensible Markup Language  |  2001-08-14  |  6.2 KB  |  162 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/cookieTasksOverlay.dtd">
  26.  
  27. <overlay id="cookieTasksOverlay"
  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.     // Remove the image entries from the task menu
  36.     function HideImage() {
  37.       var element;
  38.       element = document.getElementById("image");
  39.       element.setAttribute("style","display: none;" );
  40.       element.setAttribute("disabled","true" );
  41.     }
  42.  
  43.     // for some unexplainable reason, CheckForImage() keeps getting called repeatedly
  44.     // as we mouse over the task menu.  IMO, that shouldn't be happening.  To avoid
  45.     // taking a performance hit due to this, we will set the following flag to avoid
  46.     // reexecuting the routine
  47.     var alreadyCheckedForImage = false;
  48.  
  49.     // determine if we need to remove the image entries from the task menu
  50.     function CheckForImage()
  51.     {
  52.       if (alreadyCheckedForImage) {
  53.         return;
  54.       }
  55.       alreadyCheckedForImage = true;
  56.       // remove image functions (unless overruled by the "imageblocker.enabled" pref)
  57.       var pref;
  58.       pref = Components.classes['@mozilla.org/preferences;1'];
  59.       pref = pref.getService();
  60.       pref = pref.QueryInterface(Components.interfaces.nsIPrefBranch);
  61.       try {
  62.         if (!pref.getBoolPref("imageblocker.enabled")) {
  63.           HideImage();
  64.         }
  65.       } catch(e) {
  66.         HideImage();
  67.       }
  68.     }
  69.  
  70.     // perform a Cookie or Image action
  71.     function CookieImageAction(action) {
  72.  
  73.       if (!("_content" in window) || !window._content) {
  74.         // this occurs if doing tasks->privacy->cookie->block from java console
  75.         return;
  76.       }
  77.  
  78.       var permissionmanager =
  79.         Components.classes["@mozilla.org/permissionmanager;1"]
  80.           .getService().QueryInterface(Components.interfaces.nsIPermissionManager);
  81.       if (!permissionmanager) {
  82.         return;
  83.       }
  84.       var COOKIEPERMISSION = 0;
  85.       var IMAGEPERMISSION = 1;
  86.       var element;
  87.       switch (action) {
  88.         case "cookieAllow":
  89.           permissionmanager.add(window._content.location, true, COOKIEPERMISSION);
  90.           element = document.getElementById("AllowCookies");
  91.           alert(element.getAttribute("msg"));
  92.           break;
  93.         case "cookieBlock":
  94.           permissionmanager.add(window._content.location, false, COOKIEPERMISSION);
  95.           element = document.getElementById("BlockCookies");
  96.           alert(element.getAttribute("msg"));
  97.           break;
  98.         case "imageAllow":
  99.           permissionmanager.add(window._content.location, true, IMAGEPERMISSION);
  100.           element = document.getElementById("AllowImages");
  101.           alert(element.getAttribute("msg"));
  102.           break;
  103.         case "imageBlock":
  104.           permissionmanager.add(window._content.location, false, IMAGEPERMISSION);
  105.           element = document.getElementById("BlockImages");
  106.           alert(element.getAttribute("msg"));
  107.           break;
  108.         default:
  109.       }
  110.     }  
  111.  
  112.   ]]>
  113.   </script>         
  114.  
  115.   <!-- tasksOverlay menu items -->
  116.   <menupopup id="taskPopup" onpopupshowing="CheckForImage()"/>
  117.  
  118.   <menupopup  id="personalManagers">
  119.     <menu label="&cookieCookieManager.label;"
  120.                 accesskey="&cookieCookieManager.accesskey;"
  121.                 position="1">
  122.       <menupopup>
  123.         <menuitem label="&cookieDisplayCookiesCmd.label;"
  124.                   accesskey="&cookieDisplayCookiesCmd.accesskey;" 
  125.                   oncommand="viewCookies();"/> 
  126.         <menuitem id="AllowCookies" label="&cookieAllowCookiesCmd.label;"
  127.                   accesskey="&cookieAllowCookiesCmd.accesskey;" 
  128.                   msg="&cookieAllowCookiesMsg.label;"
  129.                   oncommand="CookieImageAction('cookieAllow');"/> 
  130.         <menuitem id="BlockCookies" label="&cookieBlockCookiesCmd.label;"
  131.                   accesskey="&cookieBlockCookiesCmd.accesskey;" 
  132.                   msg="&cookieBlockCookiesMsg.label;"
  133.                   oncommand="CookieImageAction('cookieBlock');"/> 
  134.       </menupopup>
  135.     </menu>
  136.     <menu label="&cookieImageManager.label;"
  137.           accesskey="&cookieImageManager.accesskey;"
  138.           id="image"
  139.           position="2">
  140.       <menupopup>
  141.         <menuitem label="&cookieDisplayImagesCmd.label;"
  142.                   accesskey="&cookieDisplayImagesCmd.accesskey;" 
  143.                   oncommand="viewImages();"/> 
  144.         <menuitem id="AllowImages" label="&cookieAllowImagesCmd.label;"
  145.                   accesskey="&cookieAllowImagesCmd.accesskey;" 
  146.                   msg="&cookieAllowImagesMsg.label;"
  147.                   oncommand="CookieImageAction('imageAllow');"/> 
  148.         <menuitem id="BlockImages" label="&cookieBlockImagesCmd.label;"
  149.                   accesskey="&cookieBlockImagesCmd.accesskey;" 
  150.                   msg="&cookieBlockImagesMsg.label;"
  151.                   oncommand="CookieImageAction('imageBlock');"/> 
  152.       </menupopup>
  153.     </menu>
  154.     <menuseparator insertbefore="lastInPersonalManagers"/>
  155.     <menuitem label="&cookieTutorialCmd.label;"
  156.               accesskey="&cookieTutorialCmd.accesskey;"
  157.               oncommand="viewTutorial();"
  158.               insertbefore="lastInPersonalManagers"/>
  159.   </menupopup>
  160.  
  161. </overlay>
  162.