3.27.2008

First Step: What is a Mozilla Firefox Plugin?

A Mozilla Firefox plugin is a binary component that, when it's registered with Firefox, can display contents that Firefox itself can't display natively. Plugins are written using NPAPI, the cross-browser API for plugins.

In this case, the Inferno plugin has to let Firefox to execute .dis files, in order to do it, it has to run a minimal Inferno O.S. acting as a virtual machine that will execute .dis files.

The main source of information about Mozilla Plugins is the GECKO Plugin API Reference.

It's impossible to summarize how to write a plugin, and this is not my intention, so I recommend you to read the API Reference and the Plugin Basics chapter, however I will give you some basics: The plugin is loaded into the Firefox memory, and executes within the main thread of the browser, so if you want to allocate memory you have to ask Firefox for memory through the NPN_MemAlloc and many other browser-side functions. In the Gecko API there are two kind of functions, on the one hand you can find the functions that firefox offers to be called by the plugin, the NPN functions, and on the other hand there are the functions that the plugin must implement, the NPP functions, these are the functions offered by the plugin to the browser, and these functions tell the browser how to draw the plugin, how to initialize, and let the browser to ask for plugin information or give event handling to the plugin.

Once I have downloaded and compiled the Mozilla Firefox source tree, I have built my own plugin development environment, this is , I have imported the Mozilla neccesary files from the source tree and I have written the stub of the plugin. Then I have a basic plugin that implements all the necessary NPP functions in order to let Firefox to recognice the Inferno plugin as a right Gecko plugin.