b=395004. p=paul.rouget, r=mfinkle, dtownsend, gavin, a=mconnor. Add enaled property to FUEL Extension object
authormark.finkle@gmail.com
Fri, 28 Sep 2007 16:49:45 -0700
changeset 6424 c0b1cdb429aa1cbff9e88c63562b6f20b32a8600
parent 6423 f25005b7f50884e1c4aa4cc266a40e43d7349aa8
child 6425 76cfc68c3bcc9b42f75d28e3d4498209e98cd5ba
push id1
push userbsmedberg@mozilla.com
push dateThu, 20 Mar 2008 16:49:24 +0000
treeherdermozilla-central@61007906a1f8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle, dtownsend, gavin, mconnor
bugs395004
milestone1.9a9pre
b=395004. p=paul.rouget, r=mfinkle, dtownsend, gavin, a=mconnor. Add enaled property to FUEL Extension object
browser/fuel/public/fuelIApplication.idl
browser/fuel/src/fuelApplication.js
browser/fuel/test/browser_Extensions.js
--- 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");