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