1 /* vim: set ts=2 sw=2 sts=2 et tw=80: */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 export function ContentPref(domain, name, value) {
12 ContentPref.prototype = {
13 QueryInterface: ChromeUtils.generateQI(["nsIContentPref"]),
16 export function cbHandleResult(callback, pref) {
17 safeCallback(callback, "handleResult", [pref]);
20 export function cbHandleCompletion(callback, reason) {
21 safeCallback(callback, "handleCompletion", [reason]);
24 export function cbHandleError(callback, nsresult) {
25 safeCallback(callback, "handleError", [nsresult]);
28 export function safeCallback(callbackObj, methodName, args) {
29 if (!callbackObj || typeof callbackObj[methodName] != "function") {
33 callbackObj[methodName].apply(callbackObj, args);
39 export const _methodsCallableFromChild = Object.freeze([
40 ["getByName", ["name", "context", "callback"]],
41 ["getByDomainAndName", ["domain", "name", "context", "callback"]],
42 ["getBySubdomainAndName", ["domain", "name", "context", "callback"]],
43 ["getGlobal", ["name", "context", "callback"]],
44 ["set", ["domain", "name", "value", "context", "callback"]],
45 ["setGlobal", ["name", "value", "context", "callback"]],
46 ["removeByDomainAndName", ["domain", "name", "context", "callback"]],
47 ["removeBySubdomainAndName", ["domain", "name", "context", "callback"]],
48 ["removeGlobal", ["name", "context", "callback"]],
49 ["removeByDomain", ["domain", "context", "callback"]],
50 ["removeBySubdomain", ["domain", "context", "callback"]],
51 ["removeByName", ["name", "context", "callback"]],
52 ["removeAllDomains", ["context", "callback"]],
53 ["removeAllGlobals", ["context", "callback"]],