Confirmed users
657
edits
(Initial write-up) |
(Document the Private Browsing service) |
||
| Line 5: | Line 5: | ||
==APIs for Extensions== | ==APIs for Extensions== | ||
===The Private Browsing service=== | |||
The Private Browsing service can be used in order to get and set the current status of private browsing. It supports the nsIPrivateBrowsingService interface: | |||
[scriptable, uuid(d2943870-c781-11dc-95ff-0800200c9a66)] | |||
interface nsIPrivateBrowsingService : nsISupports | |||
{ | |||
// Whether or not the private browsing mode is currently active. | |||
attribute boolean privateBrowsing; | |||
}; | |||
You can use the following code sample in order to get the current status of the private browsing mode, or change it. | |||
var pbs = Components.classes["@mozilla.org/privatebrowsing-service;1"] | |||
.getService(Components.interfaces.nsIPrivateBrowsingService); | |||
// are we currently in the Private Browsing mode? | |||
var inPrivateBrowsingMode = pbs.privateBrowsing; | |||
// enter the Private Browsing mode | |||
pbs.privateBrowsing = true; | |||
// now, whatever we do remains private! | |||
// exit the Private Browsing mode | |||
pbs.privateBrowsing = false; | |||
==Code Samples== | ==Code Samples== | ||