michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: 'use strict'; michael@0: michael@0: const Cc = Components.classes; michael@0: const Ci = Components.interfaces; michael@0: michael@0: this.EXPORTED_SYMBOLS = ['ContentPrefInstance']; michael@0: michael@0: // This is a wrapper for nsIContentPrefService that alleviates the need to pass michael@0: // an nsILoadContext argument to every method. Pass the context to the constructor michael@0: // instead and continue on your way in blissful ignorance. michael@0: michael@0: this.ContentPrefInstance = function ContentPrefInstance(aContext) { michael@0: this._contentPrefSvc = Cc["@mozilla.org/content-pref/service;1"]. michael@0: getService(Ci.nsIContentPrefService); michael@0: this._context = aContext; michael@0: }; michael@0: michael@0: ContentPrefInstance.prototype = { michael@0: getPref: function ContentPrefInstance_init(aName, aGroup, aCallback) { michael@0: return this._contentPrefSvc.getPref(aName, aGroup, this._context, aCallback); michael@0: }, michael@0: michael@0: setPref: function ContentPrefInstance_setPref(aGroup, aName, aValue) { michael@0: return this._contentPrefSvc.setPref(aGroup, aName, aValue, this._context); michael@0: }, michael@0: michael@0: hasPref: function ContentPrefInstance_hasPref(aGroup, aName) { michael@0: return this._contentPrefSvc.hasPref(aGroup, aName, this._context); michael@0: }, michael@0: michael@0: hasCachedPref: function ContentPrefInstance_hasCachedPref(aGroup, aName) { michael@0: return this._contentPrefSvc.hasCachedPref(aGroup, aName, this._context); michael@0: }, michael@0: michael@0: removePref: function ContentPrefInstance_removePref(aGroup, aName) { michael@0: return this._contentPrefSvc.removePref(aGroup, aName, this._context); michael@0: }, michael@0: michael@0: removeGroupedPrefs: function ContentPrefInstance_removeGroupedPrefs() { michael@0: return this._contentPrefSvc.removeGroupedPrefs(this._context); michael@0: }, michael@0: michael@0: removePrefsByName: function ContentPrefInstance_removePrefsByName(aName) { michael@0: return this._contentPrefSvc.removePrefsByName(aName, this._context); michael@0: }, michael@0: michael@0: getPrefs: function ContentPrefInstance_getPrefs(aGroup) { michael@0: return this._contentPrefSvc.getPrefs(aGroup, this._context); michael@0: }, michael@0: michael@0: getPrefsByName: function ContentPrefInstance_getPrefsByName(aName) { michael@0: return this._contentPrefSvc.getPrefsByName(aName, this._context); michael@0: }, michael@0: michael@0: addObserver: function ContentPrefInstance_addObserver(aName, aObserver) { michael@0: return this._contentPrefSvc.addObserver(aName, aObserver); michael@0: }, michael@0: michael@0: removeObserver: function ContentPrefInstance_removeObserver(aName, aObserver) { michael@0: return this._contentPrefSvc.removeObserver(aName, aObserver); michael@0: }, michael@0: michael@0: get grouper() { michael@0: return this._contentPrefSvc.grouper; michael@0: }, michael@0: michael@0: get DBConnection() { michael@0: return this._contentPrefSvc.DBConnection; michael@0: } michael@0: };