2012-07-03 07:35:03 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2012-10-31 09:13:28 -07:00
|
|
|
this.EXPORTED_SYMBOLS = ["PrivateBrowsingUtils"];
|
2012-07-03 07:35:03 -07:00
|
|
|
|
2012-10-16 15:06:38 -07:00
|
|
|
Components.utils.import("resource://gre/modules/Services.jsm");
|
|
|
|
|
2012-11-07 11:07:35 -08:00
|
|
|
const kAutoStartPref = "browser.privatebrowsing.autostart";
|
|
|
|
|
|
|
|
// This will be set to true when the PB mode is autostarted from the command
|
|
|
|
// line for the current session.
|
|
|
|
let gTemporaryAutoStartMode = false;
|
2012-10-16 15:06:38 -07:00
|
|
|
|
2012-10-09 17:34:59 -07:00
|
|
|
const Cc = Components.classes;
|
2012-07-03 07:35:03 -07:00
|
|
|
const Ci = Components.interfaces;
|
|
|
|
|
2012-10-31 09:13:28 -07:00
|
|
|
this.PrivateBrowsingUtils = {
|
2012-07-03 07:35:03 -07:00
|
|
|
isWindowPrivate: function pbu_isWindowPrivate(aWindow) {
|
2012-10-25 11:17:35 -07:00
|
|
|
return this.privacyContextFromWindow(aWindow).usePrivateBrowsing;
|
|
|
|
},
|
|
|
|
|
|
|
|
privacyContextFromWindow: function pbu_privacyContextFromWindow(aWindow) {
|
2012-07-03 07:35:03 -07:00
|
|
|
return aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
|
|
|
|
.getInterface(Ci.nsIWebNavigation)
|
2012-10-25 11:17:35 -07:00
|
|
|
.QueryInterface(Ci.nsILoadContext);
|
2012-10-09 17:34:59 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
get permanentPrivateBrowsing() {
|
2013-02-26 08:31:35 -08:00
|
|
|
try {
|
|
|
|
return gTemporaryAutoStartMode ||
|
|
|
|
Services.prefs.getBoolPref(kAutoStartPref);
|
|
|
|
} catch (e) {
|
|
|
|
// The pref does not exist
|
|
|
|
return false;
|
|
|
|
}
|
2012-11-07 11:07:35 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
// These should only be used from internal code
|
|
|
|
enterTemporaryAutoStartMode: function pbu_enterTemporaryAutoStartMode() {
|
|
|
|
gTemporaryAutoStartMode = true;
|
|
|
|
},
|
|
|
|
get isInTemporaryAutoStartMode() {
|
|
|
|
return gTemporaryAutoStartMode;
|
2012-07-03 07:35:03 -07:00
|
|
|
}
|
|
|
|
};
|
2012-10-16 15:06:38 -07:00
|
|
|
|