views:

46

answers:

1

Firefox extensions can invoke privileged APIs (e.g. nsIProcess to start an external app) without bugging the user, for example this extension does it from the download window: https://addons.mozilla.org/en-US/firefox/addon/10902/

I need to do the same kind of thing, but from a UI on a web page. Can an extension provide a XUL widget (which calls the privileged APIs via a component module) that I can instantiate in the page DOM? Or do I need to write a plugin?

+2  A: 

I believe this is what you're looking for: https://developer.mozilla.org/en/Code_snippets/Interaction_between_privileged_and_non-privileged_pages

As that page says, there are security risks involved with this, so be careful.

MatrixFrog
@sdwilsh: What do you mean it will prompt the user? I've been using the technique described on that page, firing a custom event from a webpage and listening for it from the privileged code in my extension, without any user prompts. Am I misunderstanding you?
MatrixFrog
My bad - looked at the wrong tab that still managed to have context to this question I guess (enablePrivledge). This answer is in fact the right way to do this!
sdwilsh
That's indeed what I needed to know! And here's the extension I've built: https://addons.mozilla.org/en-US/firefox/addon/240637/
Liam