Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 /* Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 * Use of this source code is governed by a BSD-style license that can be | 2 * Use of this source code is governed by a BSD-style license that can be |
| 3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
| 4 */ | 4 */ |
| 5 #ifndef PPAPI_C_PPP_INSTANCE_H_ | 5 #ifndef PPAPI_C_PPP_INSTANCE_H_ |
| 6 #define PPAPI_C_PPP_INSTANCE_H_ | 6 #define PPAPI_C_PPP_INSTANCE_H_ |
| 7 | 7 |
| 8 #include "ppapi/c/pp_bool.h" | 8 #include "ppapi/c/pp_bool.h" |
| 9 #include "ppapi/c/pp_instance.h" | 9 #include "ppapi/c/pp_instance.h" |
| 10 #include "ppapi/c/pp_rect.h" | 10 #include "ppapi/c/pp_rect.h" |
| 11 #include "ppapi/c/pp_resource.h" | 11 #include "ppapi/c/pp_resource.h" |
| 12 | 12 |
| 13 struct PP_InputEvent; | 13 struct PP_InputEvent; |
| 14 struct PP_Var; | 14 struct PP_Var; |
| 15 | 15 |
| 16 #define PPP_INSTANCE_INTERFACE "PPP_Instance;0.4" | 16 #define PPP_INSTANCE_INTERFACE "PPP_Instance;0.4" |
| 17 | 17 |
| 18 /** | 18 /** |
| 19 * @file | 19 * @file |
| 20 * Defines the API ... | 20 * This file defines the PPP_Instance structure - a series of points to methods |
| 21 * that you must implement in your model. | |
| 21 * | 22 * |
| 22 */ | 23 */ |
| 23 | 24 |
| 24 /** @addtogroup Interfaces | 25 /** @addtogroup Interfaces |
| 25 * @{ | 26 * @{ |
| 26 */ | 27 */ |
| 27 | 28 |
| 29 /** | |
| 30 * The PPP_Instance interface contains pointers to a series of functions that | |
| 31 * you must implement in your module. These functions can be trivial (0 lines | |
| 32 * or 1 line to return the default return value) unless you want your module | |
|
dmichael(do not use this one)
2011/02/11 16:42:04
I didn't really expect that 0 lines or 1 line word
jond
2011/02/15 17:02:47
Done.
dmichael(do not use this one)
2011/02/15 19:30:38
I meant you could take out '(0 lines or 1 line to
| |
| 33 * to handle events such as change of focus or input events (keyboard/mouse) | |
| 34 * events. | |
| 35 */ | |
| 36 | |
| 28 struct PPP_Instance { | 37 struct PPP_Instance { |
| 29 /** | 38 /** |
| 30 * Called when a new plugin is instantiated on the web page. The identifier | 39 * This value represents a pointer to a function that is called when a new |
| 31 * of the new instance will be passed in as the first argument (this value is | 40 * module is instantiated on the web page. The identifier of the new |
| 32 * generated by the browser and is an opaque handle). | 41 * instance will be passed in as the first argument (this value is |
| 42 * generated by the browser and is an opaque handle). This is called for each | |
| 43 * instantiation of the NaCl module, which is each time the <embed> tag for | |
| 44 * this module is encountered. | |
| 33 * | 45 * |
| 34 * It's possible for more than one plugin instance to be created within the | 46 * It's possible for more than one module instance to be created |
| 35 * same module (i.e. you may get more than one OnCreate without an OnDestroy | 47 * (i.e. you may get more than one OnCreate without an OnDestroy |
| 36 * in between). | 48 * in between). |
| 37 * | 49 * |
| 38 * If the plugin reports failure from this function, the plugin will be | 50 * If this function reports a failure (by returning @a PP_FALSE), the NaCl |
| 39 * deleted and OnDestroy will be called. | 51 * module will be deleted and DidDestroy will be called. |
| 52 * | |
| 53 * @param[in] instance A PP_Instance indentifying one instance of a module. | |
| 54 * @param[in] argc The number of arguments contained in @a argn and @a argv. | |
| 55 * @param[in] argn An array of argument names. These argument names are | |
| 56 * supplied in the <embed> tag, for example: | |
| 57 * <embed id="nacl_module" dimensions="2"> will produce two argument | |
| 58 * names: "id" and "dimensions." | |
| 59 * @param[in] argv An array of argument values. These are the values of the | |
| 60 * arguments listed in the <embed> tag, for example | |
|
dmichael(do not use this one)
2011/02/11 16:42:04
nit: period to end the last sentence.
jond
2011/02/15 17:02:47
Not sure where this is needed. The sentence goes b
dmichael(do not use this one)
2011/02/15 19:30:38
You're right, my mistake.
| |
| 61 * <embed id="nacl_module" dimensions="2"> will produce two argument | |
| 62 * values: "nacl_module" and "2." The indices of these values match the | |
| 63 * indices of the corresponding names in @a argn. | |
| 64 * @return @a PP_TRUE on success. | |
| 40 */ | 65 */ |
| 41 PP_Bool (*DidCreate)(PP_Instance instance, | 66 PP_Bool (*DidCreate)(PP_Instance instance, |
| 42 uint32_t argc, | 67 uint32_t argc, |
| 43 const char* argn[], | 68 const char* argn[], |
| 44 const char* argv[]); | 69 const char* argv[]); |
| 45 | 70 |
| 46 /** | 71 /** |
| 47 * Called when the plugin instance is destroyed. This will always be called, | 72 * This value represents a pointer to a function that is called when the |
| 48 * even if Create returned failure. The plugin should deallocate any data | 73 * module instance is destroyed. This function will always be called, |
| 74 * even if DidCreate returned failure. The function should deallocate any data | |
| 49 * associated with the instance. | 75 * associated with the instance. |
| 76 * | |
| 77 * @param[in] instance A PP_Instance indentifying one instance of a module. | |
| 50 */ | 78 */ |
| 51 void (*DidDestroy)(PP_Instance instance); | 79 void (*DidDestroy)(PP_Instance instance); |
| 52 | 80 |
| 53 /** | 81 /** |
| 54 * Called when the position, the size, or the clip rect has changed. | 82 * This value represents a pointer to a function that is called when the |
| 83 * position, the size, or the clip rectangle of the element in the | |
| 84 * browser that corresponds to this NaCl module has changed. | |
| 55 * | 85 * |
| 56 * The |position| is the location on the page of this plugin instance. This is | 86 * @param[in] instance A PP_Instance indentifying one instance of a module. |
| 57 * relative to the top left corner of the viewport, which changes as the page | 87 * @param[in] position The location on the page of this NaCl module. This is |
| 58 * is scrolled. | 88 * relative to the top left corner of the viewport, which changes as the |
| 59 * | 89 * page is scrolled. |
| 60 * The |clip| indicates the visible region of the plugin instance. This is | 90 * @param[in] clip The visible region of the NaCl module. This is relative to |
| 61 * relative to the top left of the plugin's coordinate system (not the page). | 91 * the top left of the plugin's coordinate system (not the page). If the |
| 62 * If the plugin is invisible, the clip rect will be (0, 0, 0, 0). | 92 * plugin is invisible, @a clip will be (0, 0, 0, 0). |
| 63 */ | 93 */ |
| 64 void (*DidChangeView)(PP_Instance instance, | 94 void (*DidChangeView)(PP_Instance instance, |
| 65 const struct PP_Rect* position, | 95 const struct PP_Rect* position, |
| 66 const struct PP_Rect* clip); | 96 const struct PP_Rect* clip); |
| 67 | 97 |
| 68 /** | 98 /** |
| 69 * Notification that the given plugin instance has gained or lost focus. | 99 * This value represents a pointer to a function to handle when your module |
| 70 * Having focus means that keyboard events will be sent to your plugin | 100 * has gained or lost focus. Having focus means that keyboard events will be |
| 71 * instance. A plugin's default condition is that it will not have focus. | 101 * sent to the module. A module's default condition is that it will |
| 102 * not have focus. | |
| 72 * | 103 * |
| 73 * Note: clicks on your plugins will give focus only if you handle the | 104 * Note: clicks on modules will give focus only if you handle the |
| 74 * click event. You signal if you handled it by returning true from | 105 * click event. Return @a true from HandleInputEvent to signal that the click |
| 75 * HandleInputEvent. Otherwise the browser will bubble the event and give | 106 * event was handled. Otherwise the browser will bubble the event and give |
| 76 * focus to the element on the page that actually did end up consuming it. | 107 * focus to the element on the page that actually did end up consuming it. |
| 77 * If you're not getting focus, check to make sure you're returning true from | 108 * If you're not getting focus, check to make sure you're returning true from |
| 78 * the mouse click in HandleInputEvent. | 109 * the mouse click in HandleInputEvent. |
| 110 * @param[in] instance A PP_Instance indentifying one instance of a module. | |
| 111 * @param[in] has_focus Indicates whether this NaCl module gained or lost | |
| 112 * event focus. | |
| 79 */ | 113 */ |
| 80 void (*DidChangeFocus)(PP_Instance instance, PP_Bool has_focus); | 114 void (*DidChangeFocus)(PP_Instance instance, PP_Bool has_focus); |
| 81 | 115 |
| 82 /** | 116 /** |
| 83 * General handler for input events. Returns true if the event was handled or | 117 * This value represents a pointer to a function to handle input events. |
| 84 * false if it was not. | 118 * Returns true if the event was handled or false if it was not. |
| 85 * | 119 * |
| 86 * If the event was handled, it will not be forwarded to the web page or | 120 * If the event was handled, it will not be forwarded to the web page or |
| 87 * browser. If it was not handled, it will bubble according to the normal | 121 * browser. If it was not handled, it will bubble according to the normal |
| 88 * rules. So it is important that a plugin respond accurately with whether | 122 * rules. So it is important that a module respond accurately with whether |
| 89 * event propogation should continue. | 123 * event propogation should continue. |
| 90 * | 124 * |
| 91 * Event propogation also controls focus. If you handle an event like a mouse | 125 * Event propogation also controls focus. If you handle an event like a mouse |
| 92 * event, typically your plugin will be given focus. Returning false means | 126 * event, typically your module will be given focus. Returning false means |
| 93 * that the click will be given to a lower part of the page and the plugin | 127 * that the click will be given to a lower part of the page and your module |
| 94 * will not receive focus. This allows a plugin to be partially transparent, | 128 * will not receive focus. This allows a module to be partially transparent, |
| 95 * where clicks on the transparent areas will behave like clicks to the | 129 * where clicks on the transparent areas will behave like clicks to the |
| 96 * underlying page. | 130 * underlying page. |
| 131 * @param[in] instance A PP_Instance indentifying one instance of a module. | |
| 132 * @param[in] event The event. | |
| 133 * @return PP_TRUE if @a event was handled, PP_FALSE otherwise. | |
| 97 */ | 134 */ |
| 98 PP_Bool (*HandleInputEvent)(PP_Instance instance, | 135 PP_Bool (*HandleInputEvent)(PP_Instance instance, |
| 99 const struct PP_InputEvent* event); | 136 const struct PP_InputEvent* event); |
| 100 | 137 |
| 101 /** | 138 /** |
| 102 * Called after Initialize for a full-frame plugin that was instantiated | 139 * This value represents a pointer to a function that is called after |
| 103 * based on the MIME type of a DOMWindow navigation. This only applies to | 140 * initialize for a full-frame plugin that was instantiated based on the MIME |
| 104 * plugins that are registered to handle certain MIME types (not current | 141 * type of a DOMWindow navigation. This only applies to modules that are |
| 105 * Native Client plugins). | 142 * registered to handle certain MIME types (not current Native Client |
| 143 * modules). | |
| 106 * | 144 * |
| 107 * The given url_loader corresponds to a PPB_URLLoader instance that is | 145 * The given url_loader corresponds to a PPB_URLLoader instance that is |
| 108 * already opened. Its response headers may be queried using | 146 * already opened. Its response headers may be queried using |
| 109 * PPB_URLLoader::GetResponseInfo. The url loader is not addrefed on behalf | 147 * PPB_URLLoader::GetResponseInfo. The url loader is not addrefed on behalf |
| 110 * of the plugin, if you're going to keep a reference to it, you need to | 148 * of the module, if you're going to keep a reference to it, you need to |
| 111 * addref it yourself. | 149 * addref it yourself. |
| 112 * | 150 * |
| 113 * This method returns PP_FALSE if the plugin cannot handle the data. In | 151 * This method returns PP_FALSE if the module cannot handle the data. In |
| 114 * response to this method, the plugin should call ReadResponseBody to read | 152 * response to this method, the module should call ReadResponseBody to read |
| 115 * the incoming data. | 153 * the incoming data. |
| 154 * @param[in] instance A PP_Instance indentifying one instance of a module. | |
| 155 * @param[in] url_loader A PP_Resource an open PPB_URLLoader instance. | |
| 156 * @return PP_TRUE if the data was handled, PP_FALSE otherwise. | |
| 116 */ | 157 */ |
| 117 PP_Bool (*HandleDocumentLoad)(PP_Instance instance, PP_Resource url_loader); | 158 PP_Bool (*HandleDocumentLoad)(PP_Instance instance, PP_Resource url_loader); |
| 118 | 159 |
| 119 /** | 160 /** |
| 120 * Returns a Var representing the instance object to the web page. Normally | 161 * This value represents a pointer to a function that returns a Var |
| 162 * representing the scriptable object for the given instance. Normally | |
| 121 * this will be a PPP_Class object that exposes certain methods the page | 163 * this will be a PPP_Class object that exposes certain methods the page |
| 122 * may want to call. | 164 * may want to call. |
| 123 * | 165 * |
| 124 * On Failure, the returned var should be a "void" var. | 166 * On Failure, the returned var should be a "void" var. |
| 125 * | 167 * |
| 126 * The returned PP_Var should have a reference added for the caller, which | 168 * The returned PP_Var should have a reference added for the caller, which |
| 127 * will be responsible for Release()ing that reference. | 169 * will be responsible for Release()ing that reference. |
| 170 * | |
| 171 * @param[in] instance A PP_Instance indentifying one instance of a module. | |
| 172 * @return A PP_Var containing scriptable object. | |
| 128 */ | 173 */ |
| 129 struct PP_Var (*GetInstanceObject)(PP_Instance instance); | 174 struct PP_Var (*GetInstanceObject)(PP_Instance instance); |
| 130 }; | 175 }; |
| 131 /** | 176 /** |
| 132 * @} | 177 * @} |
| 133 */ | 178 */ |
| 134 | 179 |
| 135 #endif /* PPAPI_C_PPP_INSTANCE_H_ */ | 180 #endif /* PPAPI_C_PPP_INSTANCE_H_ */ |
| 136 | 181 |
| OLD | NEW |