Visit Mozilla.org

NPSavedData

From MDC

« Gecko Plugin API Reference « Plug-in Side Plug-in API

Contents

[edit] Summary

Block of instance information saved after the plug-in is deleted; can be returned to the plug-in.

[edit] Syntax

typedef struct _NPSavedData
{
    int32  len;
    void*  buf;
} NPSavedData;

[edit] Fields

The data structure has the following fields:

len
Length in bytes of the buffer pointed to by buf; set by the plug-in.
buf
Pointer to a memory buffer allocated by the plug-in with NPN_MemAlloc. Can be any reasonable size; its contents are private to the plug-in and are not modified by the browser.

[edit] Description

The NPSavedData object contains a block of per-instance information that Communicator saves after the instance is deleted. This information can be returned to another instance of the same plug-in if the user returns to the web page that contains it.

You can use the plug-in's NPP_Destroy function to allocate an NPSavedData object using the NPN_MemAlloc function, fill in the fields, and return it to the browser as an output parameter. See "Instance Destruction" for a code example that shows how to use NPSavedData.

If the user revisits a web page that contains a plug-in, the browser returns the NPSavedData to the new instance of the plug-in in a call to NPP_New. After this, the plug-in is responsible for keeping or deleting the objects as necessary.

[edit] See Also

NPP_New, NPP_Destroy