aboutConfigPrefs.js (1022B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 "use strict"; 6 7 /* global ExtensionAPI, ExtensionCommon, Services */ 8 9 this.aboutConfigPrefs = class extends ExtensionAPI { 10 getAPI(context) { 11 const extensionIDBase = context.extension.id.split("@")[0]; 12 const extensionPrefNameBase = `extensions.${extensionIDBase}.`; 13 14 return { 15 aboutConfigPrefs: { 16 async setPref(name, value) { 17 const fullName = `${extensionPrefNameBase}${name}`; 18 switch (typeof value) { 19 case "boolean": 20 Services.prefs.setBoolPref(fullName, value); 21 break; 22 case "number": 23 Services.prefs.setIntPref(fullName, value); 24 break; 25 case "string": 26 Services.prefs.setStringPref(fullName, value); 27 break; 28 } 29 }, 30 }, 31 }; 32 } 33 };