[Pkg-mozext-commits] [adblock-plus-element-hiding-helper] 229/483: Don't assume that the module will be a file

David Prévot taffit at moszumanska.debian.org
Thu Jan 22 21:41:44 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository adblock-plus-element-hiding-helper.

commit 9dee42511c2b36ba97905582ef885f6b5ee5949a
Author: Wladimir Palant <trev at adblockplus.org>
Date:   Fri Oct 22 10:29:29 2010 +0200

    Don't assume that the module will be a file
---
 components/Initializer.js  | 32 +++++++++++++++++++++++++-------
 modules/ABPIntegration.jsm |  6 +++---
 2 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/components/Initializer.js b/components/Initializer.js
index 5eaf1e8..3e58c5d 100644
--- a/components/Initializer.js
+++ b/components/Initializer.js
@@ -41,7 +41,30 @@ Initializer.prototype =
   classID: Components.ID("{2d53b96c-1dd2-11b2-94ad-dedbdb99852f}"),
   _xpcom_categories: [{ category: "app-startup", service: true }],
 
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
+  get _baseURI()
+  {
+    let chromeRegistry = Cc["@mozilla.org/chrome/chrome-registry;1"].getService(Ci.nsIChromeRegistry);
+    let ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
+
+    let baseURI = chromeRegistry.convertChromeURL(ioService.newURI("chrome://elemhidehelper-modules/content/nada", null, null));
+    baseURI.QueryInterface(Ci.nsIURL);
+    baseURI.fileName = "";
+    if (baseURI instanceof Ci.nsIMutable)
+      baseURI.mutable = false;
+
+    this.__defineGetter__("_baseURI", function() baseURI);
+    return this._baseURI;
+  },
+
+  _QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
+
+  QueryInterface: function(iid)
+  {
+    if (iid.equals(Ci.nsIURI) || iid.equals(Ci.nsIURL))
+      return this._baseURI;
+    else
+      return this._QueryInterface.apply(this, arguments);
+  },
 
   observe: function(subject, topic, data)
   {
@@ -54,12 +77,7 @@ Initializer.prototype =
         break;
       case "final-ui-startup":
         observerService.removeObserver(this, "final-ui-startup");
-
-        // Load the module
-        let chromeRegistry = Cc["@mozilla.org/chrome/chrome-registry;1"].getService(Ci.nsIChromeRegistry);
-        let ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
-        let moduleURL = chromeRegistry.convertChromeURL(ioService.newURI("chrome://elemhidehelper-modules/content/ABPIntegration.jsm", null, null));
-        Cu.import(moduleURL.spec);
+        Cu.import(this._baseURI.spec + "ABPIntegration.jsm");
         break;
     }
   }
diff --git a/modules/ABPIntegration.jsm b/modules/ABPIntegration.jsm
index 85f771f..502a3b0 100644
--- a/modules/ABPIntegration.jsm
+++ b/modules/ABPIntegration.jsm
@@ -83,11 +83,11 @@ let extensionManager = null;
  */
 function init()
 {
-  let ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
-  let uri = ioService.newFileURI(__LOCATION__);
+  let baseURI = Cc["@adblockplus.org/ehh/startup;1"].getService(Ci.nsIURI);
+  let moduleLocation = baseURI.spec + "ABPIntegration.jsm";
 
   let categoryManager = Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager);
-  categoryManager.addCategoryEntry("adblock-plus-module-location", uri.spec, uri.spec, false, true);
+  categoryManager.addCategoryEntry("adblock-plus-module-location", moduleLocation, moduleLocation, false, true);
 
   // Wait a minute before checking, just in case...
   timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus-element-hiding-helper.git



More information about the Pkg-mozext-commits mailing list