Merge pull request #2498 from ehsan/pbcleanup
Simplify ChromeActions.isInPrivateBrowsing to not rely on the global PB service
This commit is contained in:
commit
24204cc153
@ -198,28 +198,7 @@ function ChromeActions(domWindow, contentDispositionFilename) {
|
|||||||
|
|
||||||
ChromeActions.prototype = {
|
ChromeActions.prototype = {
|
||||||
isInPrivateBrowsing: function() {
|
isInPrivateBrowsing: function() {
|
||||||
var docIsPrivate, privateBrowsing;
|
return PrivateBrowsingUtils.isWindowPrivate(this.domWindow);
|
||||||
try {
|
|
||||||
docIsPrivate = PrivateBrowsingUtils.isWindowPrivate(this.domWindow);
|
|
||||||
} catch (x) {
|
|
||||||
// unable to use PrivateBrowsingUtils, e.g. FF15
|
|
||||||
}
|
|
||||||
if (typeof docIsPrivate === 'undefined') {
|
|
||||||
// per-window Private Browsing is not supported, trying global service
|
|
||||||
try {
|
|
||||||
privateBrowsing = Cc['@mozilla.org/privatebrowsing;1']
|
|
||||||
.getService(Ci.nsIPrivateBrowsingService);
|
|
||||||
docIsPrivate = privateBrowsing.privateBrowsingEnabled;
|
|
||||||
} catch (x) {
|
|
||||||
// unable to get nsIPrivateBrowsingService (e.g. not Firefox)
|
|
||||||
docIsPrivate = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// caching the result
|
|
||||||
this.isInPrivateBrowsing = function isInPrivateBrowsingCached() {
|
|
||||||
return docIsPrivate;
|
|
||||||
};
|
|
||||||
return docIsPrivate;
|
|
||||||
},
|
},
|
||||||
download: function(data, sendResponse) {
|
download: function(data, sendResponse) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user