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 | // The panel module currently supports only Firefox. |
michael@0 | 7 | // See: https://bugzilla.mozilla.org/show_bug.cgi?id=jetpack-panel-apps |
michael@0 | 8 | module.metadata = { |
michael@0 | 9 | 'stability': 'unstable', |
michael@0 | 10 | 'engines': { |
michael@0 | 11 | 'Firefox': '*' |
michael@0 | 12 | } |
michael@0 | 13 | }; |
michael@0 | 14 | |
michael@0 | 15 | const { getMostRecentBrowserWindow, windows: getWindows } = require('../window/utils'); |
michael@0 | 16 | const { ignoreWindow } = require('../private-browsing/utils'); |
michael@0 | 17 | const { isPrivateBrowsingSupported } = require('../self'); |
michael@0 | 18 | const { isGlobalPBSupported } = require('../private-browsing/utils'); |
michael@0 | 19 | |
michael@0 | 20 | function getWindow(anchor) { |
michael@0 | 21 | let window; |
michael@0 | 22 | let windows = getWindows("navigator:browser", { |
michael@0 | 23 | includePrivate: isPrivateBrowsingSupported || isGlobalPBSupported |
michael@0 | 24 | }); |
michael@0 | 25 | |
michael@0 | 26 | if (anchor) { |
michael@0 | 27 | let anchorWindow = anchor.ownerDocument.defaultView.top; |
michael@0 | 28 | let anchorDocument = anchorWindow.document; |
michael@0 | 29 | |
michael@0 | 30 | // loop thru supported windows |
michael@0 | 31 | for each(let enumWindow in windows) { |
michael@0 | 32 | // Check if the anchor is in this browser window. |
michael@0 | 33 | if (enumWindow == anchorWindow) { |
michael@0 | 34 | window = anchorWindow; |
michael@0 | 35 | break; |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | // Check if the anchor is in a browser tab in this browser window. |
michael@0 | 39 | let browser = enumWindow.gBrowser.getBrowserForDocument(anchorDocument); |
michael@0 | 40 | if (browser) { |
michael@0 | 41 | window = enumWindow; |
michael@0 | 42 | break; |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | // Look in other subdocuments (sidebar, etc.)? |
michael@0 | 46 | } |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | // If we didn't find the anchor's window (or we have no anchor), |
michael@0 | 50 | // return the most recent browser window. |
michael@0 | 51 | if (!window) |
michael@0 | 52 | window = getMostRecentBrowserWindow(); |
michael@0 | 53 | |
michael@0 | 54 | // if the window is not supported, then it should be ignored |
michael@0 | 55 | if (ignoreWindow(window)) { |
michael@0 | 56 | return null; |
michael@0 | 57 | } |
michael@0 | 58 | |
michael@0 | 59 | return window; |
michael@0 | 60 | } |
michael@0 | 61 | exports.getWindow = getWindow; |