However, in some situations, I need to be able to perform alert, prompt, ... If I override nsIPrompt.idl for instance, I can decide whether or not I must fake the dialog. In case I should not, is there a way to call the former interface ?

Anyway, I have something that almost works. I created a component with nsIPromptService CID and "@mozilla.org/embedcomp/prompt-service;1" ID. Just before registering this component, I get the former prompt service and store it. If I do so after registration, I get into a stack overflow.

Humm, in fact, it does not work so well ...

I did not realize the registration only occurs once in the extension's life. So, catching the previous service before registration only works the first time I run firefox with my extension.

So, accessing the prompt service with:
var legacyService =
        Components.classes["@mozilla.org/embedcomp/prompt-service;1"].
                getService(Components.interfaces.nsIPromptService)
... does not work because I get my own service object.

>> Anyway, if you want to forward this to the previously registered
>> component, just get it by CID.

I don't really understand "get it by CID". Is it different from what I do ?

Another alternative would be to create a new interface and service as a clone of nsIPromptService. So that I can call it from my own prompt service version without the risk of recursion. The drawback is that the original nsPromptService is written in C++, and I would like to avoid code that needs to be compiled on several platforms. So far, I could develop my extension in JS only.

I could rewrite the whole prompt service in JS, but this is a bit of work and it may lead to compatibility problems with further versions of firefox. However, this is my best option so far unless someone gives me a better idea.

Cheers,
/mig

_______________________________________________
dev-tech-xpcom mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-xpcom

Reply via email to