Code: Select all
function isExtensionEnabled(extId)
{
var extMgr = Cc["@mozilla.org/extensions/manager;1"].getService(Ci.nsIExtensionManager);
var extMgrDs = extMgr.datasource;
var ext = extMgr.getItemForID(extId);
if (! ext)
return false;
var rdfSvc = Cc["@mozilla.org/rdf/rdf-service;1"].getService(Ci.nsIRDFService);
var source = rdfSvc.GetResource("urn:mozilla:item:" + ext.id);
var property = rdfSvc.GetResource("http://www.mozilla.org/2004/em-rdf#userDisabled");
var target = rdfSvc.GetLiteral("true");
var disabled = extMgrDs.HasAssertion(source, property, target, true);
return (! disabled);
}
But is that 'userDisabled' enough? While googling, I found code that used other properties (appDisabled, disabled and isDisabled) but didn't find any documentation about any of them.
Or if there's a simpler way (non-RDF) to do this, let me know.