Skip to content Skip to sidebar Skip to footer

How To Overwrite Built In XPCOM Component In Firefox Addon?

I'm taking a foray into Firefox extension development for the first time, and so far it's been pretty comfortable going, but I'm running into a problem; one of the things I need to

Solution 1:

Neil, thanks for the suggestion. That's what I thought I was doing (and I was), but if you're actually overriding a contract (instead of defining a new one), it looks like the answer is that you have to go to the nsIComponentRegistrar and actually register your factory (rather than relying on the chrome.manifest to handle it for you). An example of this would be:

Components.manager.nsIComponentRegistrar.registerFactory(CLASS_ID, CLASS_NAME, CONTRACT_ID, MyPromptServiceFactory);

Where the constans were:

const CLASS_ID = Components.ID("{a2112d6a-0e28-421f-b46a-25c0b308cbd0}");

// description
const CLASS_NAME = "My Prompt Service";

// textual unique identifier
const CONTRACT_ID = "@mozilla.org/embedcomp/prompt-service;1";

Where the CLASS_ID/CONTRACT_ID were the IDs for the pre-existing service.


Solution 2:

You need to register your component using the contract id of the service that you want to override.


Post a Comment for "How To Overwrite Built In XPCOM Component In Firefox Addon?"