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