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/. */
4 'use strict';
6 module.metadata = {
7 'stability': 'unstable'
8 };
10 const { Cc, Ci, Cu } = require('chrome');
11 const AppShellService = Cc['@mozilla.org/appshell/appShellService;1'].
12 getService(Ci.nsIAppShellService);
14 const NS = 'http://www.w3.org/1999/xhtml';
15 const COLOR = 'rgb(255,255,255)';
17 /**
18 * Creates canvas element with a thumbnail of the passed window.
19 * @param {Window} window
20 * @returns {Element}
21 */
22 function getThumbnailCanvasForWindow(window) {
23 let aspectRatio = 0.5625; // 16:9
24 let thumbnail = AppShellService.hiddenDOMWindow.document
25 .createElementNS(NS, 'canvas');
26 thumbnail.mozOpaque = true;
27 thumbnail.width = Math.ceil(window.screen.availWidth / 5.75);
28 thumbnail.height = Math.round(thumbnail.width * aspectRatio);
29 let ctx = thumbnail.getContext('2d');
30 let snippetWidth = window.innerWidth * .6;
31 let scale = thumbnail.width / snippetWidth;
32 ctx.scale(scale, scale);
33 ctx.drawWindow(window, window.scrollX, window.scrollY, snippetWidth,
34 snippetWidth * aspectRatio, COLOR);
35 return thumbnail;
36 }
37 exports.getThumbnailCanvasForWindow = getThumbnailCanvasForWindow;
39 /**
40 * Creates Base64 encoded data URI of the thumbnail for the passed window.
41 * @param {Window} window
42 * @returns {String}
43 */
44 exports.getThumbnailURIForWindow = function getThumbnailURIForWindow(window) {
45 return getThumbnailCanvasForWindow(window).toDataURL()
46 };