This post is about how to take the npruntime code sample that I have blogged about and install it as a chrome extension.
In this series of articles I have provided the code to build a simple NPAPI plugin. The next steps are to register the plugin with Firefox and Google chrome so we can test the code.
Firefox install
To install a plugin on Firefox under windows you need to use the registry. That is the most reliable method to install the plugin.
The registry keys used to install the plugin are located in the HKey Local Machine (HKLM) registry hive, so administrative permissions will be required to install the plugin.
Windows Registry Editor Version 5.00 ; for 32 bit installations [HKEY_LOCAL_MACHINE\SOFTWARE\MozillaPlugins\@conedogers.wordpress.com/npruntime,version=1.0.0.3] "Path"="npruntime.dll" "ProductName"="npruntime" "Vendor"="conedogers.wordpress.com" "Version"="1.0.0.3" ; for 64 bit OS installation [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\MozillaPlugins\@conedogers.wordpress.com/npruntime,version=1.0.0.3] "Path"="npruntime.dll" "ProductName"="npruntime" "Vendor"="conedogers.wordpress.com" "Version"="1.0.0.3"
The path should be the absolute path to the npruntime dll.
Google Chrome installation
Installation on chrome is almost as easy. Google has added a few steps to package the NPAPI control as an extension. This extension can either display the plugin publicly, which could expose the client browser to security threats, or you can make the plugin private which only allows your script to access the plugin.
To begin, we need to create a manifest file manifest.json in a sub-folder that is named for the extension. For this sample, there is a sub-folder installers\Chrome. Inside this sub-folder we have a folder named npruntime. Inside this folder we place all the files needed for the chrome extension.
- icon.png
- manifest.json
- npruntime.dll
The manifest.json file should look like this:
{
"name":"npruntime",
"version":"1.0.0.3 ",
"manifest_version":2,
"description":"Mozilla npRuntime sample",
"browser_action":{
"default_icon":"icon.png"
},
"plugins": [
{ "path":"npruntime.dll", "public" : true}
]
}
package the plugin
The first step of installing the chrome extension is to create the CRX package. To do this you need to navigate to the Chrome://extensions page and select the developer mode by selecting the checkbox in the upper right hand corner. Once you have enabled developer mode, select the pack extension button.

Select the folder where the we have the nanifest.json file.

Now we package the control and create a crx package that we can use to deploy to chrome. The second parameter is a path to your private key file used to provide a certified package. For this sample, leave it blank

When we succeed with the packaging, we will have the npruntime.crx and npruntime.pem file. DO NOT lose the pem file! this is a key assigned by chrome that is a key assigned to the control.
Retrieving the Extension ID
Now that you have the packaged extension you need to retrieve the extension ID. To do this, you open the Chrome://extensions page and in the developer section select the “Load unpacked extension…” button. You will be prompted to select the control to load, so navigate to the installers\chrome folder and select the npruntime folder to load it into chrome.

After you load the unpacked extension, you will see a screen similar to this. Highlighted is the extension ID assigned to this control.
Now that you have the extension ID, you can complete the registration of the packaged NPAPI control by adding a pair of registry keys to the windows registry.
Windows Registry Editor Version 5.00 ; 32 bit operating systems. [HKEY_LOCAL_MACHINE\SOFTWARE\Google\Chrome\Extensions\ooaihagiflmbfpeiggpknanhplcngmld] "Path"="C:\\dev\\mozilla\\npruntime\\installers\\chrome\\npruntime\\npruntime.dll" "Version"="1.0.0.3" ; 64 bit operating systems [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Google\Chrome\Extensions\ooaihagiflmbfpeiggpknanhplcngmld] "Path"="C:\\dev\\mozilla\\npruntime\\installers\\chrome\\npruntime\\npruntime.dll" "Version"="1.0.0.3"
And that should do it. You should be able to view the chrome NPAPI extension in the test.html file provided with the sample.
Source code for this project is available on github: https://github.com/chrisDwarner/npruntimeSampleCode


























































