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_PPB_INSTANCE_H_ | 5 #ifndef PPAPI_C_PPB_INSTANCE_H_ |
6 #define PPAPI_C_PPB_INSTANCE_H_ | 6 #define PPAPI_C_PPB_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_resource.h" | 10 #include "ppapi/c/pp_resource.h" |
11 #include "ppapi/c/pp_var.h" | 11 #include "ppapi/c/pp_var.h" |
12 | 12 |
13 #define PPB_INSTANCE_INTERFACE "PPB_Instance;0.4" | 13 #define PPB_INSTANCE_INTERFACE "PPB_Instance;0.5" |
14 | 14 |
15 /** | 15 /** |
16 * @file | 16 * @file |
17 * This file defines the PPB_Instance interface implemented by the | 17 * This file defines the PPB_Instance interface implemented by the |
18 * browser and containing pointers to functions related to | 18 * browser and containing pointers to functions related to |
19 * the module instance on a web page. | 19 * the module instance on a web page. |
20 * | 20 * |
21 * @addtogroup Interfaces | 21 * @addtogroup Interfaces |
22 * @{ | 22 * @{ |
23 */ | 23 */ |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 * @param[in/out] exception PP_Var containing the exception. Initialize | 100 * @param[in/out] exception PP_Var containing the exception. Initialize |
101 * this to NULL if you don't want exception info; initialize this to a void | 101 * this to NULL if you don't want exception info; initialize this to a void |
102 * exception if want exception info. | 102 * exception if want exception info. |
103 * | 103 * |
104 * @return The result of the script execution, or a "void" var | 104 * @return The result of the script execution, or a "void" var |
105 * if execution failed. | 105 * if execution failed. |
106 */ | 106 */ |
107 struct PP_Var (*ExecuteScript)(PP_Instance instance, | 107 struct PP_Var (*ExecuteScript)(PP_Instance instance, |
108 struct PP_Var script, | 108 struct PP_Var script, |
109 struct PP_Var* exception); | 109 struct PP_Var* exception); |
| 110 |
| 111 /** |
| 112 * @a PostMessage is a pointer to a function which asynchronously invokes th |
| 113 * onmessage handler on the DOM element for this module instance, if one |
| 114 * exists. @a message is a PP_Var containing the data to be sent to |
| 115 * JavaScript. Currently, it can have an int32_t, double, bool, or string |
| 116 * value (objects are not currently supported.) |
| 117 * |
| 118 * The onmessage handler in JavaScript code will receive an object conforming |
| 119 * to the MessageEvent interface. In particular, the value of @a message will |
| 120 * be contained as a property called @a data in the received MessageEvent. |
| 121 * This is analogous to listening for messages from Web Workers. |
| 122 * |
| 123 * See: |
| 124 * http://www.whatwg.org/specs/web-workers/current-work/ |
| 125 * |
| 126 * For example: |
| 127 * |
| 128 * \verbatim |
| 129 * |
| 130 * <body> |
| 131 * <object id="plugin" |
| 132 * type="application/x-ppapi-postMessage-example"/> |
| 133 * <script type="text/javascript"> |
| 134 * document.getElementById('plugin').onmessage = function(message) { |
| 135 * alert(message.data); |
| 136 * } |
| 137 * </script> |
| 138 * </body> |
| 139 * |
| 140 * \endverbatim |
| 141 * |
| 142 * If the module instance then invokes @a PostMessage() as follows: |
| 143 * <code> |
| 144 * char hello_world[] = "Hello world!"; |
| 145 * PP_Var hello_var = ppb_var_if->VarFromUtf8(instance, |
| 146 * hello_world, |
| 147 * sizeof(hello_world)); |
| 148 * the_ppb_instance->PostMessage(instance, hello_var); |
| 149 * </code> |
| 150 * |
| 151 * The browser will pop-up an alert saying "Hello world!". |
| 152 */ |
| 153 void (*PostMessage)(PP_Instance instance, struct PP_Var message); |
110 }; | 154 }; |
111 /** | 155 /** |
112 * @} | 156 * @} |
113 */ | 157 */ |
114 | 158 |
115 #endif /* PPAPI_C_PPB_INSTANCE_H_ */ | 159 #endif /* PPAPI_C_PPB_INSTANCE_H_ */ |
116 | 160 |
OLD | NEW |