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 struct contains pointers to a series of methods that you | |
31 * must implement in your module. These methods do not have to have bodies | |
32 * unless you want your model to handel events such as a change of focus or | |
dmichael(do not use this one)
2011/02/08 21:51:17
s/model/module
s/handel/handle
I also don't think
jond
2011/02/09 16:42:04
Done.
| |
33 * input events (keyboard/mouse events). | |
34 */ | |
35 | |
28 struct PPP_Instance { | 36 struct PPP_Instance { |
29 /** | 37 /** |
30 * Called when a new plugin is instantiated on the web page. The identifier | 38 * 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 | 39 * module is instantiated on the web page. The identifier of the new |
32 * generated by the browser and is an opaque handle). | 40 * instance will be passed in as the first argument (this value is |
41 * generated by the browser and is an opaque handle). This is called for each | |
42 * instantiation of the NaCl module, which is each time the <embed> tag for | |
43 * this module is encountered. | |
33 * | 44 * |
34 * It's possible for more than one plugin instance to be created within the | 45 * 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 | 46 * (i.e. you may get more than one OnCreate without an OnDestroy |
36 * in between). | 47 * in between). |
37 * | 48 * |
38 * If the plugin reports failure from this function, the plugin will be | 49 * If this function reports a failure (by returning @a PP_FALSE), the NaCl |
39 * deleted and OnDestroy will be called. | 50 * module will be deleted and DidDestroy will be called. |
51 * | |
52 * @param[in] instance A PP_Instance indentifying one instance of a module. | |
53 * @param[in] argc The number of arguments contained in @a argn and @a argv. | |
54 * @param[in] argn An array of argument names. These argument names are | |
55 * supplied in the <embed> tag, for example: | |
56 * embed id="nacl_module" dimensions="2"> | |
dmichael(do not use this one)
2011/02/08 21:51:17
s/embed/<embed
jond
2011/02/09 16:42:04
Done.
jond
2011/02/09 16:42:04
Done.
| |
57 * will produce two arguments, one named "id" and one named "dimensions". | |
58 * @param[in] argv An array of argument values. These are the values of the | |
dmichael(do not use this one)
2011/02/08 21:51:17
"These are the values of the arguments listed in t
jond
2011/02/09 16:42:04
Done.
| |
59 * arguments listed in the <embed> tag. In the previous example, there will | |
dmichael(do not use this one)
2011/02/08 21:51:17
'the previous'->'this'
jond
2011/02/09 16:42:04
Done.
| |
60 * be two elements in this array, "nacl_module" and "2". The indices of | |
61 * these values match the indices of the corresponding names in @a argn. | |
62 * @return @a PP_TRUE on success. | |
40 */ | 63 */ |
41 PP_Bool (*DidCreate)(PP_Instance instance, | 64 PP_Bool (*DidCreate)(PP_Instance instance, |
42 uint32_t argc, | 65 uint32_t argc, |
43 const char* argn[], | 66 const char* argn[], |
44 const char* argv[]); | 67 const char* argv[]); |
45 | 68 |
46 /** | 69 /** |
47 * Called when the plugin instance is destroyed. This will always be called, | 70 * 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 | 71 * module instance is destroyed. This function will always be called, |
72 * even if DidCreate returned failure. The function should deallocate any data | |
49 * associated with the instance. | 73 * associated with the instance. |
74 * | |
75 * @param[in] instance A PP_Instance indentifying one instance of a module. | |
50 */ | 76 */ |
51 void (*DidDestroy)(PP_Instance instance); | 77 void (*DidDestroy)(PP_Instance instance); |
52 | 78 |
53 /** | 79 /** |
54 * Called when the position, the size, or the clip rect has changed. | 80 * This value represents a pointer to a function that is called when the |
81 * position, the size, or the clip rectangle of the element in the | |
82 * browser that corresponds to this NaCl module has changed. | |
55 * | 83 * |
56 * The |position| is the location on the page of this plugin instance. This is | 84 * @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 | 85 * @param[in] position The location on the page of this NaCl module. This is |
58 * is scrolled. | 86 * relative to the top left corner of the viewport, which changes as the |
59 * | 87 * page is scrolled. |
60 * The |clip| indicates the visible region of the plugin instance. This is | 88 * @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). | 89 * 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). | 90 * plugin is invisible, @a clip will be (0, 0, 0, 0). |
63 */ | 91 */ |
64 void (*DidChangeView)(PP_Instance instance, | 92 void (*DidChangeView)(PP_Instance instance, |
65 const struct PP_Rect* position, | 93 const struct PP_Rect* position, |
66 const struct PP_Rect* clip); | 94 const struct PP_Rect* clip); |
67 | 95 |
68 /** | 96 /** |
69 * Notification that the given plugin instance has gained or lost focus. | 97 * 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 | 98 * 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. | 99 * sent to the module. A module's default condition is that it will |
100 * not have focus. | |
72 * | 101 * |
73 * Note: clicks on your plugins will give focus only if you handle the | 102 * 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 | 103 * click event. Return @a true from HandleInputEvent to signal that the click |
75 * HandleInputEvent. Otherwise the browser will bubble the event and give | 104 * 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. | 105 * 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 | 106 * If you're not getting focus, check to make sure you're returning true from |
78 * the mouse click in HandleInputEvent. | 107 * the mouse click in HandleInputEvent. |
108 * @param[in] instance A PP_Instance indentifying one instance of a module. | |
109 * @param[in] has_focus Indicates whether this NaCl module gained or lost | |
110 * event focus. | |
79 */ | 111 */ |
80 void (*DidChangeFocus)(PP_Instance instance, PP_Bool has_focus); | 112 void (*DidChangeFocus)(PP_Instance instance, PP_Bool has_focus); |
81 | 113 |
82 /** | 114 /** |
83 * General handler for input events. Returns true if the event was handled or | 115 * This value represents a pointer to a function to handle input events. |
84 * false if it was not. | 116 * Returns true if the event was handled or false if it was not. |
85 * | 117 * |
86 * If the event was handled, it will not be forwarded to the web page or | 118 * 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 | 119 * 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 | 120 * rules. So it is important that a module respond accurately with whether |
89 * event propogation should continue. | 121 * event propogation should continue. |
90 * | 122 * |
91 * Event propogation also controls focus. If you handle an event like a mouse | 123 * 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 | 124 * 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 | 125 * 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, | 126 * 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 | 127 * where clicks on the transparent areas will behave like clicks to the |
96 * underlying page. | 128 * underlying page. |
129 * @param[in] instance A PP_Instance indentifying one instance of a module. | |
130 * @param[in] event The event. | |
131 * @return PP_TRUE if @a event was handled, PP_FALSE otherwise. | |
97 */ | 132 */ |
98 PP_Bool (*HandleInputEvent)(PP_Instance instance, | 133 PP_Bool (*HandleInputEvent)(PP_Instance instance, |
99 const struct PP_InputEvent* event); | 134 const struct PP_InputEvent* event); |
100 | 135 |
101 /** | 136 /** |
102 * Called after Initialize for a full-frame plugin that was instantiated | 137 * 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 | 138 * 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 | 139 * type of a DOMWindow navigation. This only applies to modules that are |
105 * Native Client plugins). | 140 * registered to handle certain MIME types (not current Native Client |
141 * modules). | |
106 * | 142 * |
107 * The given url_loader corresponds to a PPB_URLLoader instance that is | 143 * The given url_loader corresponds to a PPB_URLLoader instance that is |
108 * already opened. Its response headers may be queried using | 144 * already opened. Its response headers may be queried using |
109 * PPB_URLLoader::GetResponseInfo. The url loader is not addrefed on behalf | 145 * 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 | 146 * of the module, if you're going to keep a reference to it, you need to |
111 * addref it yourself. | 147 * addref it yourself. |
112 * | 148 * |
113 * This method returns PP_FALSE if the plugin cannot handle the data. In | 149 * 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 | 150 * response to this method, the module should call ReadResponseBody to read |
115 * the incoming data. | 151 * the incoming data. |
152 * @param[in] instance A PP_Instance indentifying one instance of a module. | |
153 * @param[in] url_loader A PP_Resource an open PPB_URLLoader instance. | |
154 * @return PP_TRUE if the data was handled, PP_FALSE otherwise. | |
116 */ | 155 */ |
117 PP_Bool (*HandleDocumentLoad)(PP_Instance instance, PP_Resource url_loader); | 156 PP_Bool (*HandleDocumentLoad)(PP_Instance instance, PP_Resource url_loader); |
118 | 157 |
119 /** | 158 /** |
120 * Returns a Var representing the instance object to the web page. Normally | 159 * This value represents a pointer to a function that returns a Var |
160 * representing the scriptable object for the given instance. Normally | |
121 * this will be a PPP_Class object that exposes certain methods the page | 161 * this will be a PPP_Class object that exposes certain methods the page |
122 * may want to call. | 162 * may want to call. |
123 * | 163 * |
124 * On Failure, the returned var should be a "void" var. | 164 * On Failure, the returned var should be a "void" var. |
125 * | 165 * |
126 * The returned PP_Var should have a reference added for the caller, which | 166 * The returned PP_Var should have a reference added for the caller, which |
127 * will be responsible for Release()ing that reference. | 167 * will be responsible for Release()ing that reference. |
168 * | |
169 * @param[in] instance A PP_Instance indentifying one instance of a module. | |
170 * @return A PP_Var containing scriptable object. | |
128 */ | 171 */ |
129 struct PP_Var (*GetInstanceObject)(PP_Instance instance); | 172 struct PP_Var (*GetInstanceObject)(PP_Instance instance); |
130 }; | 173 }; |
131 /** | 174 /** |
132 * @} | 175 * @} |
133 */ | 176 */ |
134 | 177 |
135 #endif /* PPAPI_C_PPP_INSTANCE_H_ */ | 178 #endif /* PPAPI_C_PPP_INSTANCE_H_ */ |
136 | 179 |
OLD | NEW |