User:Ehsan/PrivateBrowsingForExtensions: Difference between revisions

→‎Private Browsing notifications: Add a description of private-browsing-query
No edit summary
(→‎Private Browsing notifications: Add a description of private-browsing-query)
Line 21: Line 21:


The second code sample below implements a full blown listener for the private browsing mode, which can both be used to query its current status, and set a watcher to watch for entering and/or leaving the private mode.
The second code sample below implements a full blown listener for the private browsing mode, which can both be used to query its current status, and set a watcher to watch for entering and/or leaving the private mode.
If for some reason, you don't want to make your extension dependent on nsIPrivateBrowsingService (for example, when developing an extension to support both Firefox and Thunderbird, where the private browsing service is not available), you can use the <tt>private-browsing-query</tt> notification to query the current status of the private browsing mode.  In order to use this notification, a nsISupportsPRBool object must be passed as the subject parameter.  The private browsing service, if available, will handle this notification and return the status as a boolean value in the subject parameter.  If the private browsing service is not available, the boolean value remains <tt>false</tt>.  A sample of using this notification appears in the code samples below.


==Code Samples==
==Code Samples==
Confirmed users
657

edits