Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Sharing an XPCOM component between two extensions

3 views
Skip to first unread message

James Moschou

unread,
Apr 15, 2009, 1:48:04 AM4/15/09
to dev-ext...@lists.mozilla.org
Hi,

I want to make two extensions that make use of the same component, but
I want either extension to be able to be installed independently of
the other, but not necessarily exclusive of each other. I want to
avoid making one extension dependent on the other. Is there a way for
me to make them both use the same XPCOM component (with the same CID
contractID etc.). The component is a service that does background
scanning, so I don't want to have two duplicate instances running in
case they conflict.

Is this possible?

Thanks,
James.

Eric Jung

unread,
Apr 15, 2009, 11:44:12 AM4/15/09
to dev-ext...@lists.mozilla.org

Hi,

There are probably two way to do this, maybe more.

1. Include the identical component in both extensions. Be sure to use the
same contract ID, GUID, etc. The first extension to be installed will
successfully register the component. Subsequent extension installations with
the same XPCOM component will fail registration of that component, but that
is not a fatal error for your extension. Life continues and the original
component is used by both extensions :) You should test this to be sure, but
I'm fairly certain that is how things will behave.

2. You can do something like what jslib does:
http://jslib.mozdev.org
http://jslib.mozdev.org/docs.html#using_in_app
package your XPCOM component in its own XPI

Also take a look em:requires in install.rdf:
https://developer.mozilla.org/en/Install_Manifests#requires

Note that <em:requires/> doesn't download and install the XPI for the user
automatically.

Eric

James Moschou

unread,
Apr 16, 2009, 1:38:46 AM4/16/09
to dev-ext...@lists.mozilla.org
Thanks, I think I'll try the first way, and see if I can put some
extra stuff into NSGetModule or similar to do some checks so it won't
error.

-James

2009/4/16 Eric Jung <eric...@yahoo.com>:

> _______________________________________________
> dev-extensions mailing list
> dev-ext...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-extensions
>

0 new messages