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 } = require('chrome'); |
michael@0 | 11 | const { Class } = require('../core/heritage'); |
michael@0 | 12 | const { EventTarget } = require('../event/target'); |
michael@0 | 13 | const { Branch } = require('./service'); |
michael@0 | 14 | const { emit, off } = require('../event/core'); |
michael@0 | 15 | const { when: unload } = require('../system/unload'); |
michael@0 | 16 | |
michael@0 | 17 | const prefTargetNS = require('../core/namespace').ns(); |
michael@0 | 18 | |
michael@0 | 19 | const PrefsTarget = Class({ |
michael@0 | 20 | extends: EventTarget, |
michael@0 | 21 | initialize: function(options) { |
michael@0 | 22 | options = options || {}; |
michael@0 | 23 | EventTarget.prototype.initialize.call(this, options); |
michael@0 | 24 | |
michael@0 | 25 | let branchName = options.branchName || ''; |
michael@0 | 26 | let branch = Cc["@mozilla.org/preferences-service;1"]. |
michael@0 | 27 | getService(Ci.nsIPrefService). |
michael@0 | 28 | getBranch(branchName). |
michael@0 | 29 | QueryInterface(Ci.nsIPrefBranch2); |
michael@0 | 30 | prefTargetNS(this).branch = branch; |
michael@0 | 31 | |
michael@0 | 32 | // provides easy access to preference values |
michael@0 | 33 | this.prefs = Branch(branchName); |
michael@0 | 34 | |
michael@0 | 35 | // start listening to preference changes |
michael@0 | 36 | let observer = prefTargetNS(this).observer = onChange.bind(this); |
michael@0 | 37 | branch.addObserver('', observer, false); |
michael@0 | 38 | |
michael@0 | 39 | // Make sure to destroy this on unload |
michael@0 | 40 | unload(destroy.bind(this)); |
michael@0 | 41 | } |
michael@0 | 42 | }); |
michael@0 | 43 | exports.PrefsTarget = PrefsTarget; |
michael@0 | 44 | |
michael@0 | 45 | /* HELPERS */ |
michael@0 | 46 | |
michael@0 | 47 | function onChange(subject, topic, name) { |
michael@0 | 48 | if (topic === 'nsPref:changed') { |
michael@0 | 49 | emit(this, name, name); |
michael@0 | 50 | emit(this, '', name); |
michael@0 | 51 | } |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | function destroy() { |
michael@0 | 55 | off(this); |
michael@0 | 56 | |
michael@0 | 57 | // stop listening to preference changes |
michael@0 | 58 | let branch = prefTargetNS(this).branch; |
michael@0 | 59 | branch.removeObserver('', prefTargetNS(this).observer, false); |
michael@0 | 60 | prefTargetNS(this).observer = null; |
michael@0 | 61 | } |