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_instance.h" | 9 #include "ppapi/c/pp_instance.h" |
9 #include "ppapi/c/pp_rect.h" | 10 #include "ppapi/c/pp_rect.h" |
10 #include "ppapi/c/pp_resource.h" | 11 #include "ppapi/c/pp_resource.h" |
11 | 12 |
12 struct PP_InputEvent; | 13 struct PP_InputEvent; |
13 struct PP_Var; | 14 struct PP_Var; |
14 | 15 |
15 #define PPP_INSTANCE_INTERFACE "PPP_Instance;0.1" | 16 #define PPP_INSTANCE_INTERFACE "PPP_Instance;0.2" |
16 | 17 |
17 /** | 18 /** |
18 * @file | 19 * @file |
19 * Defines the API ... | 20 * Defines the API ... |
20 * | 21 * |
21 * @addtogroup PPP | 22 * @addtogroup PPP |
22 * @{ | 23 * @{ |
23 */ | 24 */ |
24 | 25 |
25 struct PPP_Instance { | 26 struct PPP_Instance { |
26 /** | 27 /** |
27 * Called when a new plugin is instantiated on the web page. The identifier | 28 * Called when a new plugin is instantiated on the web page. The identifier |
28 * of the new instance will be passed in as the first argument (this value is | 29 * of the new instance will be passed in as the first argument (this value is |
29 * generated by the browser and is an opaque handle). | 30 * generated by the browser and is an opaque handle). |
30 * | 31 * |
31 * It's possible for more than one plugin instance to be created within the | 32 * It's possible for more than one plugin instance to be created within the |
32 * same module (i.e. you may get more than one OnCreate without an OnDestroy | 33 * same module (i.e. you may get more than one OnCreate without an OnDestroy |
33 * in between). | 34 * in between). |
34 * | 35 * |
35 * If the plugin reports failure from this function, the plugin will be | 36 * If the plugin reports failure from this function, the plugin will be |
36 * deleted and OnDestroy will be called. | 37 * deleted and OnDestroy will be called. |
37 */ | 38 */ |
38 bool (*DidCreate)(PP_Instance instance, | 39 PP_Bool (*DidCreate)(PP_Instance instance, |
39 uint32_t argc, | 40 uint32_t argc, |
40 const char* argn[], | 41 const char* argn[], |
41 const char* argv[]); | 42 const char* argv[]); |
42 | 43 |
43 /** | 44 /** |
44 * Called when the plugin instance is destroyed. This will always be called, | 45 * Called when the plugin instance is destroyed. This will always be called, |
45 * even if Create returned failure. The plugin should deallocate any data | 46 * even if Create returned failure. The plugin should deallocate any data |
46 * associated with the instance. | 47 * associated with the instance. |
47 */ | 48 */ |
48 void (*DidDestroy)(PP_Instance instance); | 49 void (*DidDestroy)(PP_Instance instance); |
49 | 50 |
50 /** | 51 /** |
51 * Called when the position, the size, or the clip rect has changed. | 52 * Called when the position, the size, or the clip rect has changed. |
(...skipping 15 matching lines...) Expand all Loading... |
67 * Having focus means that keyboard events will be sent to your plugin | 68 * Having focus means that keyboard events will be sent to your plugin |
68 * instance. A plugin's default condition is that it will not have focus. | 69 * instance. A plugin's default condition is that it will not have focus. |
69 * | 70 * |
70 * Note: clicks on your plugins will give focus only if you handle the | 71 * Note: clicks on your plugins will give focus only if you handle the |
71 * click event. You signal if you handled it by returning true from | 72 * click event. You signal if you handled it by returning true from |
72 * HandleInputEvent. Otherwise the browser will bubble the event and give | 73 * HandleInputEvent. Otherwise the browser will bubble the event and give |
73 * focus to the element on the page that actually did end up consuming it. | 74 * focus to the element on the page that actually did end up consuming it. |
74 * If you're not getting focus, check to make sure you're returning true from | 75 * If you're not getting focus, check to make sure you're returning true from |
75 * the mouse click in HandleInputEvent. | 76 * the mouse click in HandleInputEvent. |
76 */ | 77 */ |
77 void (*DidChangeFocus)(PP_Instance instance, bool has_focus); | 78 void (*DidChangeFocus)(PP_Instance instance, PP_Bool has_focus); |
78 | 79 |
79 /** | 80 /** |
80 * General handler for input events. Returns true if the event was handled or | 81 * General handler for input events. Returns true if the event was handled or |
81 * false if it was not. | 82 * false if it was not. |
82 * | 83 * |
83 * If the event was handled, it will not be forwarded to the web page or | 84 * If the event was handled, it will not be forwarded to the web page or |
84 * browser. If it was not handled, it will bubble according to the normal | 85 * browser. If it was not handled, it will bubble according to the normal |
85 * rules. So it is important that a plugin respond accurately with whether | 86 * rules. So it is important that a plugin respond accurately with whether |
86 * event propogation should continue. | 87 * event propogation should continue. |
87 * | 88 * |
88 * Event propogation also controls focus. If you handle an event like a mouse | 89 * Event propogation also controls focus. If you handle an event like a mouse |
89 * event, typically your plugin will be given focus. Returning false means | 90 * event, typically your plugin will be given focus. Returning false means |
90 * that the click will be given to a lower part of the page and the plugin | 91 * that the click will be given to a lower part of the page and the plugin |
91 * will not receive focus. This allows a plugin to be partially transparent, | 92 * will not receive focus. This allows a plugin to be partially transparent, |
92 * where clicks on the transparent areas will behave like clicks to the | 93 * where clicks on the transparent areas will behave like clicks to the |
93 * underlying page. | 94 * underlying page. |
94 */ | 95 */ |
95 bool (*HandleInputEvent)(PP_Instance instance, | 96 PP_Bool (*HandleInputEvent)(PP_Instance instance, |
96 const struct PP_InputEvent* event); | 97 const struct PP_InputEvent* event); |
97 | 98 |
98 /** | 99 /** |
99 * Called after Initialize for a full-frame plugin that was instantiated | 100 * Called after Initialize for a full-frame plugin that was instantiated |
100 * based on the MIME type of a DOMWindow navigation. This only applies to | 101 * based on the MIME type of a DOMWindow navigation. This only applies to |
101 * plugins that are registered to handle certain MIME types (not current | 102 * plugins that are registered to handle certain MIME types (not current |
102 * Native Client plugins). | 103 * Native Client plugins). |
103 * | 104 * |
104 * The given url_loader corresponds to a PPB_URLLoader instance that is | 105 * The given url_loader corresponds to a PPB_URLLoader instance that is |
105 * already opened. Its response headers may be queried using | 106 * already opened. Its response headers may be queried using |
106 * PPB_URLLoader::GetResponseInfo. The url loader is not addrefed on behalf | 107 * PPB_URLLoader::GetResponseInfo. The url loader is not addrefed on behalf |
107 * of the plugin, if you're going to keep a reference to it, you need to | 108 * of the plugin, if you're going to keep a reference to it, you need to |
108 * addref it yourself. | 109 * addref it yourself. |
109 * | 110 * |
110 * This method returns false if the plugin cannot handle the data. In | 111 * This method returns PP_FALSE if the plugin cannot handle the data. In |
111 * response to this method, the plugin should call ReadResponseBody to read | 112 * response to this method, the plugin should call ReadResponseBody to read |
112 * the incoming data. | 113 * the incoming data. |
113 */ | 114 */ |
114 bool (*HandleDocumentLoad)(PP_Instance instance, PP_Resource url_loader); | 115 PP_Bool (*HandleDocumentLoad)(PP_Instance instance, PP_Resource url_loader); |
115 | 116 |
116 /** | 117 /** |
117 * Returns a Var representing the instance object to the web page. Normally | 118 * Returns a Var representing the instance object to the web page. Normally |
118 * this will be a PPP_Class object that exposes certain methods the page | 119 * this will be a PPP_Class object that exposes certain methods the page |
119 * may want to call. | 120 * may want to call. |
120 * | 121 * |
121 * On Failure, the returned var should be a "void" var. | 122 * On Failure, the returned var should be a "void" var. |
122 * | 123 * |
123 * The returned PP_Var should have a reference added for the caller, which | 124 * The returned PP_Var should have a reference added for the caller, which |
124 * will be responsible for Release()ing that reference. | 125 * will be responsible for Release()ing that reference. |
125 */ | 126 */ |
126 struct PP_Var (*GetInstanceObject)(PP_Instance instance); | 127 struct PP_Var (*GetInstanceObject)(PP_Instance instance); |
127 }; | 128 }; |
128 | 129 |
129 /** | 130 /** |
130 * @} | 131 * @} |
131 * End addtogroup PPP | 132 * End addtogroup PPP |
132 */ | 133 */ |
133 #endif // PPAPI_C_PPP_INSTANCE_H_ | 134 #endif // PPAPI_C_PPP_INSTANCE_H_ |
OLD | NEW |