Netscape Plugin Application Program Interface ( NPAPI ) is an application programming interface (API) that allows browser extensions to be developed. It was first developed for the Netscape browser, started in 1995 with Netscape Navigator 2.0, but was later adopted by another browser.
In the NPAPI architecture, the plugin specifies the content type (e.g. "Audio/mp3") that can be handled. When a browser finds a content type that can not be handled in its original way, it loads the appropriate plugin, setting aside space in the browser context for the plugin to render and then streaming data into it. The plugin is responsible for rendering data. The plugin runs in place within the page, compared to older browsers that have to launch an external app to handle unknown content types.
NPAPI requires each plugin to apply and expose about 15 functions to initialize, create, delete and position plugin content. NPAPI also supports scripting, printing, full screen plugins, windowless plugins and streaming content.
Video NPAPI
Scripting support
Scripting is a feature that allows JavaScript code in web pages to interact with plugins. Various versions of Netscape and then Mozilla support this feature using different technologies, including LiveConnect, XPConnect, and NPRuntime.
LiveConnect
LiveConnect is a Web browser feature that allows Java and JavaScript software to interact within a Web page. From a Java side it allows an applet to request embedded scripts from a page or to access a native JavaScript environment, as well as scripts. In contrast, from the JavaScript side, it allows scripts to invoke applet methods, or to access Java runtime libraries, just like applets.
LiveConnect is used in Netscape 4 to implement NPAPI plugin script capabilities.
The implementation of OpenConnect that relies on Java Interface has been removed from the Mozilla source tree tree at the end of June 2009 as part of the Mozilla 2 cleanup effort. This is no longer necessary with the redesigned Java Runtime Environment release from Sun Microsystems. However the old implementation is restored for Gecko 1.9.2, as Apple has not yet ported the newer JRE to Mac OS X.
Java-JavaScript functionality supported by the redesigned Java Runtime Environment is still called "LiveConnect", although the Open Java Interface-specific approach has been abandoned. With Netscape 4, NPAPI is extended to allow plugins to be written. This extension is called LiveConnect. A plugin can implement Java classes and expose examples. Classes can be called from JavaScript and from Java applets running inside the page.
The disadvantage of LiveConnect is that it is strongly associated with the Java version embedded in the Netscape browser. This prevents the browser from using other Java runtimes, and adds an inflate to the browser's download size because it requires Java to install the script plugin. In addition, LiveConnect is very difficult to program: Developers must define Java classes for plugins, run them through a special Java header compiler and apply the original methods. Handling strings, exceptions, and other Java objects from C is not clear. In addition, LiveConnect uses an earlier and now outdated application programming interface (API) to call native C calls from Java, called JRIs. JRI technology has long been replaced by JNI.
XPConnect
XPConnect (Cross Platform Connect) is a technology that enables simple interoperability between XPCOM and JavaScript.
Connection object
XPConnect allows JavaScript objects to access and manipulate XPCOM objects transparently. It also allows JavaScript objects to present XPCOM-compatible interfaces to be invoked by XPCOM objects. The main purpose is the object that communicates from one side of the XPCOM style interface should not need to know or care about the object implementation language on the other side of the interface.
The main reason for the existence of XPConnect is to replace the handwritten code used in places where the default code needs to interact with JavaScript code. An example is a DOM module.
Security
Full privileges are only granted by default for chrome scripts, those are scripts that are part of the app or extension. For HTML/XHTML/XUL remote documents, most XPCOM objects can not be accessed by scripts because they have limited rights due to security reasons. Even if they are accessible (eg XMLHttpRequest objects), ordinary security restrictions can also be found (eg can not open other domain URLs).
Mozilla is already using XPCOM to define interfaces for many objects that are implemented in C. Each interface is defined by an IDL file, and runs through an IDL compiler that generates header files and a neutral language type library which is a binary representation of the interface. This binary describes interfaces, methods, parameters, data structures and enumerations.
XPConnect uses type library information for call marshal between different thread contexts and between natively compiled JavaScript and C. XPConnect is used extensively throughout Mozilla. Starting with Netscape 6.1 and Mozilla 0.9.2, NPAPI is extended, so a plugin can return the script interface to itself and XPConnect will call marshal from JavaScript and C implementation.
XPConnect has no Java dependencies. However, this technology is based on XPCOM. Thus the plugin developer must be familiar with reference count, interface and IDL to implement scripting. Dependency on XPCOM leads to certain dynamic linking issues (such as fragile base class issues) that must be solved before the plugin works properly with different browsers. XPCOM has been changed to provide a static-related version to resolve the issue. This approach also requires a.xpt file to be installed next to the dynamic link library (DLL); otherwise, the plugin seems to work, but no scripting, causing confusion.
NPRuntime
At the end of 2004, all major browser companies using NPAPI agreed on NPRuntime as an extension to the original NPAPI to supply scripting, via APIs similar to the old C-style NPAPI style and not rely on other browser technologies such as Java or XPCOM. It is only supported by Firefox ESR (Extended Support Release) and Safari.
Maps NPAPI
Browser support
The following web browsers support all NPAPI plugins:
- Basilisk
- Camino (not resumed)
- GNOME Web
- Konqueror
- Midori
- Mozilla Application Suite (stopped)
- Netscape Communicator (not resumed)
- Netscape Navigator (not resumed)
- Odyssey Web Browser (not resumed)
- Pale Moon
- Safari
- SeaMonkey
- Uzbl
- Waterfox (Leaving running of all 64-bit NPAPI plugins)
Due to API age, security issues, and adoption of alternative technologies such as HTML5, major web browser vendors began stopping NPAPI support in 2013.
- Internet Explorer versions 3 to 5.5 SP2 supports NPAPI, enabling functioning plugins in Netscape Navigator to work in Internet Explorer. Support comes through a small ActiveX control (named " plugin.ocx ") that acts as a shim between ActiveX and NPAPI plugins. Microsoft dropped support in version 5.5 SP2 and beyond for security reasons.
- Google Chrome 45, in September 2015, permanently deletes all NPAPI support from all platforms. In September 2013, Google announced that it will stop NPAPI support in the Google Chrome browser during 2014, stating that "its 90s era architecture has been a major cause of hangs, crashes, security incidents, and code complexity". In May 2014, NPAPI support was removed from the Linux version of Chrome 35 and later. As of April 2015, Chrome for Windows and OS X (version 42 and above) disables NPAPI support by default. However, until September 2015, users can re-enable NPAPI.
- Opera dropped support with version 37 in May 2016.
- Firefox releases 52.0 in March 2017 removes all support for NPAPI except for Flash. Meanwhile, the ESR channel maintains general support for this feature with the 52esr version being the last NPAPI resort.
Oracle Corporation has announced its plan to remove the Java Runtime Environment web browser plugin, starting with JDK 9.
Plugins
The following is a list of NPAPI-based plugins:
- Adobe Acrobat Viewer
- Adobe Flash Player
- Adobe Shockwave Player
- DivX Web Player
- Java Runtime Environment
- Microsoft Silverlight
- Unity of Web Player
- Windows Genuine Advantage plugin for Firefox
Similar technology
ActiveX
Internet Explorer and Internet Explorer-based browsers use ActiveX controls, ActiveX documents, and ActiveX scripting to offer page extensions in par with NPAPI. Although commonly associated with Internet Explorer, ActiveX is an integration technology that allows computer programs to integrate parts of other computer programs that support such integration. Internet Explorer, however, is terminated and its successor, Microsoft Edge, does not support ActiveX.
PPAPI
On August 12, 2009, a page on Google Code introduced a new project, Pepper, with a related Pepper Plugin API (PPAPI); PPAPI is a derivative of NPAPI that aims to make plugins more portable and more secure. This extension is specifically designed to facilitate the execution of plugins outside the process.
PPAPI was originally supported only by Google Chrome and Chromium. Then, other Chromium-based browsers like Opera and Vivaldi, also added PPAPI plugin support.
In February 2012, Adobe Systems announced that future versions of Adobe Flash Player Linux will only be provided through PPAPI. The previous release, Flash Player 11.2, with NPAPI support, will receive a five-year security update. In August 2016, Adobe announced that, contrary to their previous statement, Adobe will support NPAPI Flash Player on Linux and continue to release new versions of it.
See also
- Netscape Server Application Interface (NSAPI) Interface
References
External links
- Documentation of plugin development at Mozilla Developer Center, including NPAPI API
- ActiveX controls that host plugins - a replacement for the removed plugin.ocx from Internet Explorer.
- Messages in Netscape Plug-Ins Programming by Zan Oliphant
- Nixysa: A glue code builder for NPAPI plugins. Apache License 2.0.
- NPAPI Tutorial Building Firefox Plugin (Part two, Part three, Part four)
- Opera extension documentation 15
Source of the article : Wikipedia