Native Client

PPP_Instance Struct Reference

The PPP_Instance interface contains pointers to a series of functions that you must implement in your module. More...

Detailed Description

The PPP_Instance interface contains pointers to a series of functions that you must implement in your module.

These functions can be trivial (simply return the default return value) unless you want your module to handle events such as change of focus or input events (keyboard/mouse) events.

Data Fields List

PP_Bool(* DidCreate )(PP_Instance instance, uint32_t argc, const char *argn[], const char *argv[])
void(* DidDestroy )(PP_Instance instance)
void(* DidChangeView )(PP_Instance instance, PP_Resource view)
void(* DidChangeFocus )(PP_Instance instance, PP_Bool has_focus)
PP_Bool(* HandleDocumentLoad )(PP_Instance instance, PP_Resource url_loader)

Data Fields Details

void(* PPP_Instance::DidChangeFocus)(PP_Instance instance, PP_Bool has_focus)

DidChangeFocus() is called when an instance has gained or lost focus.

Having focus means that keyboard events will be sent to the instance. An instance's default condition is that it will not have focus.

The focus flag takes into account both browser tab and window focus as well as focus of the plugin element on the page. In order to be deemed to have focus, the browser window must be topmost, the tab must be selected in the window, and the instance must be the focused element on the page.

Note:Clicks on instances will give focus only if you handle the click event. Return true from HandleInputEvent in PPP_InputEvent (or use unfiltered events) to signal that the click event was handled. Otherwise, the browser will bubble the event and give focus to the element on the page that actually did end up consuming it. If you're not getting focus, check to make sure you're either requesting them via RequestInputEvents() (which implicitly marks all input events as consumed) or via RequestFilteringInputEvents() and returning true from your event handler.

[in]instanceA PP_Instance identifying the instance receiving the input event.
[in]has_focusIndicates the new focused state of the instance.

DidChangeView() is called when the position, size, or other view attributes of the instance has changed.

PP_Bool(* PPP_Instance::DidCreate)(PP_Instance instance, uint32_t argc, const char *argn[], const char *argv[])

DidCreate() is a creation handler that is called when a new instance is created.

This function is called for each instantiation on the page, corresponding to one <embed> tag on the page.

Generally you would handle this call by initializing the information your module associates with an instance and creating a mapping from the given PP_Instance handle to this data. The PP_Instance handle will be used in subsequent calls to identify which instance the call pertains to.

It's possible for more than one instance to be created in a single module. This means that you may get more than one OnCreate without an OnDestroy in between, and should be prepared to maintain multiple states associated with each instance.

If this function reports a failure (by returning PP_FALSE), the instance will be deleted.

[in]instanceA new PP_Instance identifying one instance of a module. This is an opaque handle.
[in]argcThe number of arguments contained in argn and argv.
[in]argnAn array of argument names. These argument names are supplied in the <embed> tag, for example: <embed id="nacl_module" dimensions="2"> will produce two argument names: "id" and "dimensions."
[in]argvAn array of argument values. These are the values of the arguments listed in the <embed> tag, for example <embed id="nacl_module" dimensions="2"> will produce two argument values: "nacl_module" and "2". The indices of these values match the indices of the corresponding names in argn.
PP_TRUE on success or PP_FALSE on failure.

DidDestroy() is an instance destruction handler.

This function is called in many cases (see below) when a module instance is destroyed. It will be called even if DidCreate() returned failure.

Generally you will handle this call by deallocating the tracking information and the PP_Instance mapping you created in the DidCreate() call. You can also free resources associated with this instance but this isn't required; all resources associated with the deleted instance will be automatically freed when this function returns.

The instance identifier will still be valid during this call, so the module can perform cleanup-related tasks. Once this function returns, the PP_Instance handle will be invalid. This means that you can't do any asynchronous operations like network requests, file writes or messaging from this function since they will be immediately canceled.

Note: This function will always be skipped on untrusted (Native Client) implementations. This function may be skipped on trusted implementations in certain circumstances when Chrome does "fast shutdown" of a web page. Fast shutdown will happen in some cases when all module instances are being deleted, and no cleanup functions will be called. The module will just be unloaded and the process terminated.

[in]instanceA PP_Instance identifying one instance of a module.

HandleDocumentLoad() is called after initialize for a full-frame instance that was instantiated based on the MIME type of a DOMWindow navigation.

This situation only applies to modules that are pre-registered to handle certain MIME types. If you haven't specifically registered to handle a MIME type or aren't positive this applies to you, your implementation of this function can just return PP_FALSE.

The given url_loader corresponds to a PPB_URLLoader instance that is already opened. Its response headers may be queried using PPB_URLLoader::GetResponseInfo. The reference count for the URL loader is not incremented automatically on behalf of the module. You need to increment the reference count yourself if you are going to keep a reference to it.

This method returns PP_FALSE if the module cannot handle the data. In response to this method, the module should call ReadResponseBody() to read the incoming data.

[in]instanceA PP_Instance identifying the instance that should do the load.
[in]url_loaderAn open PPB_URLLoader instance.
PP_TRUE if the data was handled, PP_FALSE otherwise. If you return false, the load will be canceled for you.

The documentation for this struct was generated from the following file:

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.