Search code examples
firefox-addonnpapifirefox-addon-sdkfirebreath

Embedding NPAPI plugin in background using just Firefox Addon SDK


I have recently developed a NPAPI plugin (using FireBreath) in combination with a Google Chrome Extension. I am embedding the plugin using the background.html page and access it from multiple extension pages. Thus, the plugin remains loaded in the background page (until the extension is unloaded or the browser is closed).

I am now searching for the easiest way to port this extension to Firefox. Using the Addon SDK and it's API, i can reproduce the communication between the addon code and HTML user interface.

As there is no such global background DOM as in the Chrome Extension, how would I load the NPAPI plugin just once, without inserting it in every page of the app UI?

I've seen that using a XUL overlay would allow that - is there a way using just the addon sdk?


Edit: I've created an answer to this question with a minimal solution to this problem using page-workers.


Solution

  • You'll want to look at the page-worker module:

    https://addons.mozilla.org/en-US/developers/docs/sdk/1.8/packages/addon-kit/page-worker.html

    The caveat I would give is that the NPAPI plugin might have made assumptions about visibility or other details of the environment it is running in that simply don't apply in the page-worker environment. If you run into errors, I'd be interested to hear them!