addon-sdk/source/lib/sdk/windows/observer.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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 { EventEmitterTrait: EventEmitter } = require("../deprecated/events");
michael@0 11 const { WindowTracker, windowIterator } = require("../deprecated/window-utils");
michael@0 12 const { DOMEventAssembler } = require("../deprecated/events/assembler");
michael@0 13 const { Trait } = require("../deprecated/light-traits");
michael@0 14
michael@0 15 // Event emitter objects used to register listeners and emit events on them
michael@0 16 // when they occur.
michael@0 17 const observer = Trait.compose(DOMEventAssembler, EventEmitter).create({
michael@0 18 /**
michael@0 19 * Method is implemented by `EventEmitter` and is used just for emitting
michael@0 20 * events on registered listeners.
michael@0 21 */
michael@0 22 _emit: Trait.required,
michael@0 23 /**
michael@0 24 * Events that are supported and emitted by the module.
michael@0 25 */
michael@0 26 supportedEventsTypes: [ "activate", "deactivate" ],
michael@0 27 /**
michael@0 28 * Function handles all the supported events on all the windows that are
michael@0 29 * observed. Method is used to proxy events to the listeners registered on
michael@0 30 * this event emitter.
michael@0 31 * @param {Event} event
michael@0 32 * Keyboard event being emitted.
michael@0 33 */
michael@0 34 handleEvent: function handleEvent(event) {
michael@0 35 this._emit(event.type, event.target, event);
michael@0 36 }
michael@0 37 });
michael@0 38
michael@0 39 // Using `WindowTracker` to track window events.
michael@0 40 WindowTracker({
michael@0 41 onTrack: function onTrack(chromeWindow) {
michael@0 42 observer._emit("open", chromeWindow);
michael@0 43 observer.observe(chromeWindow);
michael@0 44 },
michael@0 45 onUntrack: function onUntrack(chromeWindow) {
michael@0 46 observer._emit("close", chromeWindow);
michael@0 47 observer.ignore(chromeWindow);
michael@0 48 }
michael@0 49 });
michael@0 50
michael@0 51 exports.observer = observer;

mercurial