简体   繁体   中英

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?

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

您可以使用nsIProcess启动进程,将其写入已知位置,然后使用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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM