summaryrefslogtreecommitdiffstats
path: root/devtools/server/actors/preference.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /devtools/server/actors/preference.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/server/actors/preference.js')
-rw-r--r--devtools/server/actors/preference.js81
1 files changed, 81 insertions, 0 deletions
diff --git a/devtools/server/actors/preference.js b/devtools/server/actors/preference.js
new file mode 100644
index 000000000..8d4140155
--- /dev/null
+++ b/devtools/server/actors/preference.js
@@ -0,0 +1,81 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+const {Cc, Ci, Cu, CC} = require("chrome");
+const protocol = require("devtools/shared/protocol");
+const {Arg, method, RetVal} = protocol;
+const Services = require("Services");
+const {preferenceSpec} = require("devtools/shared/specs/preference");
+
+exports.register = function (handle) {
+ handle.addGlobalActor(PreferenceActor, "preferenceActor");
+};
+
+exports.unregister = function (handle) {
+};
+
+var PreferenceActor = exports.PreferenceActor = protocol.ActorClassWithSpec(preferenceSpec, {
+ typeName: "preference",
+
+ getBoolPref: function (name) {
+ return Services.prefs.getBoolPref(name);
+ },
+
+ getCharPref: function (name) {
+ return Services.prefs.getCharPref(name);
+ },
+
+ getIntPref: function (name) {
+ return Services.prefs.getIntPref(name);
+ },
+
+ getAllPrefs: function () {
+ let prefs = {};
+ Services.prefs.getChildList("").forEach(function (name, index) {
+ // append all key/value pairs into a huge json object.
+ try {
+ let value;
+ switch (Services.prefs.getPrefType(name)) {
+ case Ci.nsIPrefBranch.PREF_STRING:
+ value = Services.prefs.getCharPref(name);
+ break;
+ case Ci.nsIPrefBranch.PREF_INT:
+ value = Services.prefs.getIntPref(name);
+ break;
+ case Ci.nsIPrefBranch.PREF_BOOL:
+ value = Services.prefs.getBoolPref(name);
+ break;
+ default:
+ }
+ prefs[name] = {
+ value: value,
+ hasUserValue: Services.prefs.prefHasUserValue(name)
+ };
+ } catch (e) {
+ // pref exists but has no user or default value
+ }
+ });
+ return prefs;
+ },
+
+ setBoolPref: function (name, value) {
+ Services.prefs.setBoolPref(name, value);
+ Services.prefs.savePrefFile(null);
+ },
+
+ setCharPref: function (name, value) {
+ Services.prefs.setCharPref(name, value);
+ Services.prefs.savePrefFile(null);
+ },
+
+ setIntPref: function (name, value) {
+ Services.prefs.setIntPref(name, value);
+ Services.prefs.savePrefFile(null);
+ },
+
+ clearUserPref: function (name) {
+ Services.prefs.clearUserPref(name);
+ Services.prefs.savePrefFile(null);
+ },
+});