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.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | 'use strict'; |
michael@0 | 5 | |
michael@0 | 6 | module.metadata = { |
michael@0 | 7 | 'stability': 'deprecated' |
michael@0 | 8 | }; |
michael@0 | 9 | |
michael@0 | 10 | const { WindowTracker } = require('./deprecated/window-utils'); |
michael@0 | 11 | const { isXULBrowser } = require('./window/utils'); |
michael@0 | 12 | const { add, remove } = require('./util/array'); |
michael@0 | 13 | const { getTabs, closeTab, getURI } = require('./tabs/utils'); |
michael@0 | 14 | const { data } = require('./self'); |
michael@0 | 15 | const { ns } = require("./core/namespace"); |
michael@0 | 16 | |
michael@0 | 17 | const addonURL = data.url('index.html'); |
michael@0 | 18 | |
michael@0 | 19 | const windows = ns(); |
michael@0 | 20 | |
michael@0 | 21 | require("./util/deprecate").deprecateUsage( |
michael@0 | 22 | "The addon-page module is deprecated." + |
michael@0 | 23 | "In the new Firefox UI design all pages will include navigational elements;" + |
michael@0 | 24 | "once the new design ships, using the addon-page module will not have any effect." |
michael@0 | 25 | ); |
michael@0 | 26 | |
michael@0 | 27 | WindowTracker({ |
michael@0 | 28 | onTrack: function onTrack(window) { |
michael@0 | 29 | if (!isXULBrowser(window) || windows(window).hideChromeForLocation) |
michael@0 | 30 | return; |
michael@0 | 31 | |
michael@0 | 32 | let { XULBrowserWindow } = window; |
michael@0 | 33 | let { hideChromeForLocation } = XULBrowserWindow; |
michael@0 | 34 | |
michael@0 | 35 | windows(window).hideChromeForLocation = hideChromeForLocation; |
michael@0 | 36 | |
michael@0 | 37 | // Augmenting the behavior of `hideChromeForLocation` method, as |
michael@0 | 38 | // suggested by https://developer.mozilla.org/en-US/docs/Hiding_browser_chrome |
michael@0 | 39 | XULBrowserWindow.hideChromeForLocation = function(url) { |
michael@0 | 40 | return isAddonURL(url) || hideChromeForLocation.call(this, url); |
michael@0 | 41 | } |
michael@0 | 42 | }, |
michael@0 | 43 | |
michael@0 | 44 | onUntrack: function onUntrack(window) { |
michael@0 | 45 | if (isXULBrowser(window)) |
michael@0 | 46 | getTabs(window).filter(tabFilter).forEach(untrackTab.bind(null, window)); |
michael@0 | 47 | } |
michael@0 | 48 | }); |
michael@0 | 49 | |
michael@0 | 50 | function isAddonURL(url) { |
michael@0 | 51 | if (url.indexOf(addonURL) === 0) { |
michael@0 | 52 | let rest = url.substr(addonURL.length); |
michael@0 | 53 | return ((rest.length === 0) || (['#','?'].indexOf(rest.charAt(0)) > -1)); |
michael@0 | 54 | } |
michael@0 | 55 | return false; |
michael@0 | 56 | } |
michael@0 | 57 | |
michael@0 | 58 | function tabFilter(tab) { |
michael@0 | 59 | return isAddonURL(getURI(tab)); |
michael@0 | 60 | } |
michael@0 | 61 | |
michael@0 | 62 | function untrackTab(window, tab) { |
michael@0 | 63 | // Note: `onUntrack` will be called for all windows on add-on unloads, |
michael@0 | 64 | // so we want to clean them up from these URLs. |
michael@0 | 65 | let { hideChromeForLocation } = windows(window); |
michael@0 | 66 | |
michael@0 | 67 | if (hideChromeForLocation) { |
michael@0 | 68 | window.XULBrowserWindow.hideChromeForLocation = hideChromeForLocation.bind(window.XULBrowserWindow); |
michael@0 | 69 | windows(window).hideChromeForLocation = null; |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | closeTab(tab); |
michael@0 | 73 | } |