diff options
author | Kris Maglione <maglione.k@gmail.com> | 2011-05-31 17:34:47 -0400 |
---|---|---|
committer | Kris Maglione <maglione.k@gmail.com> | 2011-05-31 17:34:47 -0400 |
commit | 7d019560be3782ddb3e31e0602bd014e7bc0e88d (patch) | |
tree | ad7c750ca3846719e5738f1abbd8760aa3d0e44f /common/modules | |
parent | 1632e5d594e2d3a10237b90cc087af3b92cf82af (diff) | |
download | pentadactyl-7d019560be3782ddb3e31e0602bd014e7bc0e88d.tar.gz |
Fix Firefox freakout. Closes issue #463.
Diffstat (limited to 'common/modules')
-rw-r--r-- | common/modules/addons.jsm | 39 | ||||
-rw-r--r-- | common/modules/contexts.jsm | 4 |
2 files changed, 26 insertions, 17 deletions
diff --git a/common/modules/addons.jsm b/common/modules/addons.jsm index a22b2842..74ce3cf6 100644 --- a/common/modules/addons.jsm +++ b/common/modules/addons.jsm @@ -500,27 +500,14 @@ else addon = this.wrapAddon(addon); return callback(addon); }, + wrapAddon: function wrapAddon(addon) { addon = Object.create(addon.QueryInterface(Ci.nsIUpdateItem)); - function getRdfProperty(item, property) { - let resource = services.rdf.GetResource("urn:mozilla:item:" + item.id); - let value = ""; - - if (resource) { - let target = services.extensionManager.datasource.GetTarget(resource, - services.rdf.GetResource("http://www.mozilla.org/2004/em-rdf#" + property), true); - if (target && target instanceof Ci.nsIRDFLiteral) - value = target.Value; - } - - return value; - } - ["aboutURL", "creator", "description", "developers", "homepageURL", "installDate", "optionsURL", "releaseNotesURI", "updateDate"].forEach(function (item) { - memoize(addon, item, function (item) getRdfProperty(this, item)); + memoize(addon, item, function (item) this.getProperty(item)); }); update(addon, { @@ -529,19 +516,33 @@ else appDisabled: false, + getProperty: function getProperty(property) { + let resource = services.rdf.GetResource("urn:mozilla:item:" + this.id); + + if (resource) { + let target = services.extensionManager.datasource.GetTarget(resource, + services.rdf.GetResource("http://www.mozilla.org/2004/em-rdf#" + property), true); + + if (target && target instanceof Ci.nsIRDFLiteral) + return target.Value; + } + + return ""; + }, + installLocation: Class.memoize(function () services.extensionManager.getInstallLocation(this.id)), getResourceURI: function getResourceURI(path) { let file = this.installLocation.getItemFile(this.id, path); return services.io.newFileURI(file); }, - isActive: getRdfProperty(addon, "isDisabled") != "true", + get isActive() this.getProperty("isDisabled") != "true", uninstall: function uninstall() { services.extensionManager.uninstallItem(this.id); }, - get userDisabled() getRdfProperty(addon, "userDisabled") === "true", + get userDisabled() this.getProperty("userDisabled") === "true", set userDisabled(val) { services.extensionManager[val ? "disableItem" : "enableItem"](this.id); } @@ -549,6 +550,7 @@ else return addon; }, + getAddonsByTypes: function (types, callback) { let res = []; for (let [, type] in Iterator(types)) @@ -560,6 +562,7 @@ else util.timeout(function () { callback(res); }); return res; }, + getInstallForFile: function (file, callback, mimetype) { callback({ addListener: function () {}, @@ -568,9 +571,11 @@ else } }); }, + getInstallForURL: function (url, callback, mimetype) { util.assert(false, _("error.unavailable", config.host, services.runtime.version)); }, + observers: [], addAddonListener: function (listener) { observer.listener = listener; diff --git a/common/modules/contexts.jsm b/common/modules/contexts.jsm index 523033de..8d883a06 100644 --- a/common/modules/contexts.jsm +++ b/common/modules/contexts.jsm @@ -372,6 +372,7 @@ var Contexts = Module("contexts", { let rhs = args.literalArg; let type = ["-builtin", "-ex", "-javascript", "-keys"].reduce(function (a, b) args[b] ? b : a, default_); + switch (type) { case "-builtin": let noremap = true; @@ -385,6 +386,7 @@ var Contexts = Module("contexts", { } action.macro = util.compileMacro(rhs, true); break; + case "-ex": action = function action() modules.commands .execute(action.macro, makeParams(this, arguments), @@ -392,6 +394,7 @@ var Contexts = Module("contexts", { action.macro = util.compileMacro(rhs, true); action.context = this.context && update({}, this.context); break; + case "-javascript": if (callable(params)) action = dactyl.userEval("(function action() { with (action.makeParams(this, arguments)) {" + args.literalArg + "} })"); @@ -402,6 +405,7 @@ var Contexts = Module("contexts", { action.makeParams = makeParams; break; } + action.toString = function toString() (type === default_ ? "" : type + " ") + rhs; args = null; return action; |