1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
14 * The Original Code is mozilla.org code.
16 * The Initial Developer of the Original Code is
17 * Netscape Communications Corporation.
18 * Portions created by the Initial Developer are Copyright (C) 1998
19 * the Initial Developer. All Rights Reserved.
23 * Alternatively, the contents of this file may be used under the terms of
24 * either the GNU General Public License Version 2 or later (the "GPL"), or
25 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26 * in which case the provisions of the GPL or the LGPL are applicable instead
27 * of those above. If you wish to allow use of your version of this file only
28 * under the terms of either the GPL or the LGPL, and not to allow others to
29 * use your version of this file under the terms of the MPL, indicate your
30 * decision by deleting the provisions above and replace them with the notice
31 * and other provisions required by the GPL or the LGPL. If you do not delete
32 * the provisions above, a recipient may use your version of this file under
33 * the terms of any one of the MPL, the GPL or the LGPL.
35 * ***** END LICENSE BLOCK ***** */
39 * Netscape client plug-in API spec
46 #include <wtf/Platform.h>
48 #if ENABLE(NETSCAPE_API)
51 #include "jri.h" /* Java Runtime Interface */
64 # define _declspec __declspec
69 # endif /* macintosh */
74 # endif /* __INTEL__ */
76 #endif /* __MWERKS__ */
78 #if defined(__APPLE_CC__) && !defined(__MACOS_CLASSIC__) && !defined(XP_UNIX)
83 #include <Quickdraw.h>
88 #include <Carbon/Carbon.h>
89 #include <ApplicationServices/ApplicationServices.h>
90 #include <OpenGL/OpenGL.h>
95 #include <X11/Xutil.h>
103 #if defined(XP_MACOSX) && defined(__LP64__)
104 #error 64-bit Netscape plug-ins are not supported on Mac OS X
107 /*----------------------------------------------------------------------*/
108 /* Plugin Version Constants */
109 /*----------------------------------------------------------------------*/
111 #define NP_VERSION_MAJOR 0
112 #define NP_VERSION_MINOR 18
116 /*----------------------------------------------------------------------*/
117 /* Definition of Basic Types */
118 /*----------------------------------------------------------------------*/
122 typedef unsigned short uint16
;
128 typedef unsigned int uint32
;
130 typedef unsigned long uint32
;
131 #endif /* __LP64__ */
145 #endif /* __LP64__ */
158 typedef unsigned char NPBool
;
159 typedef int16 NPError
;
160 typedef int16 NPReason
;
161 typedef char* NPMIMEType
;
165 /*----------------------------------------------------------------------*/
166 /* Structures and definitions */
167 /*----------------------------------------------------------------------*/
169 #if !defined(__LP64__)
170 #if defined(XP_MAC) || defined(XP_MACOSX)
171 #pragma options align=mac68k
173 #endif /* __LP64__ */
176 * NPP is a plug-in's opaque instance handle
180 void* pdata
; /* plug-in private data */
181 void* ndata
; /* netscape private data */
187 typedef struct _NPStream
189 void* pdata
; /* plug-in private data */
190 void* ndata
; /* netscape private data */
195 const char* headers
; /* Response headers from host.
196 * Exists only for >= NPVERS_HAS_RESPONSE_HEADERS.
197 * Used for HTTP only; NULL for non-HTTP.
198 * Available from NPP_NewStream onwards.
199 * Plugin should copy this data before storing it.
200 * Includes HTTP status line and all headers,
201 * preferably verbatim as received from server,
202 * headers formatted as in HTTP ("Header: Value"),
203 * and newlines (\n, NOT \r\n) separating lines.
204 * Terminated by \n\0 (NOT \n\n\0). */
208 typedef struct _NPByteRange
210 int32 offset
; /* negative offset means from the end */
212 struct _NPByteRange
* next
;
216 typedef struct _NPSavedData
223 typedef struct _NPRect
234 * Unix specific structures and definitions
238 * Callback Structures.
240 * These are used to pass additional platform specific information.
250 } NPAnyCallbackStruct
;
259 } NPSetWindowCallbackStruct
;
265 } NPPrintCallbackStruct
;
270 * The following masks are applied on certain platforms to NPNV and
271 * NPPV selectors that pass around pointers to COM interfaces. Newer
272 * compilers on some platforms may generate vtables that are not
273 * compatible with older compilers. To prevent older plugins from
274 * not understanding a new browser's ABI, these masks change the
275 * values of those selectors on those platforms. To remain backwards
276 * compatible with differenet versions of the browser, plugins can
277 * use these masks to dynamically determine and use the correct C++
278 * ABI that the browser is expecting. This does not apply to Windows
279 * as Microsoft's COM ABI will likely not change.
282 #define NP_ABI_GCC3_MASK 0x10000000
284 * gcc 3.x generated vtables on UNIX and OSX are incompatible with
285 * previous compilers.
287 #if (defined (XP_UNIX) && defined(__GNUC__) && (__GNUC__ >= 3))
288 #define _NP_ABI_MIXIN_FOR_GCC3 NP_ABI_GCC3_MASK
290 #define _NP_ABI_MIXIN_FOR_GCC3 0
293 #define NP_ABI_MACHO_MASK 0x01000000
295 * On OSX, the Mach-O executable format is significantly
296 * different than CFM. In addition to having a different
297 * C++ ABI, it also has has different C calling convention.
298 * You must use glue code when calling between CFM and
299 * Mach-O C functions.
301 #if (defined(TARGET_RT_MAC_MACHO))
302 #define _NP_ABI_MIXIN_FOR_MACHO NP_ABI_MACHO_MASK
304 #define _NP_ABI_MIXIN_FOR_MACHO 0
308 #define NP_ABI_MASK (_NP_ABI_MIXIN_FOR_GCC3 | _NP_ABI_MIXIN_FOR_MACHO)
311 * List of variable names for which NPP_GetValue shall be implemented
314 NPPVpluginNameString
= 1,
315 NPPVpluginDescriptionString
,
316 NPPVpluginWindowBool
,
317 NPPVpluginTransparentBool
,
319 NPPVjavaClass
, /* Not implemented in WebKit */
320 NPPVpluginWindowSize
, /* Not implemented in WebKit */
321 NPPVpluginTimerInterval
, /* Not implemented in WebKit */
323 NPPVpluginScriptableInstance
= (10 | NP_ABI_MASK
), /* Not implemented in WebKit */
324 NPPVpluginScriptableIID
= 11, /* Not implemented in WebKit */
326 /* 12 and over are available on Mozilla builds starting with 0.9.9 */
327 NPPVjavascriptPushCallerBool
= 12, /* Not implemented in WebKit */
328 NPPVpluginKeepLibraryInMemory
= 13, /* Not implemented in WebKit */
329 NPPVpluginNeedsXEmbed
= 14, /* Not implemented in WebKit */
331 /* Get the NPObject for scripting the plugin. */
332 NPPVpluginScriptableNPObject
= 15,
334 /* Get the plugin value (as \0-terminated UTF-8 string data) for
335 * form submission if the plugin is part of a form. Use
336 * NPN_MemAlloc() to allocate memory for the string data.
338 NPPVformValue
= 16, /* Not implemented in WebKit */
340 /* Used for negotiating drawing models */
341 NPPVpluginDrawingModel
= 1000
346 * List of variable names for which NPN_GetValue is implemented by Mozilla
352 NPNVjavascriptEnabledBool
,
356 /* 10 and over are available on Mozilla builds starting with 0.9.4 */
357 NPNVserviceManager
= (10 | NP_ABI_MASK
), /* Not implemented in WebKit */
358 NPNVDOMElement
= (11 | NP_ABI_MASK
), /* Not implemented in WebKit */
359 NPNVDOMWindow
= (12 | NP_ABI_MASK
), /* Not implemented in WebKit */
360 NPNVToolkit
= (13 | NP_ABI_MASK
), /* Not implemented in WebKit */
361 NPNVSupportsXEmbedBool
= 14, /* Not implemented in WebKit */
363 /* Get the NPObject wrapper for the browser window. */
364 NPNVWindowNPObject
= 15,
366 /* Get the NPObject wrapper for the plugins DOM element. */
367 NPNVPluginElementNPObject
370 , NPNVpluginDrawingModel
= 1000 /* The NPDrawingModel specified by the plugin */
372 #ifndef NP_NO_QUICKDRAW
373 , NPNVsupportsQuickDrawBool
= 2000 /* TRUE if the browser supports the QuickDraw drawing model */
375 , NPNVsupportsCoreGraphicsBool
= 2001 /* TRUE if the browser supports the CoreGraphics drawing model */
376 , NPNVsupportsOpenGLBool
= 2002 /* TRUE if the browser supports the OpenGL drawing model (CGL on Mac) */
377 #endif /* XP_MACOSX */
381 * The type of a NPWindow - it specifies the type of the data structure
382 * returned in the window field.
385 NPWindowTypeWindow
= 1,
392 * The drawing model for a Mac OS X plugin. These are the possible values for the NPNVpluginDrawingModel variable.
396 #ifndef NP_NO_QUICKDRAW
397 NPDrawingModelQuickDraw
= 0,
399 NPDrawingModelCoreGraphics
= 1,
400 NPDrawingModelOpenGL
= 2
405 typedef struct _NPWindow
407 void* window
; /* Platform specific window handle */
408 int32 x
; /* Position of top left corner relative */
409 int32 y
; /* to a netscape page. */
410 uint32 width
; /* Maximum window size */
412 NPRect clipRect
; /* Clipping rectangle in port coordinates */
413 /* Used by MAC only. */
415 void * ws_info
; /* Platform-dependent additonal data */
417 NPWindowType type
; /* Is this a window or a drawable? */
421 typedef struct _NPFullPrint
423 NPBool pluginPrinted
; /* Set TRUE if plugin handled fullscreen */
425 NPBool printOne
; /* TRUE if plugin should print one copy */
426 /* to default printer */
427 void* platformPrint
; /* Platform-specific printing info */
430 typedef struct _NPEmbedPrint
433 void* platformPrint
; /* Platform-specific printing info */
436 typedef struct _NPPrint
438 uint16 mode
; /* NP_FULL or NP_EMBED */
441 NPFullPrint fullPrint
; /* if mode is NP_FULL */
442 NPEmbedPrint embedPrint
; /* if mode is NP_EMBED */
446 #if defined(XP_MAC) || defined(XP_MACOSX)
447 typedef EventRecord NPEvent
;
448 #elif defined(XP_WIN)
449 typedef struct _NPEvent
455 #elif defined (XP_UNIX)
456 typedef XEvent NPEvent
;
458 typedef void* NPEvent
;
462 typedef RgnHandle NPRegion
;
463 #elif defined(XP_MACOSX)
465 * NPRegion's type depends on the drawing model specified by the plugin (see NPNVpluginDrawingModel).
466 * NPQDRegion represents a QuickDraw RgnHandle and is used with the QuickDraw drawing model.
467 * NPCGRegion repesents a graphical region when using any other drawing model.
469 typedef void *NPRegion
;
470 #ifndef NP_NO_QUICKDRAW
471 typedef RgnHandle NPQDRegion
;
473 typedef CGPathRef NPCGRegion
;
474 #elif defined(XP_WIN)
475 typedef HRGN NPRegion
;
476 #elif defined(XP_UNIX)
477 typedef Region NPRegion
;
479 typedef void *NPRegion
;
485 * NP_CGContext is the type of the NPWindow's 'window' when the plugin specifies NPDrawingModelCoreGraphics
486 * as its drawing model.
489 typedef struct NP_CGContext
491 CGContextRef context
;
496 * NP_GLContext is the type of the NPWindow's 'window' when the plugin specifies NPDrawingModelOpenGL as its
500 typedef struct NP_GLContext
502 CGLContextObj context
;
506 #endif /* XP_MACOSX */
508 #if defined(XP_MAC) || defined(XP_MACOSX)
511 * Mac-specific structures and definitions.
514 #ifndef NP_NO_QUICKDRAW
517 * NP_Port is the type of the NPWindow's 'window' when the plugin specifies NPDrawingModelQuickDraw as its
518 * drawing model, or the plugin does not specify a drawing model.
520 * It is not recommended that new plugins use NPDrawingModelQuickDraw or NP_Port, as QuickDraw has been
521 * deprecated in Mac OS X 10.5. CoreGraphics is the preferred drawing API.
523 * NP_Port is not available in 64-bit.
526 typedef struct NP_Port
528 CGrafPtr port
; /* Grafport */
529 int32 portx
; /* position inside the topmost window */
533 #endif /* NP_NO_QUICKDRAW */
536 * Non-standard event types that can be passed to HandleEvent
538 #define getFocusEvent (osEvt + 16)
539 #define loseFocusEvent (osEvt + 17)
540 #define adjustCursorEvent (osEvt + 18)
546 * Values for mode passed to NPP_New:
552 * Values for stream type passed to NPP_NewStream:
557 #define NP_ASFILEONLY 4
559 #define NP_MAXREADY (((unsigned)(~0)<<1)>>1)
561 #if !defined(__LP64__)
562 #if defined(XP_MAC) || defined(XP_MACOSX)
563 #pragma options align=reset
565 #endif /* __LP64__ */
568 /*----------------------------------------------------------------------*/
569 /* Error and Reason Code definitions */
570 /*----------------------------------------------------------------------*/
573 * Values of type NPError:
576 #define NPERR_NO_ERROR (NPERR_BASE + 0)
577 #define NPERR_GENERIC_ERROR (NPERR_BASE + 1)
578 #define NPERR_INVALID_INSTANCE_ERROR (NPERR_BASE + 2)
579 #define NPERR_INVALID_FUNCTABLE_ERROR (NPERR_BASE + 3)
580 #define NPERR_MODULE_LOAD_FAILED_ERROR (NPERR_BASE + 4)
581 #define NPERR_OUT_OF_MEMORY_ERROR (NPERR_BASE + 5)
582 #define NPERR_INVALID_PLUGIN_ERROR (NPERR_BASE + 6)
583 #define NPERR_INVALID_PLUGIN_DIR_ERROR (NPERR_BASE + 7)
584 #define NPERR_INCOMPATIBLE_VERSION_ERROR (NPERR_BASE + 8)
585 #define NPERR_INVALID_PARAM (NPERR_BASE + 9)
586 #define NPERR_INVALID_URL (NPERR_BASE + 10)
587 #define NPERR_FILE_NOT_FOUND (NPERR_BASE + 11)
588 #define NPERR_NO_DATA (NPERR_BASE + 12)
589 #define NPERR_STREAM_NOT_SEEKABLE (NPERR_BASE + 13)
592 * Values of type NPReason:
595 #define NPRES_DONE (NPRES_BASE + 0)
596 #define NPRES_NETWORK_ERR (NPRES_BASE + 1)
597 #define NPRES_USER_BREAK (NPRES_BASE + 2)
600 * Don't use these obsolete error codes any more.
602 #define NP_NOERR NP_NOERR_is_obsolete_use_NPERR_NO_ERROR
603 #define NP_EINVAL NP_EINVAL_is_obsolete_use_NPERR_GENERIC_ERROR
604 #define NP_EABORT NP_EABORT_is_obsolete_use_NPRES_USER_BREAK
607 * Version feature information
609 #define NPVERS_HAS_STREAMOUTPUT 8
610 #define NPVERS_HAS_NOTIFICATION 9
611 #define NPVERS_HAS_LIVECONNECT 9
612 #define NPVERS_WIN16_HAS_LIVECONNECT 9
613 #define NPVERS_68K_HAS_LIVECONNECT 11
614 #define NPVERS_HAS_WINDOWLESS 11
615 #define NPVERS_HAS_XPCONNECT_SCRIPTING 13 /* Not implemented in WebKit */
616 #define NPVERS_HAS_NPRUNTIME_SCRIPTING 14
617 #define NPVERS_HAS_FORM_VALUES 15 /* Not implemented in WebKit; see bug 13061 */
618 #define NPVERS_HAS_POPUPS_ENABLED_STATE 16 /* Not implemented in WebKit */
619 #define NPVERS_HAS_RESPONSE_HEADERS 17
620 #define NPVERS_HAS_NPOBJECT_ENUM 18
623 /*----------------------------------------------------------------------*/
624 /* Function Prototypes */
625 /*----------------------------------------------------------------------*/
627 #if defined(_WINDOWS) && !defined(WIN32)
628 #define NP_LOADDS _loadds
638 * NPP_* functions are provided by the plugin and called by the navigator.
642 char* NPP_GetMIMEDescription(void);
645 NPError
NPP_Initialize(void);
646 void NPP_Shutdown(void);
647 NPError NP_LOADDS
NPP_New(NPMIMEType pluginType
, NPP instance
,
648 uint16 mode
, int16 argc
, char* argn
[],
649 char* argv
[], NPSavedData
* saved
);
650 NPError NP_LOADDS
NPP_Destroy(NPP instance
, NPSavedData
** save
);
651 NPError NP_LOADDS
NPP_SetWindow(NPP instance
, NPWindow
* window
);
652 NPError NP_LOADDS
NPP_NewStream(NPP instance
, NPMIMEType type
,
653 NPStream
* stream
, NPBool seekable
,
655 NPError NP_LOADDS
NPP_DestroyStream(NPP instance
, NPStream
* stream
,
657 int32 NP_LOADDS
NPP_WriteReady(NPP instance
, NPStream
* stream
);
658 int32 NP_LOADDS
NPP_Write(NPP instance
, NPStream
* stream
, int32 offset
,
659 int32 len
, void* buffer
);
660 void NP_LOADDS
NPP_StreamAsFile(NPP instance
, NPStream
* stream
,
662 void NP_LOADDS
NPP_Print(NPP instance
, NPPrint
* platformPrint
);
663 int16
NPP_HandleEvent(NPP instance
, void* event
);
664 void NP_LOADDS
NPP_URLNotify(NPP instance
, const char* url
,
665 NPReason reason
, void* notifyData
);
666 jref NP_LOADDS
NPP_GetJavaClass(void);
667 NPError
NPP_GetValue(NPP instance
, NPPVariable variable
,
669 NPError
NPP_SetValue(NPP instance
, NPNVariable variable
,
673 * NPN_* functions are provided by the navigator and called by the plugin.
676 void NPN_Version(int* plugin_major
, int* plugin_minor
,
677 int* netscape_major
, int* netscape_minor
);
678 NPError
NPN_GetURLNotify(NPP instance
, const char* url
,
679 const char* target
, void* notifyData
);
680 NPError
NPN_GetURL(NPP instance
, const char* url
,
682 NPError
NPN_PostURLNotify(NPP instance
, const char* url
,
683 const char* target
, uint32 len
,
684 const char* buf
, NPBool file
,
686 NPError
NPN_PostURL(NPP instance
, const char* url
,
687 const char* target
, uint32 len
,
688 const char* buf
, NPBool file
);
689 NPError
NPN_RequestRead(NPStream
* stream
, NPByteRange
* rangeList
);
690 NPError
NPN_NewStream(NPP instance
, NPMIMEType type
,
691 const char* target
, NPStream
** stream
);
692 int32
NPN_Write(NPP instance
, NPStream
* stream
, int32 len
,
694 NPError
NPN_DestroyStream(NPP instance
, NPStream
* stream
,
696 void NPN_Status(NPP instance
, const char* message
);
697 const char* NPN_UserAgent(NPP instance
);
698 void* NPN_MemAlloc(uint32 size
);
699 void NPN_MemFree(void* ptr
);
700 uint32
NPN_MemFlush(uint32 size
);
701 void NPN_ReloadPlugins(NPBool reloadPages
);
702 JRIEnv
* NPN_GetJavaEnv(void);
703 jref
NPN_GetJavaPeer(NPP instance
);
704 NPError
NPN_GetValue(NPP instance
, NPNVariable variable
,
706 NPError
NPN_SetValue(NPP instance
, NPPVariable variable
,
708 void NPN_InvalidateRect(NPP instance
, NPRect
*invalidRect
);
709 void NPN_InvalidateRegion(NPP instance
, NPRegion invalidRegion
);
710 void NPN_ForceRedraw(NPP instance
);
711 void NPN_PushPopupsEnabledState(NPP instance
, NPBool enabled
);
712 void NPN_PopPopupsEnabledState(NPP instance
);
715 } /* end extern "C" */
718 #endif // ENABLE(NETSCAPE_API)
720 #endif /* _NPAPI_H_ */