Revision 103685 of Supporting private browsing mode

  • Revision slug: Supporting_private_browsing_mode
  • Revision title: Supporting private browsing mode
  • Revision id: 103685
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment 74 words added

Revision Content

{{ fx_minversion_header("3") }}

{{ draft() }}

Firefox 3.1 introduced private browsing mode, in which potentially private information is not recorded.  This includes cookies, history information, download information, and so forth.

Extensions that may record potentially private information may wish to hook into the private browsing service so that they can avoid saving personal information when private browsing mode is enabled.  Doing this is quite easy, using the {{ interface("nsIPrivateBrowsingService") }} interface.

Detecting private browsing mode

Determining whether or not the user is currently in private browsing mode is simple.  Just check the value of the privateBrowsingEnabled attribute on the {{ interface("nsIPrivateBrowsingService") }} service.

var pbs = Components.classes["@mozilla.org/privatebrowsing;1"]
                    .getService(Components.interfaces.nsIPrivateBrowsingService);
var inPrivateBrowsingMode = pbs.privateBrowsingEnabled;

if (!inPrivateBrowsingMode)

See also

  • {{ interface("nsIPrivateBrowsingService") }}

 

Revision Source

<p>{{ fx_minversion_header("3") }}</p>
<p>{{ draft() }}</p>
<p>Firefox 3.1 introduced private browsing mode, in which potentially private information is not recorded.  This includes cookies, history information, download information, and so forth.</p>
<p>Extensions that may record potentially private information may wish to hook into the private browsing service so that they can avoid saving personal information when private browsing mode is enabled.  Doing this is quite easy, using the {{ interface("nsIPrivateBrowsingService") }} interface.</p>
<h2>Detecting private browsing mode</h2>
<p>Determining whether or not the user is currently in private browsing mode is simple.  Just check the value of the <code>privateBrowsingEnabled</code> attribute on the {{ interface("nsIPrivateBrowsingService") }} service.</p>
<pre>var pbs = Components.classes["@mozilla.org/privatebrowsing;1"]
                    .getService(Components.interfaces.nsIPrivateBrowsingService);
var inPrivateBrowsingMode = pbs.privateBrowsingEnabled;

if (!inPrivateBrowsingMode)

</pre>
<h2>See also</h2>
<ul> <li>{{ interface("nsIPrivateBrowsingService") }}</li>
</ul>
<p> </p>
Revert to this revision