Bug 1004395 - Uplift Add-on SDK to Firefox r=me
This commit is contained in:
@@ -16,6 +16,7 @@ const { deprecateFunction } = require('../util/deprecate');
|
||||
const { isOneOf, is, satisfiesVersion, version } = require('../system/xul-app');
|
||||
const { isWindowPrivate } = require('../window/utils');
|
||||
const { isPrivateBrowsingSupported } = require('../self');
|
||||
const { dispatcher } = require("../util/dispatcher");
|
||||
|
||||
let deferredEmit = defer(emit);
|
||||
let pbService;
|
||||
@@ -53,10 +54,11 @@ let isWindowPBSupported = exports.isWindowPBSupported =
|
||||
let isTabPBSupported = exports.isTabPBSupported =
|
||||
!pbService && !!PrivateBrowsingUtils && is('Fennec') && satisfiesVersion(version, '>=20.0*');
|
||||
|
||||
exports.isPermanentPrivateBrowsing = function() {
|
||||
function isPermanentPrivateBrowsing() {
|
||||
return !!(PrivateBrowsingUtils && PrivateBrowsingUtils.permanentPrivateBrowsing);
|
||||
}
|
||||
|
||||
exports.isPermanentPrivateBrowsing = isPermanentPrivateBrowsing;
|
||||
|
||||
function ignoreWindow(window) {
|
||||
return !isPrivateBrowsingSupported && isWindowPrivate(window) && !isGlobalPBSupported;
|
||||
}
|
||||
@@ -90,14 +92,25 @@ exports.setMode = deprecateFunction(
|
||||
);
|
||||
|
||||
let getMode = function getMode(chromeWin) {
|
||||
if (isWindowPrivate(chromeWin))
|
||||
if (chromeWin !== undefined && isWindowPrivate(chromeWin))
|
||||
return true;
|
||||
|
||||
// default
|
||||
return pbService ? pbService.privateBrowsingEnabled : false;
|
||||
return isGlobalPrivateBrowsing();
|
||||
};
|
||||
exports.getMode = getMode;
|
||||
|
||||
function isGlobalPrivateBrowsing() {
|
||||
return pbService ? pbService.privateBrowsingEnabled : false;
|
||||
}
|
||||
|
||||
const isPrivate = dispatcher("isPrivate");
|
||||
isPrivate.when(isPermanentPrivateBrowsing, _ => true);
|
||||
isPrivate.when(x => x instanceof Ci.nsIDOMWindow, isWindowPrivate);
|
||||
isPrivate.when(x => Ci.nsIPrivateBrowsingChannel && x instanceof Ci.nsIPrivateBrowsingChannel, x => x.isChannelPrivate);
|
||||
isPrivate.define(isGlobalPrivateBrowsing);
|
||||
exports.isPrivate = isPrivate;
|
||||
|
||||
exports.on = on.bind(null, exports);
|
||||
|
||||
// Make sure listeners are cleaned up.
|
||||
|
||||
Reference in New Issue
Block a user