| OLD | NEW |
| 1 /* Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 /* Copyright (c) 2011 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 |
| 6 /* From ppp_instance.idl modified Sat Jul 16 16:50:26 2011. */ |
| 7 |
| 5 #ifndef PPAPI_C_PPP_INSTANCE_H_ | 8 #ifndef PPAPI_C_PPP_INSTANCE_H_ |
| 6 #define PPAPI_C_PPP_INSTANCE_H_ | 9 #define PPAPI_C_PPP_INSTANCE_H_ |
| 7 | 10 |
| 8 #include "ppapi/c/pp_bool.h" | 11 #include "ppapi/c/pp_bool.h" |
| 12 #include "ppapi/c/pp_input_event.h" |
| 9 #include "ppapi/c/pp_instance.h" | 13 #include "ppapi/c/pp_instance.h" |
| 14 #include "ppapi/c/pp_macros.h" |
| 15 #include "ppapi/c/pp_point.h" |
| 10 #include "ppapi/c/pp_rect.h" | 16 #include "ppapi/c/pp_rect.h" |
| 11 #include "ppapi/c/pp_resource.h" | 17 #include "ppapi/c/pp_resource.h" |
| 12 | 18 #include "ppapi/c/pp_size.h" |
| 13 struct PP_InputEvent; | 19 #include "ppapi/c/pp_stdint.h" |
| 14 | 20 #include "ppapi/c/pp_time.h" |
| 15 #define PPP_INSTANCE_INTERFACE_0_5 "PPP_Instance;0.5" | 21 #include "ppapi/c/ppb_input_event.h" |
| 16 #define PPP_INSTANCE_INTERFACE PPP_INSTANCE_INTERFACE_0_5 | |
| 17 | 22 |
| 18 /** | 23 /** |
| 19 * @file | 24 * @file |
| 20 * This file defines the <code>PPP_Instance</code> structure - a series of | 25 * This file defines the <code>PPP_Instance</code> structure - a series of |
| 21 * pointers to methods that you must implement in your module. | 26 * pointers to methods that you must implement in your module. |
| 22 */ | 27 */ |
| 23 | 28 |
| 24 /** @addtogroup Interfaces | 29 |
| 30 /** |
| 31 * @addtogroup Interfaces |
| 25 * @{ | 32 * @{ |
| 26 */ | 33 */ |
| 27 | |
| 28 /** | 34 /** |
| 29 * The <code>PPP_Instance</code> interface contains pointers to a series of | 35 * The <code>PPP_Instance</code> interface contains pointers to a series of |
| 30 * functions that you must implement in your module. These functions can be | 36 * functions that you must implement in your module. These functions can be |
| 31 * trivial (simply return the default return value) unless you want your module | 37 * trivial (simply return the default return value) unless you want your module |
| 32 * to handle events such as change of focus or input events (keyboard/mouse) | 38 * to handle events such as change of focus or input events (keyboard/mouse) |
| 33 * events. | 39 * events. |
| 34 */ | 40 */ |
| 41 #define PPP_INSTANCE_INTERFACE_0_5 "PPP_Instance;0.5" |
| 42 #define PPP_INSTANCE_INTERFACE PPP_INSTANCE_INTERFACE_0_5 |
| 35 | 43 |
| 36 struct PPP_Instance { | 44 struct PPP_Instance { |
| 37 /** | 45 /** |
| 38 * DidCreate() is a creation handler that is called when a new instance is | 46 * DidCreate() is a creation handler that is called when a new instance is |
| 39 * created. This function is called for each instantiation on the page, | 47 * created. This function is called for each instantiation on the page, |
| 40 * corresponding to one \<embed\> tag on the page. | 48 * corresponding to one \<embed\> tag on the page. |
| 41 * | 49 * |
| 42 * Generally you would handle this call by initializing the information | 50 * Generally you would handle this call by initializing the information |
| 43 * your module associates with an instance and creating a mapping from the | 51 * your module associates with an instance and creating a mapping from the |
| 44 * given <code>PP_Instance</code> handle to this data. The | 52 * given <code>PP_Instance</code> handle to this data. The |
| (...skipping 25 matching lines...) Expand all Loading... |
| 70 * argument values: "nacl_module" and "2". The indices of these values match | 78 * argument values: "nacl_module" and "2". The indices of these values match |
| 71 * the indices of the corresponding names in <code>argn</code>. | 79 * the indices of the corresponding names in <code>argn</code>. |
| 72 * | 80 * |
| 73 * @return <code>PP_TRUE</code> on success or <code>PP_FALSE</code> on | 81 * @return <code>PP_TRUE</code> on success or <code>PP_FALSE</code> on |
| 74 * failure. | 82 * failure. |
| 75 */ | 83 */ |
| 76 PP_Bool (*DidCreate)(PP_Instance instance, | 84 PP_Bool (*DidCreate)(PP_Instance instance, |
| 77 uint32_t argc, | 85 uint32_t argc, |
| 78 const char* argn[], | 86 const char* argn[], |
| 79 const char* argv[]); | 87 const char* argv[]); |
| 80 | |
| 81 /** | 88 /** |
| 82 * DidDestroy() is an instance destruction handler. This function is called | 89 * DidDestroy() is an instance destruction handler. This function is called |
| 83 * in many cases (see below) when a module instance is destroyed. It will be | 90 * in many cases (see below) when a module instance is destroyed. It will be |
| 84 * called even if DidCreate() returned failure. | 91 * called even if DidCreate() returned failure. |
| 85 * | 92 * |
| 86 * Generally you will handle this call by deallocating the tracking | 93 * Generally you will handle this call by deallocating the tracking |
| 87 * information and the <code>PP_Instance</code> mapping you created in the | 94 * information and the <code>PP_Instance</code> mapping you created in the |
| 88 * DidCreate() call. You can also free resources associated with this | 95 * DidCreate() call. You can also free resources associated with this |
| 89 * instance but this isn't required; all resources associated with the deleted | 96 * instance but this isn't required; all resources associated with the deleted |
| 90 * instance will be automatically freed when this function returns. | 97 * instance will be automatically freed when this function returns. |
| 91 * | 98 * |
| 92 * The instance identifier will still be valid during this call so the module | 99 * The instance identifier will still be valid during this call so the module |
| 93 * can perform cleanup-related tasks. Once this function returns, the | 100 * can perform cleanup-related tasks. Once this function returns, the |
| 94 * <code>PP_Instance</code> handle will be invalid. This means that you can't | 101 * <code>PP_Instance</code> handle will be invalid. This means that you can't |
| 95 * do any asynchronous operations like network requests or file writes from | 102 * do any asynchronous operations like network requests or file writes from |
| 96 * this function since they will be immediately canceled. | 103 * this function since they will be immediately canceled. |
| 97 * | 104 * |
| 98 * <strong>Note:</strong> This function may be skipped in certain | 105 * <strong>Note:</strong> This function may be skipped in certain |
| 99 * circumstances when Chrome does "fast shutdown". Fast shutdown will happen | 106 * circumstances when Chrome does "fast shutdown". Fast shutdown will happen |
| 100 * in some cases when all module instances are being deleted, and no cleanup | 107 * in some cases when all module instances are being deleted, and no cleanup |
| 101 * functions will be called. The module will just be unloaded and the process | 108 * functions will be called. The module will just be unloaded and the process |
| 102 * terminated. | 109 * terminated. |
| 103 * | 110 * |
| 104 * @param[in] instance A <code>PP_Instance</code> indentifying one instance | 111 * @param[in] instance A <code>PP_Instance</code> indentifying one instance |
| 105 * of a module. | 112 * of a module. |
| 106 */ | 113 */ |
| 107 void (*DidDestroy)(PP_Instance instance); | 114 void (*DidDestroy)(PP_Instance instance); |
| 108 | |
| 109 /** | 115 /** |
| 110 * DidChangeView() is called when the position, the size, of the clip | 116 * DidChangeView() is called when the position, the size, of the clip |
| 111 * rectangle of the element in the browser that corresponds to this | 117 * rectangle of the element in the browser that corresponds to this |
| 112 * instance has changed. | 118 * instance has changed. |
| 113 * | 119 * |
| 114 * A typical implementation will check the size of the <code>position</code> | 120 * A typical implementation will check the size of the <code>position</code> |
| 115 * argument and reallocate the graphics context when a different size is | 121 * argument and reallocate the graphics context when a different size is |
| 116 * received. Note that this function will be called for scroll events where | 122 * received. Note that this function will be called for scroll events where |
| 117 * the size doesn't change, so you should always check that the size is | 123 * the size doesn't change, so you should always check that the size is |
| 118 * actually different before doing any reallocations. | 124 * actually different before doing any reallocations. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 135 * not usually worthwhile, however, to generate partial updates according to | 141 * not usually worthwhile, however, to generate partial updates according to |
| 136 * the clip when the instance is partially visible. Instead, update the entire | 142 * the clip when the instance is partially visible. Instead, update the entire |
| 137 * region. The time saved doing partial paints is usually not significant and | 143 * region. The time saved doing partial paints is usually not significant and |
| 138 * it can create artifacts when scrolling (this notification is sent | 144 * it can create artifacts when scrolling (this notification is sent |
| 139 * asynchronously from scolling so there can be flashes of old content in the | 145 * asynchronously from scolling so there can be flashes of old content in the |
| 140 * exposed regions). | 146 * exposed regions). |
| 141 */ | 147 */ |
| 142 void (*DidChangeView)(PP_Instance instance, | 148 void (*DidChangeView)(PP_Instance instance, |
| 143 const struct PP_Rect* position, | 149 const struct PP_Rect* position, |
| 144 const struct PP_Rect* clip); | 150 const struct PP_Rect* clip); |
| 145 | |
| 146 /** | 151 /** |
| 147 * DidChangeFocus() is called when an instance has gained or lost focus. | 152 * DidChangeFocus() is called when an instance has gained or lost focus. |
| 148 * Having focus means that keyboard events will be sent to the instance. | 153 * Having focus means that keyboard events will be sent to the instance. |
| 149 * An instance's default condition is that it will not have focus. | 154 * An instance's default condition is that it will not have focus. |
| 150 * | 155 * |
| 151 * <strong>Note:</strong>Clicks on instances will give focus only if you | 156 * <strong>Note:</strong>Clicks on instances will give focus only if you |
| 152 * handle the click event. Return <code>true</code> from HandleInputEvent to | 157 * handle the click event. Return <code>true</code> from HandleInputEvent to |
| 153 * signal that the click event was handled. Otherwise the browser will bubble | 158 * signal that the click event was handled. Otherwise the browser will bubble |
| 154 * the event and give focus to the element on the page that actually did end | 159 * the event and give focus to the element on the page that actually did end |
| 155 * up consuming it. If you're not getting focus, check to make sure you're | 160 * up consuming it. If you're not getting focus, check to make sure you're |
| 156 * returning true from the mouse click in <code>HandleInputEvent</code>. | 161 * returning true from the mouse click in <code>HandleInputEvent</code>. |
| 157 * | 162 * |
| 158 * @param[in] instance A <code>PP_Instance</code> indentifying the instance | 163 * @param[in] instance A <code>PP_Instance</code> indentifying the instance |
| 159 * receiving the input event. | 164 * receiving the input event. |
| 160 * | 165 * |
| 161 * @param[in] has_focus Indicates the new focused state of the instance. | 166 * @param[in] has_focus Indicates the new focused state of the instance. |
| 162 */ | 167 */ |
| 163 void (*DidChangeFocus)(PP_Instance instance, PP_Bool has_focus); | 168 void (*DidChangeFocus)(PP_Instance instance, PP_Bool has_focus); |
| 164 | |
| 165 /** | 169 /** |
| 166 * HandleInputEvent() handles input events, such as keyboard events. This | 170 * HandleInputEvent() handles input events, such as keyboard events. This |
| 167 * function returns <code>PP_TRUE</code> if the event was handled or | 171 * function returns <code>PP_TRUE</code> if the event was handled or |
| 168 * <code>PP_FALSE</code> if it was not. | 172 * <code>PP_FALSE</code> if it was not. |
| 169 * | 173 * |
| 170 * If the event was handled, it will not be forwarded to the web page or | 174 * If the event was handled, it will not be forwarded to the web page or |
| 171 * browser. If it was not handled, it will bubble according to the normal | 175 * browser. If it was not handled, it will bubble according to the normal |
| 172 * rules. So it is important that a module respond accurately with whether | 176 * rules. So it is important that a module respond accurately with whether |
| 173 * event propagation should continue. | 177 * event propagation should continue. |
| 174 * | 178 * |
| 175 * Event propagation also controls focus. If you handle an event like a mouse | 179 * Event propagation also controls focus. If you handle an event like a mouse |
| 176 * event, typically the instance will be given focus. Returning false means | 180 * event, typically the instance will be given focus. Returning false means |
| 177 * that the click will be given to a lower part of the page and your module | 181 * that the click will be given to a lower part of the page and your module |
| 178 * will not receive focus. This allows an instance to be partially | 182 * will not receive focus. This allows an instance to be partially |
| 179 * transparent, where clicks on the transparent areas will behave like clicks | 183 * transparent, where clicks on the transparent areas will behave like clicks |
| 180 * to the underlying page. | 184 * to the underlying page. |
| 181 * | 185 * |
| 182 * @param[in] instance A <code>PP_Instance</code> indentifying one instance | 186 * @param[in] instance A <code>PP_Instance</code> indentifying one instance |
| 183 * of a module. | 187 * of a module. |
| 184 * | 188 * |
| 185 * @param[in] event The input event. | 189 * @param[in] event The input event. |
| 186 * | 190 * |
| 187 * @return <code>PP_TRUE</code> if <code>event</code> was handled, | 191 * @return <code>PP_TRUE</code> if <code>event</code> was handled, |
| 188 * <code>PP_FALSE</code> otherwise. | 192 * <code>PP_FALSE</code> otherwise. |
| 189 */ | 193 */ |
| 190 PP_Bool (*HandleInputEvent)(PP_Instance instance, | 194 PP_Bool (*HandleInputEvent)(PP_Instance instance, |
| 191 const struct PP_InputEvent* event); | 195 const struct PP_InputEvent* event); |
| 192 | |
| 193 /** | 196 /** |
| 194 * HandleDocumentLoad() is called after initialize for a full-frame | 197 * HandleDocumentLoad() is called after initialize for a full-frame |
| 195 * module that was instantiated based on the MIME type of a DOMWindow | 198 * module that was instantiated based on the MIME type of a DOMWindow |
| 196 * navigation. This situation only applies to modules that are pre-registered | 199 * navigation. This situation only applies to modules that are pre-registered |
| 197 * to handle certain MIME types. If you haven't specifically registered to | 200 * to handle certain MIME types. If you haven't specifically registered to |
| 198 * handle a MIME type or aren't positive this applies to you, your | 201 * handle a MIME type or aren't positive this applies to you, your |
| 199 * implementation of this function can just return <code>PP_FALSE</code>. | 202 * implementation of this function can just return <code>PP_FALSE</code>. |
| 200 * | 203 * |
| 201 * The given <code>url_loader</code> corresponds to a | 204 * The given <code>url_loader</code> corresponds to a |
| 202 * <code>PPB_URLLoader</code> instance that is already opened. Its response | 205 * <code>PPB_URLLoader</code> instance that is already opened. Its response |
| 203 * headers may be queried using <code>PPB_URLLoader::GetResponseInfo</code>. | 206 * headers may be queried using <code>PPB_URLLoader::GetResponseInfo</code>. |
| 204 * The reference count for the URL loader is not incremented automatically on | 207 * The reference count for the URL loader is not incremented automatically on |
| 205 * behalf of the module. You need to increment the reference count yourself | 208 * behalf of the module. You need to increment the reference count yourself |
| 206 * if you are going to keep a reference to it. | 209 * if you are going to keep a reference to it. |
| 207 * | 210 * |
| 208 * This method returns <code>PP_FALSE</code> if the module cannot handle the | 211 * This method returns <code>PP_FALSE</code> if the module cannot handle the |
| 209 * data. In response to this method, the module should call | 212 * data. In response to this method, the module should call |
| 210 * ReadResponseBody() to read the incoming data. | 213 * ReadResponseBody() to read the incoming data. |
| 211 * | 214 * |
| 212 * @param[in] instance A <code>PP_Instance</code> indentifying the instance | 215 * @param[in] instance A <code>PP_Instance</code> indentifying the instance |
| 213 * that should do the load. | 216 * that should do the load. |
| 214 * | 217 * |
| 215 * @param[in] url_loader An open <code>PPB_URLLoader</code> instance. | 218 * @param[in] url_loader An open <code>PPB_URLLoader</code> instance. |
| 216 * | 219 * |
| 217 * @return <code>PP_TRUE</code> if the data was handled, | 220 * @return <code>PP_TRUE</code> if the data was handled, |
| 218 * <code>PP_FALSE</code> otherwise. | 221 * <code>PP_FALSE</code> otherwise. |
| 219 */ | 222 */ |
| 220 PP_Bool (*HandleDocumentLoad)(PP_Instance instance, PP_Resource url_loader); | 223 PP_Bool (*HandleDocumentLoad)(PP_Instance instance, PP_Resource url_loader); |
| 221 }; | 224 }; |
| 222 | |
| 223 /** | 225 /** |
| 224 * @} | 226 * @} |
| 225 */ | 227 */ |
| 226 | 228 |
| 229 |
| 227 typedef struct PPP_Instance PPP_Instance_0_5; | 230 typedef struct PPP_Instance PPP_Instance_0_5; |
| 228 | 231 |
| 229 #endif /* PPAPI_C_PPP_INSTANCE_H_ */ | 232 #endif /* PPAPI_C_PPP_INSTANCE_H_ */ |
| 230 | 233 |
| OLD | NEW |