1 /* See license.txt for terms of usage */ 2 3 define([ 4 "firebug/lib/trace", 5 "firebug/lib/object", 6 "firebug/lib/array", 7 "firebug/lib/events", 8 ], 9 function(FBTrace, Obj, Arr, Events) { 10 11 // ********************************************************************************************* // 12 // Constants 13 14 const Cc = Components.classes; 15 const Ci = Components.interfaces; 16 17 // ********************************************************************************************* // 18 19 /** 20 * No data should be written if Firefox is set to privatebrowsing. 21 * don't forget to check it before access (issue 2923). 22 */ 23 var Privacy = Obj.extend(Firebug.Module, 24 { 25 initialize: function() 26 { 27 if (this.observerService) 28 return; 29 30 this.observerService = Components.classes["@mozilla.org/observer-service;1"] 31 .getService(Components.interfaces.nsIObserverService); 32 33 this.observerService.addObserver(this, "private-browsing", false); 34 35 this.update(); 36 }, 37 38 shutdown: function() 39 { 40 this.observerService.removeObserver(this, "private-browsing"); 41 }, 42 43 update: function(data) 44 { 45 try 46 { 47 var pbs = Components.classes["@mozilla.org/privatebrowsing;1"] 48 .getService(Components.interfaces.nsIPrivateBrowsingService); 49 50 this.privateBrowsingEnabled = pbs.privateBrowsingEnabled; 51 52 Events.dispatch(this.fbListeners, "onPrivateBrowsingChange", 53 [this.privateBrowsingEnabled]); 54 55 if (FBTrace.DBG_ACTIVATION) 56 FBTrace.sysout("Privacy.update " + this.isPrivateBrowsing()) 57 } 58 catch (e) 59 { 60 if (FBTrace.DBG_ERRORS) 61 FBTrace.sysout("Privacy.update EXCEPTION " + e, e); 62 } 63 }, 64 65 observe: function (subject, topic, data) 66 { 67 if (topic == "private-browsing") 68 Privacy.update(data); 69 }, 70 71 isPrivateBrowsing: function() 72 { 73 return this.privateBrowsingEnabled; 74 }, 75 }); 76 77 // ********************************************************************************************* // 78 // Registration 79 80 Firebug.registerModule(Privacy); 81 82 return Privacy; 83 84 // ********************************************************************************************* // 85 }); 86