OLD | NEW |
(Empty) | |
| 1 <div id="pageData-title" class="pageData">NPAPI Plugins</div> |
| 2 |
| 3 <p> |
| 4 Leveraging HTML and JavaScript |
| 5 makes developing new extensions really easy, |
| 6 but what if you have existing legacy or proprietary code |
| 7 that you want to reuse in your extension? |
| 8 You can bundle an NPAPI plugin with your extension, |
| 9 allowing you to call into native binary code from JavaScript. |
| 10 </p> |
| 11 |
| 12 <h2>Details</h2> |
| 13 |
| 14 <p> |
| 15 How to develop an NPAPI plugin is outside the scope of this document. |
| 16 See <a href="https://developer.mozilla.org/en/Plugins">Mozilla's |
| 17 NPAPI plugin reference</a> for information on how to do that. |
| 18 </p> |
| 19 |
| 20 <p> |
| 21 Once you have an NPAPI plugin, |
| 22 follow these steps to get your extension using it. |
| 23 </p> |
| 24 |
| 25 <ol> |
| 26 <li> |
| 27 Add a section to your extension's <code>manifest.json</code> |
| 28 that describes where to find the plugin, |
| 29 along with other properties about it: |
| 30 |
| 31 <pre>{ |
| 32 "name": "My extension", |
| 33 ... |
| 34 "plugins": [ |
| 35 { "path": "content_plugin.dll", "public": true }, |
| 36 { "path": "extension_plugin.dll" } |
| 37 ] |
| 38 }</pre> |
| 39 |
| 40 <p> |
| 41 The "path" property specifies the path to your plugin, |
| 42 relative to the manifest file. |
| 43 The "public" property specifies whether |
| 44 your plugin can be accessed by regular web pages; |
| 45 the default is false, |
| 46 meaning only your extension can load the plugin. |
| 47 </p> |
| 48 </li> |
| 49 |
| 50 <li> |
| 51 Create an HTML file that loads your plugin by mime-type. |
| 52 Assuming your mime-type is "application/x-my-extension": |
| 53 |
| 54 <pre> |
| 55 <embed type="application/x-my-extension" id="pluginId"></embed> |
| 56 <script> |
| 57 var plugin = document.getElementById("pluginId"); |
| 58 var result = plugin.myPluginMethod(); // call a method in your plugin |
| 59 console.log("my plugin returned: " + result); |
| 60 </script></pre> |
| 61 |
| 62 <p> |
| 63 This can be inside a toolstrip, a background page, |
| 64 or any other HTML page used by your extension. |
| 65 If your plugin is "public", |
| 66 you can even use a content script to programmatically |
| 67 insert your plugin into a web page. |
| 68 </p> |
OLD | NEW |