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 | |
michael@0 | 5 | "use strict"; |
michael@0 | 6 | |
michael@0 | 7 | module.metadata = { |
michael@0 | 8 | "stability": "experimental" |
michael@0 | 9 | }; |
michael@0 | 10 | |
michael@0 | 11 | const { Cc, Ci } = require("chrome"); |
michael@0 | 12 | |
michael@0 | 13 | const io = Cc['@mozilla.org/network/io-service;1']. |
michael@0 | 14 | getService(Ci.nsIIOService); |
michael@0 | 15 | |
michael@0 | 16 | const SHEET_TYPE = { |
michael@0 | 17 | "agent": "AGENT_SHEET", |
michael@0 | 18 | "user": "USER_SHEET", |
michael@0 | 19 | "author": "AUTHOR_SHEET" |
michael@0 | 20 | }; |
michael@0 | 21 | |
michael@0 | 22 | function getDOMWindowUtils(window) { |
michael@0 | 23 | return window.QueryInterface(Ci.nsIInterfaceRequestor). |
michael@0 | 24 | getInterface(Ci.nsIDOMWindowUtils); |
michael@0 | 25 | }; |
michael@0 | 26 | |
michael@0 | 27 | /** |
michael@0 | 28 | * Synchronously loads a style sheet from `uri` and adds it to the list of |
michael@0 | 29 | * additional style sheets of the document. |
michael@0 | 30 | * The sheets added takes effect immediately, and only on the document of the |
michael@0 | 31 | * `window` given. |
michael@0 | 32 | */ |
michael@0 | 33 | function loadSheet(window, url, type) { |
michael@0 | 34 | if (!(type && type in SHEET_TYPE)) |
michael@0 | 35 | type = "author"; |
michael@0 | 36 | |
michael@0 | 37 | type = SHEET_TYPE[type]; |
michael@0 | 38 | |
michael@0 | 39 | if (!(url instanceof Ci.nsIURI)) |
michael@0 | 40 | url = io.newURI(url, null, null); |
michael@0 | 41 | |
michael@0 | 42 | let winUtils = getDOMWindowUtils(window); |
michael@0 | 43 | try { |
michael@0 | 44 | winUtils.loadSheet(url, winUtils[type]); |
michael@0 | 45 | } |
michael@0 | 46 | catch (e) {}; |
michael@0 | 47 | }; |
michael@0 | 48 | exports.loadSheet = loadSheet; |
michael@0 | 49 | |
michael@0 | 50 | /** |
michael@0 | 51 | * Remove the document style sheet at `sheetURI` from the list of additional |
michael@0 | 52 | * style sheets of the document. The removal takes effect immediately. |
michael@0 | 53 | */ |
michael@0 | 54 | function removeSheet(window, url, type) { |
michael@0 | 55 | if (!(type && type in SHEET_TYPE)) |
michael@0 | 56 | type = "author"; |
michael@0 | 57 | |
michael@0 | 58 | type = SHEET_TYPE[type]; |
michael@0 | 59 | |
michael@0 | 60 | if (!(url instanceof Ci.nsIURI)) |
michael@0 | 61 | url = io.newURI(url, null, null); |
michael@0 | 62 | |
michael@0 | 63 | let winUtils = getDOMWindowUtils(window); |
michael@0 | 64 | |
michael@0 | 65 | try { |
michael@0 | 66 | winUtils.removeSheet(url, winUtils[type]); |
michael@0 | 67 | } |
michael@0 | 68 | catch (e) {}; |
michael@0 | 69 | }; |
michael@0 | 70 | exports.removeSheet = removeSheet; |
michael@0 | 71 | |
michael@0 | 72 | /** |
michael@0 | 73 | * Returns `true` if the `type` given is valid, otherwise `false`. |
michael@0 | 74 | * The values currently accepted are: "agent", "user" and "author". |
michael@0 | 75 | */ |
michael@0 | 76 | function isTypeValid(type) { |
michael@0 | 77 | return type in SHEET_TYPE; |
michael@0 | 78 | } |
michael@0 | 79 | exports.isTypeValid = isTypeValid; |