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 | const { Ci } = require("chrome"); |
michael@0 | 7 | const { InputPort } = require("./system"); |
michael@0 | 8 | const { getFrameElement, getOuterId, |
michael@0 | 9 | getOwnerBrowserWindow } = require("../window/utils"); |
michael@0 | 10 | const { isnt } = require("../lang/functional"); |
michael@0 | 11 | const { foldp, lift, merges, keepIf } = require("../event/utils"); |
michael@0 | 12 | const { object } = require("../util/sequence"); |
michael@0 | 13 | const { compose } = require("../lang/functional"); |
michael@0 | 14 | const { LastClosed } = require("./browser"); |
michael@0 | 15 | const { patch } = require("diffpatcher/index"); |
michael@0 | 16 | |
michael@0 | 17 | const Document = Ci.nsIDOMDocument; |
michael@0 | 18 | |
michael@0 | 19 | const isntNull = isnt(null); |
michael@0 | 20 | |
michael@0 | 21 | const frameID = frame => frame.id; |
michael@0 | 22 | const browserID = compose(getOuterId, getOwnerBrowserWindow); |
michael@0 | 23 | |
michael@0 | 24 | const isInnerFrame = frame => |
michael@0 | 25 | frame && frame.hasAttribute("data-is-sdk-inner-frame"); |
michael@0 | 26 | |
michael@0 | 27 | // Utility function that given content window loaded in our frame views returns |
michael@0 | 28 | // an actual frame. This basically takes care of fact that actual frame document |
michael@0 | 29 | // is loaded in the nested iframe. If content window is not loaded in the nested |
michael@0 | 30 | // frame of the frame view it returs null. |
michael@0 | 31 | const getFrame = document => |
michael@0 | 32 | document && document.defaultView && getFrameElement(document.defaultView); |
michael@0 | 33 | |
michael@0 | 34 | const FrameInput = function(options) { |
michael@0 | 35 | const input = keepIf(isInnerFrame, null, |
michael@0 | 36 | lift(getFrame, new InputPort(options))); |
michael@0 | 37 | return lift(frame => { |
michael@0 | 38 | if (!frame) return frame; |
michael@0 | 39 | const [id, owner] = [frameID(frame), browserID(frame)]; |
michael@0 | 40 | return object([id, {owners: object([owner, options.update])}]); |
michael@0 | 41 | }, input); |
michael@0 | 42 | }; |
michael@0 | 43 | |
michael@0 | 44 | const LastLoading = new FrameInput({topic: "document-element-inserted", |
michael@0 | 45 | update: {readyState: "loading"}}); |
michael@0 | 46 | exports.LastLoading = LastLoading; |
michael@0 | 47 | |
michael@0 | 48 | const LastInteractive = new FrameInput({topic: "content-document-interactive", |
michael@0 | 49 | update: {readyState: "interactive"}}); |
michael@0 | 50 | exports.LastInteractive = LastInteractive; |
michael@0 | 51 | |
michael@0 | 52 | const LastLoaded = new FrameInput({topic: "content-document-loaded", |
michael@0 | 53 | update: {readyState: "complete"}}); |
michael@0 | 54 | exports.LastLoaded = LastLoaded; |
michael@0 | 55 | |
michael@0 | 56 | const LastUnloaded = new FrameInput({topic: "content-page-hidden", |
michael@0 | 57 | update: null}); |
michael@0 | 58 | exports.LastUnloaded = LastUnloaded; |
michael@0 | 59 | |
michael@0 | 60 | // Represents state of SDK frames in form of data structure: |
michael@0 | 61 | // {"frame#1": {"id": "frame#1", |
michael@0 | 62 | // "inbox": {"data": "ping", |
michael@0 | 63 | // "target": {"id": "frame#1", "owner": "outerWindowID#2"}, |
michael@0 | 64 | // "source": {"id": "frame#1"}} |
michael@0 | 65 | // "url": "resource://addon-1/data/index.html", |
michael@0 | 66 | // "owners": {"outerWindowID#1": {"readyState": "loading"}, |
michael@0 | 67 | // "outerWindowID#2": {"readyState": "complete"}} |
michael@0 | 68 | // |
michael@0 | 69 | // |
michael@0 | 70 | // frame#2: {"id": "frame#2", |
michael@0 | 71 | // "url": "resource://addon-1/data/main.html", |
michael@0 | 72 | // "outbox": {"data": "pong", |
michael@0 | 73 | // "source": {"id": "frame#2", "owner": "outerWindowID#1"} |
michael@0 | 74 | // "target": {"id": "frame#2"}} |
michael@0 | 75 | // "owners": {outerWindowID#1: {readyState: "interacitve"}}}} |
michael@0 | 76 | const Frames = foldp(patch, {}, merges([ |
michael@0 | 77 | LastLoading, |
michael@0 | 78 | LastInteractive, |
michael@0 | 79 | LastLoaded, |
michael@0 | 80 | LastUnloaded, |
michael@0 | 81 | new InputPort({ id: "frame-mailbox" }), |
michael@0 | 82 | new InputPort({ id: "frame-change" }), |
michael@0 | 83 | new InputPort({ id: "frame-changed" }) |
michael@0 | 84 | ])); |
michael@0 | 85 | exports.Frames = Frames; |