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