mozilla

Revision 285846 of Préface

  • Raccourci de la révision : Gecko-API_Greffons/Préface
  • Titre de la révision : Gecko-API_Greffons/Préface
  • ID de la révision : 285846
  • Créé :
  • Créateur : Demos
  • Version actuelle ? Non
  • Commentaire page created, 1014 words added

Contenu de la révision

{{ Next("Gecko Plugin API Reference:Plug-in Basics") }} {{ Npapiref() }}

About this guide

The Gecko Plug-in API Reference describes the application programming interfaces (APIs) for Netscape Gecko plug-ins and provides information about how to use these interfaces to create plug-ins for Gecko-based applications such as Firefox, Mozilla, Netscape 6+, and others.

The general introduction in {{ Npapi-page("Plug-in Basics") }} and a chapter entitled {{ Npapi-page("Plug-in Development Overview") }} begin the guide. A series of chapters on specific programming topics such as {{ Npapi-page("Initialization and Destruction") }}, {{ Npapi-page("Streams") }}, and {{ Npapi-page("URLs") }} provide more detail about the technical aspects and techniques for creating and managing plug-ins.

The API reference in the second half of the guide is divided up into two main halves, {{ Npapi-page("Plug-in Side Plug-in API") }} and {{ Npapi-page("Browser Side Plug-in API") }}, as well as additional reference material about {{ Npapi-page("Structures") }} and {{ Npapi-page("Constants") }}.

The guide is structured so the developers new to Gecko plug-ins can familiarize themselves with the APIs and particular aspects of the development process (e.g., {{ Npapi-page("Drawing and Event Handling") }}), but so that plug-in developers can quickly access the API reference material they need.

Who should read this guide

The Gecko Plug-in API Reference is meant for plug-in developers. Though it provides a basic overview of plug-ins and how they work in the browser, the guide presumes that you understand how plug-ins work, how they handle and display media, and what the basic architecture of a browser is that supports the use of plug-in software.

The guide also presumes that you know how to use application programming interfaces, have experience developing browser software such as plug-ins, components, or add-ons, and are familiar with C/C++, the language(s) in which the libraries were actually created and in which all of the examples are given.

The Plug-in software development kit

A Plug-in software development kit (SDK) is available for Gecko plug-in developers. This SDK is located in the Mozilla source under {{ Source("modules/plugin/sdk/") }}. You can use it within the Mozilla source tree, or you can build it there and then use it outside of tree if you'd rather. In either case, the Mozilla source tree is required to get started developing plug-ins. You can also view the plug-in SDK samples and source code using the web-based source viewer: {{ Source("modules/plugin/sdk/") }}

The SDK is based on the API developed originally for Netscape browsers starting with Netscape 2.x. Some additions were made when Netscape 3.x and Netscape 4.x were released. The present SDK reflects major changes related to Mozilla code base: LiveConnect for plug-in scriptability is no longer supported, existing plug-ins should be modified slightly to become scriptable again; the browser services are now accessible from the plug-in through the access to the service manager.

The SDK is intended to help in creating full-blown plug-ins to work with the Mozilla code base without actually having the whole Mozilla source tree present and built.

The Common folder contains stub implementations of the NPAPI methods. There is no need to modify files in this folder, just include them into your project. This is not necessary though, some samples or plug-in projects may use their own implementations, the files in this folder are just an illustration of one possible way to do that.

The Samples section at this point contains the following plug-in samples:

Basic plug-in

Shows the bare bones of the plugin DLL. It does not do anything more than a 'Hello, World' for plug-ins. The basic plug-in demonstrates how the plugin DLL is invoked and how NPAPI methods are called. It can be used as a starting template for writing your own plug-in.

Simple plug-in

This plug-in example illustrates specific for Mozilla code base features. It is scriptable via JavaScript and uses services provided by the browser.

XPCOM interfaces are implemented in the simple plug-in so the Mozilla browser is aware of its capabilities. The plug-in does not draw in the native window but rather uses JavaScript box to display the result of its work. Therefore, there are no separate projects for different platforms in this sample.

Scriptable plug-in

Yet another example of plug-in scriptability. The scriptable plug-in implements two native methods callable from the JavaScript, and it draws in a native window, so it uses different projects for the different major platforms.

Windowless plug-in

The windowless plug-in is an example of a plug-in which does not use native window messaging mechanism and relies exclusively on NPP_HandleEvent to receive GUI messages for painting and other tasks. This plug-in simply draws a gray rectangle in the occupied area.

Scriptable plug-in samples require that you generate cross-platform type library (XPT) files and place them in the Mozilla Plugins directory along with the plug-in DLLs. (For backwards compatibility with pre-Mozilla 1.0 and Netscape 6.x browsers, you must put the type library file in the Components directory instead. For more information on type libraries and plug-in path information, see {{ Npapi-section("Plug-in Basics", "Plug-in Detection") }} in the "Plug-in Basics" chapter.)

To verify that Mozilla is aware of new .xpt files, you can look in the generated file, xpti.dat, where type libraries are listed. If you need to, you can callnavigator.plugins.refresh() to find new XPT files and plug-in software.

Plug-in developers might find it useful for debugging purposes to turn off the exception catching mechanism currently implemented in Mozilla on Windows. To turn off Windows exception handling, add the following line into your prefs.js file:

user_pref("plugin.dont_try_safe_calls", true);

{{ Next("Gecko Plugin API Reference:Plug-in Basics") }}

 

Source de la révision

<div style="background-color: rgb(255, 255, 255); font: normal normal normal 14px/1.7 Verdana, Tahoma, sans-serif; color: rgb(37, 34, 29); font-family: Times; line-height: normal; font-size: medium; ">
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.7em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">{{ Next("Gecko Plugin API Reference:Plug-in Basics") }} {{ Npapiref() }}</p>
<h3 name="About_this_guide">About this guide</h3>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.7em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">The Gecko Plug-in API Reference describes the application programming interfaces (APIs) for Netscape Gecko plug-ins and provides information about how to use these interfaces to create plug-ins for <a href="/en/Gecko" style="text-decoration: none; color: rgb(4, 137, 183) !important; cursor: default; " title="en/Gecko">Gecko</a>-based applications such as Firefox, Mozilla, Netscape 6+, and others.</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.7em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">The general introduction in {{ Npapi-page("Plug-in Basics") }} and a chapter entitled {{ Npapi-page("Plug-in Development Overview") }} begin the guide. A series of chapters on specific programming topics such as {{ Npapi-page("Initialization and Destruction") }}, {{ Npapi-page("Streams") }}, and {{ Npapi-page("URLs") }} provide more detail about the technical aspects and techniques for creating and managing plug-ins.</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.7em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">The API reference in the second half of the guide is divided up into two main halves, {{ Npapi-page("Plug-in Side Plug-in API") }} and {{ Npapi-page("Browser Side Plug-in API") }}, as well as additional reference material about {{ Npapi-page("Structures") }} and {{ Npapi-page("Constants") }}.</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.7em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">The guide is structured so the developers new to Gecko plug-ins can familiarize themselves with the APIs and particular aspects of the development process (e.g., {{ Npapi-page("Drawing and Event Handling") }}), but so that plug-in developers can quickly access the API reference material they need.</p>
<h3 name="Who_should_read_this_guide">Who should read this guide</h3>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.7em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">The Gecko Plug-in API Reference is meant for plug-in developers. Though it provides a basic overview of plug-ins and how they work in the browser, the guide presumes that you understand how plug-ins work, how they handle and display media, and what the basic architecture of a browser is that supports the use of plug-in software.</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.7em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">The guide also presumes that you know how to use application programming interfaces, have experience developing browser software such as plug-ins, components, or add-ons, and are familiar with C/C++, the language(s) in which the libraries were actually created and in which all of the examples are given.</p>
<h3 name="The_Plug-in_software_development_kit">The Plug-in software development kit</h3>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.7em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">A Plug-in software development kit (SDK) is available for Gecko plug-in developers. This SDK is located in the Mozilla source under {{ Source("modules/plugin/sdk/") }}. You can use it within the Mozilla source tree, or you can build it there and then use it outside of tree if you'd rather. In either case, the Mozilla source tree is required to get started developing plug-ins. You can also view the plug-in SDK samples and source code using the web-based source viewer: {{ Source("modules/plugin/sdk/") }}</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.7em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">The SDK is based on the API developed originally for Netscape browsers starting with Netscape 2.x. Some additions were made when Netscape 3.x and Netscape 4.x were released. The present SDK reflects major changes related to Mozilla code base: LiveConnect for plug-in scriptability is no longer supported, existing plug-ins should be modified slightly to become scriptable again; the browser services are now accessible from the plug-in through the access to the service manager.</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.7em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">The SDK is intended to help in creating full-blown plug-ins to work with the Mozilla code base without actually having the whole Mozilla source tree present and built.</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.7em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">The Common folder contains stub implementations of the NPAPI methods. There is no need to modify files in this folder, just include them into your project. This is not necessary though, some samples or plug-in projects may use their own implementations, the files in this folder are just an illustration of one possible way to do that.</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.7em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">The Samples section at this point contains the following plug-in samples:</p>
<h5 name="Basic_plug-in">Basic plug-in</h5>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.7em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">Shows the bare bones of the plugin DLL. It does not do anything more than a 'Hello, World' for plug-ins. The basic plug-in demonstrates how the plugin DLL is invoked and how NPAPI methods are called. It can be used as a starting template for writing your own plug-in.</p>
<h5 name="Simple_plug-in">Simple plug-in</h5>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.7em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">This plug-in example illustrates specific for Mozilla code base features. It is scriptable via JavaScript and uses services provided by the browser.</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.7em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">XPCOM interfaces are implemented in the simple plug-in so the Mozilla browser is aware of its capabilities. The plug-in does not draw in the native window but rather uses JavaScript box to display the result of its work. Therefore, there are no separate projects for different platforms in this sample.</p>
<h5 name="Scriptable_plug-in">Scriptable plug-in</h5>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.7em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">Yet another example of plug-in scriptability. The scriptable plug-in implements two native methods callable from the JavaScript, and it draws in a native window, so it uses different projects for the different major platforms.</p>
<h5 name="Windowless_plug-in">Windowless plug-in</h5>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.7em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">The windowless plug-in is an example of a plug-in which does not use native window messaging mechanism and relies exclusively on <code style="color: inherit; font-weight: inherit; ">NPP_HandleEvent</code> to receive GUI messages for painting and other tasks. This plug-in simply draws a gray rectangle in the occupied area.</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.7em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">Scriptable plug-in samples require that you generate cross-platform type library (XPT) files and place them in the Mozilla Plugins directory along with the plug-in DLLs. (For backwards compatibility with pre-Mozilla 1.0 and Netscape 6.x browsers, you must put the type library file in the Components directory instead. For more information on type libraries and plug-in path information, see {{ Npapi-section("Plug-in Basics", "Plug-in Detection") }} in the "Plug-in Basics" chapter.)</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.7em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">To verify that Mozilla is aware of new .xpt files, you can look in the generated file, xpti.dat, where type libraries are listed. If you need to, you can call<code style="color: inherit; font-weight: inherit; ">navigator.plugins.refresh()</code> to find new XPT files and plug-in software.</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.7em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">Plug-in developers might find it useful for debugging purposes to turn off the exception catching mechanism currently implemented in Mozilla on Windows. To turn off Windows exception handling, add the following line into your prefs.js file:</p>
<pre class="eval" style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.7em; margin-left: 0px; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(223, 236, 241); border-right-color: rgb(223, 236, 241); border-bottom-color: rgb(223, 236, 241); border-left-color: rgb(223, 236, 241); overflow-x: auto; overflow-y: auto; font: normal normal normal 12px/normal 'Courier New', 'Andale Mono', monospace; color: rgb(37, 34, 29); ">user_pref("plugin.dont_try_safe_calls", true);
</pre>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.7em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">{{ Next("Gecko Plugin API Reference:Plug-in Basics") }}</p>
</div>
<p> </p>
Revenir à cette révision