addon-sdk/source/lib/sdk/panel/window.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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

mercurial