Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 'use strict';
6 module.metadata = {
7 'stability': 'deprecated'
8 };
10 const { WindowTracker } = require('./deprecated/window-utils');
11 const { isXULBrowser } = require('./window/utils');
12 const { add, remove } = require('./util/array');
13 const { getTabs, closeTab, getURI } = require('./tabs/utils');
14 const { data } = require('./self');
15 const { ns } = require("./core/namespace");
17 const addonURL = data.url('index.html');
19 const windows = ns();
21 require("./util/deprecate").deprecateUsage(
22 "The addon-page module is deprecated." +
23 "In the new Firefox UI design all pages will include navigational elements;" +
24 "once the new design ships, using the addon-page module will not have any effect."
25 );
27 WindowTracker({
28 onTrack: function onTrack(window) {
29 if (!isXULBrowser(window) || windows(window).hideChromeForLocation)
30 return;
32 let { XULBrowserWindow } = window;
33 let { hideChromeForLocation } = XULBrowserWindow;
35 windows(window).hideChromeForLocation = hideChromeForLocation;
37 // Augmenting the behavior of `hideChromeForLocation` method, as
38 // suggested by https://developer.mozilla.org/en-US/docs/Hiding_browser_chrome
39 XULBrowserWindow.hideChromeForLocation = function(url) {
40 return isAddonURL(url) || hideChromeForLocation.call(this, url);
41 }
42 },
44 onUntrack: function onUntrack(window) {
45 if (isXULBrowser(window))
46 getTabs(window).filter(tabFilter).forEach(untrackTab.bind(null, window));
47 }
48 });
50 function isAddonURL(url) {
51 if (url.indexOf(addonURL) === 0) {
52 let rest = url.substr(addonURL.length);
53 return ((rest.length === 0) || (['#','?'].indexOf(rest.charAt(0)) > -1));
54 }
55 return false;
56 }
58 function tabFilter(tab) {
59 return isAddonURL(getURI(tab));
60 }
62 function untrackTab(window, tab) {
63 // Note: `onUntrack` will be called for all windows on add-on unloads,
64 // so we want to clean them up from these URLs.
65 let { hideChromeForLocation } = windows(window);
67 if (hideChromeForLocation) {
68 window.XULBrowserWindow.hideChromeForLocation = hideChromeForLocation.bind(window.XULBrowserWindow);
69 windows(window).hideChromeForLocation = null;
70 }
72 closeTab(tab);
73 }