Including XPCOM inFirefox extension
I have a ve开发者_如何学JAVAry 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?
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
You could use nsIProcess to launch the process, have it write to a known location, and then read from that file using nsIFile.
Protozilla has derived in this: http://mozilla-enigmail.org/ipc/ you can find xulrunner enabled binaries there that should allow you to invoke external processes.
The code has been included into the Mozilla codebase (after 10 years, see https://bugzilla.mozilla.org/show_bug.cgi?id=68702 and http://hg.mozilla.org/ipccode/), but it's not available in Firefox 4, as far as I can tell.
精彩评论