toolkit/components/contentprefs/ContentPrefInstance.jsm

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/components/contentprefs/ContentPrefInstance.jsm	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,74 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +'use strict';
     1.9 +
    1.10 +const Cc = Components.classes;
    1.11 +const Ci = Components.interfaces;
    1.12 +
    1.13 +this.EXPORTED_SYMBOLS = ['ContentPrefInstance'];
    1.14 +
    1.15 +// This is a wrapper for nsIContentPrefService that alleviates the need to pass
    1.16 +// an nsILoadContext argument to every method. Pass the context to the constructor
    1.17 +// instead and continue on your way in blissful ignorance.
    1.18 +
    1.19 +this.ContentPrefInstance = function ContentPrefInstance(aContext) {
    1.20 +  this._contentPrefSvc = Cc["@mozilla.org/content-pref/service;1"].
    1.21 +                           getService(Ci.nsIContentPrefService);
    1.22 +  this._context = aContext;
    1.23 +};
    1.24 +
    1.25 +ContentPrefInstance.prototype = {
    1.26 +  getPref: function ContentPrefInstance_init(aName, aGroup, aCallback) {
    1.27 +    return this._contentPrefSvc.getPref(aName, aGroup, this._context, aCallback);
    1.28 +  },
    1.29 +
    1.30 +  setPref: function ContentPrefInstance_setPref(aGroup, aName, aValue) {
    1.31 +    return this._contentPrefSvc.setPref(aGroup, aName, aValue, this._context);
    1.32 +  },
    1.33 +
    1.34 +  hasPref: function ContentPrefInstance_hasPref(aGroup, aName) {
    1.35 +    return this._contentPrefSvc.hasPref(aGroup, aName, this._context);
    1.36 +  },
    1.37 +
    1.38 +  hasCachedPref: function ContentPrefInstance_hasCachedPref(aGroup, aName) {
    1.39 +    return this._contentPrefSvc.hasCachedPref(aGroup, aName, this._context);
    1.40 +  },
    1.41 +
    1.42 +  removePref: function ContentPrefInstance_removePref(aGroup, aName) {
    1.43 +    return this._contentPrefSvc.removePref(aGroup, aName, this._context);
    1.44 +  },
    1.45 +
    1.46 +  removeGroupedPrefs: function ContentPrefInstance_removeGroupedPrefs() {
    1.47 +    return this._contentPrefSvc.removeGroupedPrefs(this._context);
    1.48 +  },
    1.49 +
    1.50 +  removePrefsByName: function ContentPrefInstance_removePrefsByName(aName) {
    1.51 +    return this._contentPrefSvc.removePrefsByName(aName, this._context);
    1.52 +  },
    1.53 +
    1.54 +  getPrefs: function ContentPrefInstance_getPrefs(aGroup) {
    1.55 +    return this._contentPrefSvc.getPrefs(aGroup, this._context);
    1.56 +  },
    1.57 +
    1.58 +  getPrefsByName: function ContentPrefInstance_getPrefsByName(aName) {
    1.59 +    return this._contentPrefSvc.getPrefsByName(aName, this._context);
    1.60 +  },
    1.61 +
    1.62 +  addObserver: function ContentPrefInstance_addObserver(aName, aObserver) {
    1.63 +    return this._contentPrefSvc.addObserver(aName, aObserver);
    1.64 +  },
    1.65 +
    1.66 +  removeObserver: function ContentPrefInstance_removeObserver(aName, aObserver) {
    1.67 +    return this._contentPrefSvc.removeObserver(aName, aObserver);
    1.68 +  },
    1.69 +
    1.70 +  get grouper() {
    1.71 +    return this._contentPrefSvc.grouper;
    1.72 +  },
    1.73 +
    1.74 +  get DBConnection() {
    1.75 +    return this._contentPrefSvc.DBConnection;
    1.76 +  }
    1.77 +};

mercurial