mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-03-16 11:23:31 +01:00
Try not to break things on :rehash for users running from the repo.
This commit is contained in:
4
common/bootstrap.js
vendored
4
common/bootstrap.js
vendored
@@ -61,6 +61,10 @@ function startup(data, reason) {
|
|||||||
addon = data;
|
addon = data;
|
||||||
AddonManager.getAddonByID(addon.id, function (a) { addon = a; });
|
AddonManager.getAddonByID(addon.id, function (a) { addon = a; });
|
||||||
|
|
||||||
|
// Temporary hack.
|
||||||
|
if (basePath.isDirectory() && JSMLoader.bump == null)
|
||||||
|
JSMLoader.bump = 1;
|
||||||
|
|
||||||
if (basePath.isDirectory())
|
if (basePath.isDirectory())
|
||||||
getURI = function getURI(path) {
|
getURI = function getURI(path) {
|
||||||
let file = basePath.clone().QueryInterface(Ci.nsILocalFile);
|
let file = basePath.clone().QueryInterface(Ci.nsILocalFile);
|
||||||
|
|||||||
@@ -934,7 +934,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
* @param {number} level The logging level 0 - 15.
|
* @param {number} level The logging level 0 - 15.
|
||||||
*/
|
*/
|
||||||
log: function (msg, level) {
|
log: function (msg, level) {
|
||||||
let verbose = prefs.get("extensions.dactyl.loglevel", 0);
|
let verbose = localPrefs.get("loglevel", 0);
|
||||||
|
|
||||||
if (!level || level <= verbose) {
|
if (!level || level <= verbose) {
|
||||||
if (isObject(msg))
|
if (isObject(msg))
|
||||||
|
|||||||
@@ -334,9 +334,10 @@ function deprecated(reason, fn) {
|
|||||||
function deprecatedMethod() {
|
function deprecatedMethod() {
|
||||||
let frame = Components.stack.caller;
|
let frame = Components.stack.caller;
|
||||||
let obj = this.className || this.constructor.className;
|
let obj = this.className || this.constructor.className;
|
||||||
if (!set.add(deprecatedMethod.seen, frame.filename))
|
let filename = frame.filename.replace(/.* -> /, "");
|
||||||
|
if (!set.add(deprecatedMethod.seen, filename))
|
||||||
util.dactyl(fn).echoerr(
|
util.dactyl(fn).echoerr(
|
||||||
util.urlPath(frame.filename || "unknown") + ":" + frame.lineNumber + ": " +
|
util.urlPath(filename || "unknown") + ":" + frame.lineNumber + ": " +
|
||||||
(obj ? obj + "." : "") + (fn.name || name) + " is deprecated: " + reason);
|
(obj ? obj + "." : "") + (fn.name || name) + " is deprecated: " + reason);
|
||||||
return func.apply(this, arguments);
|
return func.apply(this, arguments);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
Components.utils.import("resource://dactyl/base.jsm");
|
Components.utils.import("resource://dactyl/base.jsm");
|
||||||
defineModule("prefs", {
|
defineModule("prefs", {
|
||||||
exports: ["Prefs", "prefs"],
|
exports: ["Prefs", "localPrefs", "prefs"],
|
||||||
require: ["services", "util"],
|
require: ["services", "util"],
|
||||||
use: ["config", "template"]
|
use: ["config", "template"]
|
||||||
});
|
});
|
||||||
@@ -16,20 +16,21 @@ defineModule("prefs", {
|
|||||||
var Prefs = Module("prefs", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), {
|
var Prefs = Module("prefs", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), {
|
||||||
SAVED: "extensions.dactyl.saved.",
|
SAVED: "extensions.dactyl.saved.",
|
||||||
RESTORE: "extensions.dactyl.restore.",
|
RESTORE: "extensions.dactyl.restore.",
|
||||||
|
INIT: {},
|
||||||
|
|
||||||
init: function () {
|
init: function (branch) {
|
||||||
this._prefContexts = [];
|
this._prefContexts = [];
|
||||||
|
|
||||||
util.addObserver(this);
|
util.addObserver(this);
|
||||||
this._branch = services.pref.getBranch("").QueryInterface(Ci.nsIPrefBranch2);
|
this.branch = services.pref.getBranch(branch || "").QueryInterface(Ci.nsIPrefBranch2);
|
||||||
this._branch.addObserver("", this, false);
|
this.branch.addObserver("", this, false);
|
||||||
this._observers = {};
|
this._observers = {};
|
||||||
|
|
||||||
this.restore();
|
this.restore();
|
||||||
},
|
},
|
||||||
|
|
||||||
cleanup: function cleanup() {
|
cleanup: function cleanup() {
|
||||||
this._branch.removeObserver("", this);
|
this.branch.removeObserver("", this);
|
||||||
},
|
},
|
||||||
|
|
||||||
observe: {
|
observe: {
|
||||||
@@ -123,7 +124,7 @@ var Prefs = Module("prefs", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
|||||||
* @param {string} branch The branch in which to search preferences.
|
* @param {string} branch The branch in which to search preferences.
|
||||||
* @default ""
|
* @default ""
|
||||||
*/
|
*/
|
||||||
getNames: function (branch) services.pref.getChildList(branch || "", { value: 0 }),
|
getNames: function (branch) this.branch.getChildList(branch || "", { value: 0 }),
|
||||||
|
|
||||||
_checkSafe: function (name, message, value) {
|
_checkSafe: function (name, message, value) {
|
||||||
let curval = this._load(name, null, false);
|
let curval = this._load(name, null, false);
|
||||||
@@ -208,7 +209,7 @@ var Prefs = Module("prefs", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
|||||||
*/
|
*/
|
||||||
reset: function (name) {
|
reset: function (name) {
|
||||||
try {
|
try {
|
||||||
services.pref.clearUserPref(name);
|
this.branch.clearUserPref(name);
|
||||||
}
|
}
|
||||||
catch (e) {} // ignore - thrown if not a user set value
|
catch (e) {} // ignore - thrown if not a user set value
|
||||||
},
|
},
|
||||||
@@ -219,7 +220,7 @@ var Prefs = Module("prefs", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
|||||||
* @param {string} name The preference name.
|
* @param {string} name The preference name.
|
||||||
*/
|
*/
|
||||||
toggle: function (name) {
|
toggle: function (name) {
|
||||||
util.assert(services.pref.getPrefType(name) === Ci.nsIPrefBranch.PREF_BOOL,
|
util.assert(this.branch.getPrefType(name) === Ci.nsIPrefBranch.PREF_BOOL,
|
||||||
"E488: Trailing characters: " + name + "!");
|
"E488: Trailing characters: " + name + "!");
|
||||||
this.set(name, !this.get(name));
|
this.set(name, !this.get(name));
|
||||||
},
|
},
|
||||||
@@ -276,24 +277,24 @@ var Prefs = Module("prefs", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
|||||||
? "E521: Number required after =: " + name + "=" + value
|
? "E521: Number required after =: " + name + "=" + value
|
||||||
: "E474: Invalid argument: " + name + "=" + value);
|
: "E474: Invalid argument: " + name + "=" + value);
|
||||||
|
|
||||||
let type = services.pref.getPrefType(name);
|
let type = this.branch.getPrefType(name);
|
||||||
switch (typeof value) {
|
switch (typeof value) {
|
||||||
case "string":
|
case "string":
|
||||||
assertType(Ci.nsIPrefBranch.PREF_STRING);
|
assertType(Ci.nsIPrefBranch.PREF_STRING);
|
||||||
|
|
||||||
let supportString = Cc["@mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString);
|
let supportString = Cc["@mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString);
|
||||||
supportString.data = value;
|
supportString.data = value;
|
||||||
services.pref.setComplexValue(name, Ci.nsISupportsString, supportString);
|
this.branch.setComplexValue(name, Ci.nsISupportsString, supportString);
|
||||||
break;
|
break;
|
||||||
case "number":
|
case "number":
|
||||||
assertType(Ci.nsIPrefBranch.PREF_INT);
|
assertType(Ci.nsIPrefBranch.PREF_INT);
|
||||||
|
|
||||||
services.pref.setIntPref(name, value);
|
this.branch.setIntPref(name, value);
|
||||||
break;
|
break;
|
||||||
case "boolean":
|
case "boolean":
|
||||||
assertType(Ci.nsIPrefBranch.PREF_BOOL);
|
assertType(Ci.nsIPrefBranch.PREF_BOOL);
|
||||||
|
|
||||||
services.pref.setBoolPref(name, value);
|
this.branch.setBoolPref(name, value);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw FailedAssertion("Unknown preference type: " + typeof value + " (" + name + "=" + value + ")");
|
throw FailedAssertion("Unknown preference type: " + typeof value + " (" + name + "=" + value + ")");
|
||||||
@@ -304,14 +305,14 @@ var Prefs = Module("prefs", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
|||||||
if (defaultValue == null)
|
if (defaultValue == null)
|
||||||
defaultValue = null;
|
defaultValue = null;
|
||||||
|
|
||||||
let branch = defaultBranch ? services.pref.getDefaultBranch("") : services.pref;
|
let branch = defaultBranch ? services.pref.getDefaultBranch(this.branch.root) : this.branch;
|
||||||
let type = services.pref.getPrefType(name);
|
let type = this.branch.getPrefType(name);
|
||||||
try {
|
try {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case Ci.nsIPrefBranch.PREF_STRING:
|
case Ci.nsIPrefBranch.PREF_STRING:
|
||||||
let value = branch.getComplexValue(name, Ci.nsISupportsString).data;
|
let value = branch.getComplexValue(name, Ci.nsISupportsString).data;
|
||||||
// try in case it's a localized string (will throw an exception if not)
|
// try in case it's a localized string (will throw an exception if not)
|
||||||
if (!services.pref.prefIsLocked(name) && !services.pref.prefHasUserValue(name) &&
|
if (!this.branch.prefIsLocked(name) && !this.branch.prefHasUserValue(name) &&
|
||||||
RegExp("chrome://.+/locale/.+\\.properties").test(value))
|
RegExp("chrome://.+/locale/.+\\.properties").test(value))
|
||||||
value = branch.getComplexValue(name, Ci.nsIPrefLocalizedString).data;
|
value = branch.getComplexValue(name, Ci.nsIPrefLocalizedString).data;
|
||||||
return value;
|
return value;
|
||||||
@@ -339,10 +340,13 @@ var Prefs = Module("prefs", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
|||||||
},
|
},
|
||||||
javascript: function (dactyl, modules) {
|
javascript: function (dactyl, modules) {
|
||||||
modules.JavaScript.setCompleter([this.get, this.safeSet, this.set, this.reset, this.toggle],
|
modules.JavaScript.setCompleter([this.get, this.safeSet, this.set, this.reset, this.toggle],
|
||||||
[function (context) (context.anchored=false, prefs.getNames().map(function (pref) [pref, ""]))]);
|
[function (context) (context.anchored=false, this.getNames().map(function (pref) [pref, ""]))]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var localPrefs = Prefs("extensions.dactyl.");
|
||||||
|
defineModule.modules.push(localPrefs);
|
||||||
|
|
||||||
endModule();
|
endModule();
|
||||||
|
|
||||||
// catch(e){dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack);}
|
// catch(e){dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack);}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ var Item = Class("Item", {
|
|||||||
shouldSanitize: function (shutdown) (!shutdown || this.builtin || this.persistent) &&
|
shouldSanitize: function (shutdown) (!shutdown || this.builtin || this.persistent) &&
|
||||||
prefs.get(shutdown ? this.shutdownPref : this.pref)
|
prefs.get(shutdown ? this.shutdownPref : this.pref)
|
||||||
}, {
|
}, {
|
||||||
PREFIX: "extensions.dactyl.",
|
PREFIX: localPrefs.branch.root,
|
||||||
BRANCH: "privacy.cpd.",
|
BRANCH: "privacy.cpd.",
|
||||||
SHUTDOWN_BRANCH: "privacy.clearOnShutdown."
|
SHUTDOWN_BRANCH: "privacy.clearOnShutdown."
|
||||||
});
|
});
|
||||||
@@ -261,8 +261,8 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
get ranAtShutdown() prefs.get(Item.PREFIX + "didSanitizeOnShutdown"),
|
get ranAtShutdown() localPrefs.get("didSanitizeOnShutdown"),
|
||||||
set ranAtShutdown(val) prefs.set(Item.PREFIX + "didSanitizeOnShutdown", Boolean(val)),
|
set ranAtShutdown(val) localPrefs.set("didSanitizeOnShutdown", Boolean(val)),
|
||||||
get runAtShutdown() prefs.get("privacy.sanitize.sanitizeOnShutdown"),
|
get runAtShutdown() prefs.get("privacy.sanitize.sanitizeOnShutdown"),
|
||||||
set runAtShutdown(val) prefs.set("privacy.sanitize.sanitizeOnShutdown", Boolean(val)),
|
set runAtShutdown(val) prefs.set("privacy.sanitize.sanitizeOnShutdown", Boolean(val)),
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user