Search code examples
xulfirefox-addonxpcom

Including XPCOM inFirefox extension


I have a very limited experience with Firefox extensions development (read XUL School, written a couple of very simple extensions).

I now need some functionality that is not available through Firefox XPCOM objects, namely running an external process and reading its stdout. It seems that this can be done using Protozilla. So my problems becomes now to include this external XPCOM object in my XPI so that it will be available to my extension.

I should make clear that my problem is NOT how to build an XPCOM object, since I already have their builds and if I need to change something I already have their makefiles. My problem is: what do I do now? My extensions tree look like

/
-->chrome/
-->-->content
-->-->-->browserOverlay.js
-->-->-->...
-->-->locale
-->-->-->en-US
-->-->-->-->browserOverlay.dtd
-->-->-->-->browserOverlay.properties
-->-->-->...
-->-->skin
-->-->-->...
-->defaults/
-->-->preferences/
-->-->-->my_extension.js
-->modules/
-->-->common.js
-->chrome.manifest
-->install.rdf

Where should I include the XPCOM files? Do I need to do something to tell Firefox that a new XPCOM object is available?


Solution

  • From Mozilla developer center,

    XPCOM Components

    Firefox supports XPCOM components in extensions. You can create your own components easily in JavaScript or in C++ (using the Gecko SDK).

    Place all of your .js or .dll files in the components/ directory - they are automatically registered the first time Firefox runs after your extension is installed.

    https://developer.mozilla.org/en/building_an_extension