b=395004. p=paul.rouget, r=mfinkle, dtownsend, gavin, a=mconnor. Add enaled property to FUEL Extension object

This commit is contained in:
mark.finkle%gmail.com 2007-09-28 23:49:45 +00:00
Родитель 84cfc2b32a
Коммит 72224ec6c5
3 изменённых файлов: 23 добавлений и 0 удалений

Просмотреть файл

@ -284,6 +284,11 @@ interface fuelIExtension : nsISupports
*/
readonly attribute AString name;
/**
* Check if the extension is currently enabled, or not.
*/
readonly attribute boolean enabled;
/**
* The version number of the extension.
*/

Просмотреть файл

@ -401,6 +401,19 @@ function Extension(aItem) {
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);
@ -449,6 +462,10 @@ Extension.prototype = {
return this._item.name;
},
get enabled() {
return this._enabled;
},
get version() {
return this._item.version;
},

Просмотреть файл

@ -22,6 +22,7 @@ function test() {
// 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");