1 /* See license.txt for terms of usage */
  2 
  3 define([
  4     "firebug/lib/object",
  5     "firebug/lib/options",
  6 ],
  7 function(Obj, Options) {
  8 
  9 // ********************************************************************************************* //
 10 // Menu Utils
 11 
 12 var MenuUtils = 
 13 {
 14     optionMenu: function(context, label, tooltiptext, domain, option)
 15     {
 16         var value = Options.getPref(domain, option), self = this;
 17         return {
 18             label: label,
 19             tooltiptext: tooltiptext,
 20             type: "checkbox",
 21             checked: value,
 22             command: function()
 23             {
 24                 var checked = this.hasAttribute("checked");
 25                 self.setPref(domain, option, checked);
 26             }
 27         };
 28     },
 29 
 30     optionAllowGlobally: function(context, label, tooltiptext, domain, option)
 31     {
 32         var value = Options.getPref(domain, option) == 0;
 33         return {
 34             label: label,
 35             tooltiptext: tooltiptext,
 36             type: "checkbox",
 37             checked: value,
 38             command: Obj.bindFixed(this.onAllowCookie, this, domain, option)
 39         }
 40     },
 41 
 42     // Command handlers
 43     onAllowCookie: function(domain, option)
 44     {
 45         var value = Options.getPref(domain, option);
 46         switch (value)
 47         {
 48             case 0: // accept all cookies by default
 49             Options.setPref(domain, option, 2);
 50             return;
 51 
 52             case 1: // only accept from the originating site (block third party cookies)
 53             case 2: // block all cookies by default;
 54             case 3: // use p3p settings
 55             Options.setPref(domain, option, 0);
 56             return;
 57         } 
 58     },
 59 
 60     onBlockCurrent: function()
 61     {
 62     },
 63 
 64     setPref: function(domain, name, value)
 65     {
 66         Options.setPref(domain, name, value);
 67     }
 68 };
 69 
 70 // ********************************************************************************************* //
 71 
 72 return MenuUtils;
 73 
 74 // ********************************************************************************************* //
 75 });
 76 
 77