Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: Javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* vim: set ft=javascript ts=2 et sw=2 tw=80: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | const {Cc, Ci, Cu, Cr} = require("chrome"); |
michael@0 | 8 | |
michael@0 | 9 | Cu.import("resource://gre/modules/Services.jsm"); |
michael@0 | 10 | Cu.import("resource://gre/modules/devtools/event-emitter.js"); |
michael@0 | 11 | |
michael@0 | 12 | exports.PREF_ORIG_SOURCES = "devtools.styleeditor.source-maps-enabled"; |
michael@0 | 13 | |
michael@0 | 14 | /** |
michael@0 | 15 | * A PreferenceObserver observes a pref branch for pref changes. |
michael@0 | 16 | * It emits an event for each preference change. |
michael@0 | 17 | */ |
michael@0 | 18 | function PrefObserver(branchName) { |
michael@0 | 19 | this.branchName = branchName; |
michael@0 | 20 | this.branch = Services.prefs.getBranch(branchName); |
michael@0 | 21 | this.branch.addObserver("", this, false); |
michael@0 | 22 | |
michael@0 | 23 | EventEmitter.decorate(this); |
michael@0 | 24 | } |
michael@0 | 25 | |
michael@0 | 26 | exports.PrefObserver = PrefObserver; |
michael@0 | 27 | |
michael@0 | 28 | PrefObserver.prototype = { |
michael@0 | 29 | observe: function(subject, topic, data) { |
michael@0 | 30 | if (topic == "nsPref:changed") { |
michael@0 | 31 | this.emit(this.branchName + data); |
michael@0 | 32 | } |
michael@0 | 33 | }, |
michael@0 | 34 | |
michael@0 | 35 | destroy: function() { |
michael@0 | 36 | if (this.branch) { |
michael@0 | 37 | this.branch.removeObserver('', this); |
michael@0 | 38 | } |
michael@0 | 39 | } |
michael@0 | 40 | }; |