b=395004. p=paul.rouget, r=mfinkle, dtownsend, gavin, a=mconnor. Add enaled property to FUEL Extension object
b=395004. p=paul.rouget, r=mfinkle, dtownsend, gavin, a=mconnor. Add enaled property to FUEL Extension object
--- a/browser/fuel/public/fuelIApplication.idl
+++ b/browser/fuel/public/fuelIApplication.idl
@@ -280,16 +280,21 @@ interface fuelIExtension : nsISupports
readonly attribute AString id;
/**
* The name of the extension.
*/
readonly attribute AString name;
/**
+ * Check if the extension is currently enabled, or not.
+ */
+ readonly attribute boolean enabled;
+
+ /**
* The version number of the extension.
*/
readonly attribute AString version;
/**
* Indicates whether this is the extension's first run after install
*/
readonly attribute boolean firstRun;
--- a/browser/fuel/src/fuelApplication.js
+++ b/browser/fuel/src/fuelApplication.js
@@ -396,16 +396,29 @@ function Extension(aItem) {
this._events = new Events();
var installPref = "install-event-fired";
if (!this._prefs.has(installPref)) {
this._prefs.setValue(installPref, true);
this._firstRun = true;
}
+ this._enabled = false;
+ const PREFIX_ITEM_URI = "urn:mozilla:item:";
+ const PREFIX_NS_EM = "http://www.mozilla.org/2004/em-rdf#";
+ var rdf = Cc["@mozilla.org/rdf/rdf-service;1"].getService(Ci.nsIRDFService);
+ var itemResource = rdf.GetResource(PREFIX_ITEM_URI + this._item.id);
+ if (itemResource) {
+ var extmgr = Cc["@mozilla.org/extensions/manager;1"].getService(Ci.nsIExtensionManager);
+ var ds = extmgr.datasource;
+ var target = ds.GetTarget(itemResource, rdf.GetResource(PREFIX_NS_EM + "isDisabled"), true);
+ if (target && target instanceof Ci.nsIRDFLiteral)
+ this._enabled = (target.Value != "true");
+ }
+
var os = Components.classes["@mozilla.org/observer-service;1"]
.getService(Ci.nsIObserverService);
os.addObserver(this, "em-action-requested", false);
var self = this;
gShutdown.push(function(){ self._shutdown(); });
}
@@ -444,16 +457,20 @@ Extension.prototype = {
get id() {
return this._item.id;
},
get name() {
return this._item.name;
},
+ get enabled() {
+ return this._enabled;
+ },
+
get version() {
return this._item.version;
},
get firstRun() {
return this._firstRun;
},
--- a/browser/fuel/test/browser_Extensions.js
+++ b/browser/fuel/test/browser_Extensions.js
@@ -17,16 +17,17 @@ function test() {
ok(Application.extensions.has(testdata.inspectorid), "Check extension for existance");
var inspector = Application.extensions.get(testdata.inspectorid);
is(inspector.id, testdata.inspectorid, "Check 'Extension.id' for known extension");
is(inspector.name, testdata.inspectorname, "Check 'Extension.name' for known extension");
// The known version number changes too frequently to hardcode in
ok(inspector.version, "Check 'Extension.version' for known extension");
ok(inspector.firstRun, "Check 'Extension.firstRun' for known extension");
+ ok(inspector.enabled, "Check 'Extension.enabled' for known extension");
// test to see if extension find works
is(Application.extensions.all.length, 1, "Check a find for all extensions");
// STORAGE TESTING
// Make sure the we are given the same extension (cached) so things like .storage work right
inspector.storage.set("test", "simple check");
ok(inspector.storage.has("test"), "Checking that extension storage worked");