Browser Plug-in API: Plug-in API Reference Tables

The Browser Plug-in API consists of the following two parts:

The browser and plug-ins interact with each other through two interfaces:

Each function in the API has the prefix NPN or NPP to indicate which interface it uses to communicate.

Adapted Netscape Plug-in API Functions

The tables in this section contain the functions adapted from the Netscape Plug-in API.

Initialization and Destruction Functions

The browser calls the functions in this section to initialize or delete a plug-in instance.

InitializeFuncs

Plug-in API Type

NPP — implemented by the plug-in

Syntax

void InitializeFuncs (NPPluginFuncs *aNPPFn);

Parameters

NPPluginFuncs *aNPPFn

Pointer to the plug-in's function table

Returns

None

Description

Exchanges function tables between the browser and the plug-in.

NPP_New

Plug-in API Type

NPP — implemented by the plug-in

Syntax

NPError NPP_New (NPMIMEType pluginType,

NPP instance,

uint16 mode,

CDesCArray* argn,

CDesCArray* argv,

NPSavedData* saved);

Parameters NPMIMEType pluginType The MIME type NPP instance The plug-in instance uint16 mode The mode Value: NP_EMBED CDesCArray* argn Attribute of the <object> tag CDesCArray* argv Attribute of the <object> tag NPSavedData* saved saved data is not supported

Returns

NPError status code

One of the following:

  • 0 means NO_ERROR

  • 1 means GENERIC_ERROR

  • 2 means INVALID_INSTANCE_ERROR

  • 3 means INVALID_FUNCTABLE_ERROR

  • 4 means MODULE_LOAD_FAILED_ERROR

  • 5 means OUT_OF_MEMORY_ERROR

  • 6 means INVALID_PLUGIN_ERROR

  • 7 means INVALID_PLUGIN_DIR_ERROR

  • 8 means INCOMPATIBLE_VERSION_ERROR

  • 9 means INVALID_PARAMETER

  • 10 means INVALID_URL

  • 11 means FILE_NOT_FOUND

  • 12 means NO_DATA

  • 13 means STREAM_NOT_SEEKABLE

Description

Creates a new instance of the plug-in.

NPP_Destroy

Plug-in API Type

NPP — implemented by the plug-in

Syntax

NPError NPP_Destroy (NPP instance,

NPSavedData** save);

Parameters

NPP instance

The instance to be destroyed

NPSavedData** save

Not supported

Returns

NPError status code

For values, see Table 3.

Description

Deletes a plug-in instance.

NPP_Shutdown

Plug-in API Type

NPP — implemented by the plug-in

Syntax

void NPP_Shutdown (void);

Parameters

None

Returns

None

Description

Deletes all resources allocated for the plug-in DLL.

Drawing functions

NPN_ForceRedraw

This function has an empty implementation in the browser. If called, it does nothing.

NPN_InvalidateRect

This function has an empty implementation in the browser. If called, this function does nothing.

NPN_InvalidateRegion

Windowless plug-ins are not supported in the S60 platform. Therefore, this function has an empty implementation in the browser. If called, this function does nothing.

NPN_SetValue

This function has an empty implementation in the browser. If called, this function does nothing.

NPP_HandleEvent
NPP_Print

Not supported. The browser never calls this plug-in function.

NPP_SetValue

Not supported. The browser never calls this plug-in function.

NPP_SetWindow

Plug-in API Type

NPP — implemented by the plug-in

Syntax

NPError NPP_SetWindow (NPP instance,

NPWindow* window);

Parameters

NPP instance

The plug-in instance

NPWindow* window

The window parameters

Returns

NPError status code

For the status code values, see Table 3.

Description

Sets the parent window and the size of the plug-in. The coordinates are always relative to the parent window.

Stream Functions

NPN_NewStream

This function has an empty implementation in the browser. If called, this function does nothing.

NPN_DestroyStream

This function has an empty implementation in the browser, which can be called but does nothing.

NPN_RequestRead

This function has an empty implementation in the browser. If called, this function does nothing.

NPN_Write

This function has an empty implementation in the browser. If called, this function does nothing.

NPP_NewStream

Plug-in API Type

NPP — implemented by the plug-in

Syntax

NPError NPP_NewStream (NPP instance,

NPMIMEType type,

NPStream* stream,

NPBool seekable,

uint16* stype);

Parameters

NPP instance

The instance of the plug-in

NPMIMEType type

The MIME type of the stream

NPStream* stream

The new stream object

NPBool seekable

A flag that indicates whether or not the stream is searchable.

Searchable streams are not supported. Therefore, the flag is always set to EFalse.

Parameters

(continued)

uint16* stype

The type of the stream. The plug-in should set the stream type. Currently supported stream types are:

  • NP_NORMAL,

  • NP_ASFILE

  • NP_ASFILEONLY

    NP_NORMAL: The plug-in can process the data progressively as it arrives from the network or file system through a series of calls to the NPP_WriteReady and the NPP_Write functions.

    NP_ASFILEONLY: The plug-in gets full random access to the data using platform-specific file operations. The browser saves stream data to a local file. When the stream is complete, the browser calls the NPP_StreamAsFile function to return the path of the file.

    NP_ASFILE: This mode is like NP_ASFILEONLY except that data is delivered to the plug-in as it is saved to the file, through a series of calls to the NPP_Write function. Use NP_ASFILEONLY whenever possible; NP_ASFILE is less efficient because it uses successive calls to NPP_Write to send the data.

Returns

NPError status code

For the status code values, see NPP_New function table.

Description

Notifies a plug-in instance of a new data stream.

NPP_DestroyStream

Plug-in API Type

NPP — implemented by the plug-in

Syntax

NPError NPP_DestroyStream (NPP instance,

NPStream* stream,

NPReason reason);

Parameters NPP instance The plug-in instance NPStream* stream The stream to be destroyed NPReason reason The reason for destroying the stream. The reason parameter can have one of the following values: NPRES_DONE (Most common)-- normal completion; all data was sent to the instance. NPRES_USER_BREAK--the user canceled the stream NPRES_NETWORK_ERR--the stream failed because of problems with the network, disk I/O error, lack of memory, or some other problem.

Returns

NPError status code

For the status code values, see NPP_New function table.

Description

Destroys the stream that was previously created to stream data to the plug-in.

NPP_StreamAsFile

Plug-in API Type

NPP — implemented by the plug-in

Syntax

void NPP_StreamAsFile (NPP instance,

NPStream* stream,

const TDesC& fname);

Parameters

NPP instance

The plug-in instance

NPStream* stream

The stream

const TDesC& fname

The file name

Returns

None

Description

A file name is passed to the plug-in in which the stream data is stored. The plug-in can access the file and use the data received.

NPP_Write

Plug-in API Type

NPP — implemented by the plug-in

Syntax

int32 NPP_Write (NPP instance,

NPStream* stream,

int32 offset,

int32 len,

void* buffer);

Parameters

NPP instance

The plug-in instance

NPStream* stream

The stream

int32 offset

The offset in the stream

int32 len

The size of the new data

void* buffer

The data itself

Returns

If successful, this function returns the number of bytes consumed by the plug-in instance.

If unsuccessful, this function destroys the stream by returning a negative value.

Description

Writes a chunk of data to the plug-in.

NPP_WriteReady

Plug-in API Type

NPP — implemented by the plug-in

Syntax

int32 NPP_WriteReady (NPP instance,

NPStream* stream);

Parameters

NPP instance

The plug-in instance

NPStream* stream

The stream

Returns

The maximum data size that the plug-in can handle.

Description

The browser calls the NPP_Write function with the amount of data returned from the NPP_WriteReady function.

URL Functions

NPN_GetURL

Plug-in API Type

NPN — implemented by the browser

Syntax

NPError NPN_GetURL (NPP instance,

const TDesC& url,

const TDesC* target);

Parameters

NPP instance

The plug-in instance

const TDesC& url

The URL to load

const TDesC* target

The target window

Returns

NPError status code

For the status code values, see NPP_New function table.

Description

The plug-in calls this function to request the browser to load a URL.

Note

If the target window is NULL, pass the response to the plug-in.

If the target window is _parent, or _top, the browser initiates a load request to the given URL.

NPN_GetURLNotify

Plug-in API Type

NPN — implemented by the browser

Syntax

NPError NPN_GetURLNotify (NPP instance,

const TDesC& url,

const TDesC* tgt,

void* notifyData); 

Parameters

NPP instance

The plug-in instance

const TDesC& url

The URL to load

const TDesC* tgt

The target window

void* notifyData

The context to be returned to the plug-in with the notification.

Returns

NPError status code

For the status code values, see NPP_New function table.

Description

The plug-in calls this function to request the browser to load a URL. A requesting plug-in is informed when the load completes.

Note

If the target window is NULL, _parent, or _top, the browser initiates a load request to the given URL. After the load is initiated, the browser notifies the plug-in that the load was successful. There is no way for the browser to ensure that the server received the load request.

NPN_PostURL

Plug-in API Type

NPN — implemented by the browser

Syntax

NPError NPN_PostURL (NPP instance,

const TDesC& url,

const TDesC* target,

const TDesC& buf,

NPBool file); 

Parameters NPP instance The plug-in instance const TDesC& url The URL to post to const TDesC* target The target window const TDesC& buf A buffer NPBool file A flag indicating the contents of the buffer. Value: One of the following: ETrue indicates that the buffer contains a file name. EFalse indicates that the buffer contains the posted data.

Returns

NPError status code

For the status code values, see NPP_New function table.

Description

Posts information through the browser and requests that the result be displayed or passed to the named target window or frame. If a name is not provided, the target is assumed to be the plug-in itself.

Note

If the target window is NULL, pass the response to the plug-in.

If the target window is _parent, or _top, the browser initiates a load request to the given URL.

NPN_PostURLNotify

Plug-in API Type

NPN — implemented by the browser

Syntax

NPError NPN_PostURLNotify (NPP instance,

const TDesC& url,

const TDesC* tgt,

const TDesC& buf,

NPBool file,

void* notifyData);

Parameters NPP instance The plug-in instance const TDesC& url The URL to post to const TDesC* tgt The target window const TDesC& buf A buffer NPBool file A flag indicating the contents of the buffer. Value: One of the following: ETrue indicates that the buffer contains a file name. EFalse indicates that the buffer contains the posted data. void* notifyData The context to be returned to the plug-in with the notification.

Returns

NPError status code

For the status code values, see NPP_New function table.

Description

The plug-in calls this function to request the browser to post to a URL. The browser informs the plug-in when the load request is complete.

Note

If the target window is NULL, pass the response to the plug-in.

If the target window is _parent, or _top, the browser initiates a load request to the given URL.

NPP_URLNotify

Plug-in API Type

NPP — implemented by the plug-in

Syntax

NPError NPP_URLNotify (NPP instance,

const TDesC& url,

const TDesC* target,

void* notifyData);

Parameters NPP instance The plug-in instance const TDesC& url URL of the NPN_GetURLNotify function or of the NPN_PostURLNotify function request const TDesC* target Reason code for completion of the request Values: One of the following: NPRES_DONE: Normal completion; all data was sent to the instance. This is the most common value. NPRES_USER_BREAK: The user canceled the stream directly. NPRES_NETWORK_ERR: The stream failed because of problems with the network, disk I/O error, lack of memory, or some other problem. void* notifyData Context to be returned to the plug-in with the notification

Returns

NPError status code

For the status code values, see NPP_New function table.

Description

Notifies the instance of the completion of a URL request made by the NPN_GetURLNotify function or the NPN_PostURLNotify function.

Memory Functions

NPN_MemAlloc

Plug-in API Type

NPN — implemented by the browser

Syntax

void* NPN_MemAlloc (uint32 size);

Parameters

uint32 size

The desired memory size

Returns

The allocated memory.

If this function fails to complete, it returns NULL.

Description

Allocates memory directly from the operating system on behalf of the plug-in.

NPN_MemFlush

This function has an empty implementation in the browser. If called, this function does nothing.

NPN_MemFree

Plug-in API Type

NPN — implemented by the browser

Syntax

void NPN_MemFree (void* ptr);

Parameters

void* ptr

A pointer to the memory to be freed.

Returns

None.

Description

Frees memory that was previously allocated by the browser.

Utility functions

NPN_ReloadPlugins

Plug-in API Type

NPN implemented by the browser

Syntax

void NPN_ReloadPlugins (NPBool reloadPages); 

Parameters

NPBool reloadPages

If set to true, the browser should reload the current page.

If set to false, the browser should not reload the current page.

Returns

None

Description

Requests the browser to rescan the file system for newly installed plug-ins.

NPN_Status

Plug-in API Type

NPN — implemented by the browser

Syntax

void NPN_Status (NPP instance,

const TDesC& message); 

Parameters

NPP instance

The plug-in instance

const TDesC& message

The message to display

Returns

None.

Description

Returns the current browser status. Displays a small message window at the top right corner.

Note

NPN_UserAgent

Plug-in API Type

NPN implemented by the browser

Syntax

const TDesC* NPN_UserAgent(NPP instance); 

Parameters

NPP instance

The plug-in instance

Returns

The User Agent string configured in the system.

Description

Returns the currently configured user agent to the plug-in.

NPN_Version

Plug-in API Type

NPN — implemented by the plug-in

Syntax

void NPN_Version (int* plugin_major,

int* plugin_minor,

int* netscape_major,

int* netscape_minor); 

Parameters

int* plugin_major

Pointer to the major version number of the plug-in

int* plugin_minor

Pointer to the minor version number of the plug-in

int* netscape_major

Pointer to the major version number of the browser

int* netscape_minor

Pointer to the minor version number of the browser

Returns

None

Description

Returns version information for the Browser Plug-in API.

Note

The plug-in can implement this function. The version parameter of the NPNetscapeFuncs class provides the correct version number.

The browser does not implement this function.

Java Communication Functions

The Browser Plug-in API does not support Java communication functions.

Extensions

MPluginAdapter Class

The plug-in can use this interface to communicate with the browser.

GetVersion

Syntax

TUint16 GetVersion (void);

Parameters

None

Returns

S60 returns 1.

Description

Gets the pointer to the minor version number of the plug-in version number of the Browser Plug-in API.

PluginConstructedL

Syntax

void PluginConstructedL (CCoeControl aControl);

Parameters

CCoeControl aControl

A pointer to the plug-in control window

Returns

None

Description

Called when the plug-in has completed its creation.

Note

This function is called from the constructL function of the plug-in.

PluginFinishedL

Syntax

void PluginFinishedL (void);

Parameters

None

Returns

None

Description

Called after the plug-in has been deleted.

Note

This function is called from the destructor of the plug-in.

OpenUrlL

Syntax

void OpenUrlL (const TDesC &aUrl);

Parameters

const TDesC &aUrl

Name of the URL to open

Returns

None

Description

Called by the plug-in to open a URL in the parent frame.

Note

This function is not implemented in the S60 platform.

OpenUrlInTargetWindowL

Syntax

void OpenUrlInTargetWindowL (

const TDesC &aUrl,

const TDesC &aTgtWnd);

Parameters

const TDesC &aUrl

The URL to open

const TDesC &aTgtWnd

The name of the target window or frame

Returns

None

Description

Called by the plug-in to open a URL in a named window or frame.

Note

This function is not implemented in the S60 platform.

HasNaviagationHistoryPrevious

Syntax

TBool HasNaviagationHistoryPrevious (void) const;

Parameters

None

Returns

true if the frame has a previous navigation history item false otherwise

Description

Specifies whether or not the frame has a previous navigation history item.

Note

This function is not implemented in the S60 platform.

LoadNaviagationHistoryPreviousL

Syntax

void LoadNaviagationHistoryNextL (void);

Parameters

None

Returns

None

Description

Informs the browser to load the next navigation history URL in its parent frame.

Note

This function is not implemented in the S60 platform.

HasNaviagationHistoryNext

Syntax

TBool HasNaviagationHistoryNext (void) const;

Parameters

None

Returns

true if the frame has a next navigation history item

false if the frame does not have a next navigation history item

Description

Returns whether the frame has a next navigation history item.

Note

This function is not implemented in the S60 platform.

LoadNaviagationHistoryNextL

Syntax

void LoadNaviagationHistoryNextL (void);

Parameters

None

Returns

None

Description

Informs the browser to load the next navigation history URL in its parent frame.

Note

This function is not implemented in the S60 platform.

GetParentControl

Syntax

CCoeControl* GetParentControl (void);

Parameters

None

Returns

A pointer to the parent control window.

Description

Returns the window system level control object for the plug-in.

GetParentControlObserver

Syntax

MCoeControlObserver* GetParentControlObserver (void);

Parameters

None

Returns

Observer that the plug-in can use to send events to the browser.

Description

Returns the observer for the plug-in control.

SetPluginNotifier

Syntax

void SetPluginNotifier (MPluginNotifier* aNotifier);

Parameters

MPluginNotifier* aNotifier

Pointer to an interface that the browser can use to send events to the plug-in.

Returns

None

Description

Sets the plug-in notifier allowing the plug-in to control portions of the browser.

MPluginNotifier Class

NotifyL

Syntax

TInt NotifyL (TNotificationType aCallType,

TAny *aParam);

Parameters TNotificationType aCallType The event type that is passed to the plug-in Values: 1 EEditCut 2 EEditCopy 3 EEditPaste 4 EEditDelete 5 EApplicationFocusChanged 6 ESystemNotification TAny *aParam The parameter associated with the event

Returns

Not used.

Description

Notifies the plug-in of an event.

Structures

NPByteRange

This structure is not supported in the S60 platform.

NPEmbedPrint

This structure is not supported in the S60 platform.

NPFullPrint

This structure is not supported in the S60 platform.

NPP

Syntax

typedef struct _NPP {     void* pdata;     void* ndata; } NPP_t;

Parameters

void* pdata

A private value that a plug-in can use to store a pointer to an internal data structure associated with the instance. The browser does not modify this value.

void* ndata

A private value that the browser uses to store data associated with the plug-in instance. The plug-in should not modify this value.

Description

The browser creates an NPP structure for each plug-in instance and passes a pointer to it to the NPP_New function. This pointer identifies the instance on which API calls should operate and represents the opaque instance handle of a plug-in. NPP contains private instance data for both the plug-in and the browser.

The NPP_Destroy function informs the plug-in when the NPP instance is about to be deleted. After this call returns, the NPP pointer is no longer valid.

Note

NPPrint

This structure is not supported in the S60 platform.

NPRect

Syntax

typedef struct _NPRect {     uint16  top;     uint16  left;     uint16  bottom;     uint16  right; } NPRect;

Parameters

uint16 top

The top of the rectangle

uint16 left

The left side of the rectangle

uint16 bottom

The bottom of the rectangle

uint16 right

The right side of the rectangle

Description

Defines the area of the plug-in window to be updated, painted, invalidated, or clipped to.

NPSavedData

This structure is not supported.

NPStream

Syntax

typedef struct _NPStream {     void*   pdata;     void*   ndata;     HBufC*  url;     uint32  end;     uint32  lastmodified;     void*   notifyData; } NPStream;

Parameters void*   pdata A private value that the plug-in can use to store a pointer to private data associated with the plug-in instance. The browser does not modify this value. void*   ndata A private value that can store data associated with the plug-in instance. The plug-in should not modify this value. HBufC*  url The URL from which the data in the stream is read or to which the data is written. uint32  end The offset, in bytes, of the end of the stream. This is equivalent to the length of the stream in bytes. This value can be zero for streams of unknown length, such as streams returned from older FTP servers or generated “on the fly” by CGI scripts. uint32  lastmodified The time at which the data in the URL was last modified (if applicable), measured in seconds since 12:00 midnight GMT, January 1, 1970. void*   notifyData This parameter is used only for streams generated in response to a NPN_GetURLNotify function or a NPN_PostURLNotify function request. Value: NPN_GetURLNotify function's notifyData parameter value NPN_PostURLNotify function's notifyData parameter value null for other streams

Description

The browser allocates and initializes the NPStream object and passes it to the plug-in instance as a parameter to the NPP_NewStream function. The browser cannot delete the object until after it calls the NPP_DestroyStream function.

NPWindow

Syntax

typedef struct _NPWindow {     void* window;     int32 x;     int32 y;     uint32  width;     uint32  height;     NPRect  clipRect;     NPWindowType type; } NPWindow;

Parameters void* window A handle to a native window element int32 x The x coordinate of the top left corner of the plug-in relative to the page. The plug-in should not modify this value. int32 y The y coordinate of the top left corner of the plug-in relative to the page. The plug-in should not modify this value. uint32  width The width of the plug-in area. The plug-in should not modify this value. uint32  height The height of the plug-in area. The plug-in should not modify this value. NPRect  clipRect The clipping rectangle of the plug-in. The origin is the top left corner of the window. Clipping to the clipRect prevents the plug-in from overwriting the status bar, scroll bars, and other page elements when partially scrolled off the screen. NPWindowType type Specifies whether the NPWindow instance represents a window or a drawable. Values: 1 NPWindowTypeWindow: Indicates that the window field holds a platform-specific handle to a window. The plug-in is considered windowed. 2 NPWindowTypeDrawable: Not supported in the S60 platform browsers.

Description

The NPWindow structure represents the native window. It contains information about coordinate position, size, and some platform-specific information.

A windowed plug-in is drawn into a native window (or portion of a native window) on a Web page. For windowed plug-ins, the browser calls the NPP_SetWindow function with an NPWindow structure that represents a drawable (a pointer to an NPWindow allocated by the browser). This window is valid until NPP_SetWindow is called again with a different window or the instance is destroyed.


Copyright © Nokia Corporation 2001-2008
Back to top