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 | 5 |
6 /** | 6 /** |
7 * This file defines the <code>PPB_Messaging</code> interface implemented | 7 * This file defines the <code>PPB_Messaging</code> interface implemented |
8 * by the browser for sending messages to DOM elements associated with a | 8 * by the browser for sending messages to DOM elements associated with a |
9 * specific module instance. | 9 * specific module instance. |
10 */ | 10 */ |
11 | 11 |
12 label Chrome { | 12 label Chrome { |
13 M14 = 1.0 | 13 M14 = 1.0 |
14 }; | 14 }; |
15 | 15 |
16 /** | 16 /** |
17 * The <code>PPB_Messaging</code> interface is implemented by the browser | 17 * The <code>PPB_Messaging</code> interface is implemented by the browser |
18 * and is related to sending messages to JavaScript message event listeners on | 18 * and is related to sending messages to JavaScript message event listeners on |
19 * the DOM element associated with specific module instance. | 19 * the DOM element associated with specific module instance. |
20 */ | 20 */ |
21 interface PPB_Messaging { | 21 interface PPB_Messaging { |
22 /** | 22 /** |
23 * PostMessage() asynchronously invokes any listeners for message events on | 23 * PostMessage() asynchronously invokes any listeners for message events on |
24 * the DOM element for the given module instance. A call to PostMessage() | 24 * the DOM element for the given module instance. A call to PostMessage() |
25 * will not block while the message is processed. | 25 * will not block while the message is processed. |
26 * | 26 * |
27 * @param[in] instance A <code>PP_Instance</code> indentifying one instance | 27 * @param[in] instance A <code>PP_Instance</code> identifying one instance |
28 * of a module. | 28 * of a module. |
29 * @param[in] message A <code>PP_Var</code> containing the data to be sent to | 29 * @param[in] message A <code>PP_Var</code> containing the data to be sent to |
30 * JavaScript. | 30 * JavaScript. |
31 * Message can have a numeric, boolean, or string value; arrays and | 31 * Message can have a numeric, boolean, or string value; arrays and |
32 * dictionaries are not yet supported. Ref-counted var types are copied, and | 32 * dictionaries are not yet supported. Ref-counted var types are copied, and |
33 * are therefore not shared between the module instance and the browser. | 33 * are therefore not shared between the module instance and the browser. |
34 * | 34 * |
35 * Listeners for message events in JavaScript code will receive an object | 35 * Listeners for message events in JavaScript code will receive an object |
36 * conforming to the HTML 5 <code>MessageEvent</code> interface. | 36 * conforming to the HTML 5 <code>MessageEvent</code> interface. |
37 * Specifically, the value of message will be contained as a property called | 37 * Specifically, the value of message will be contained as a property called |
38 * data in the received <code>MessageEvent</code>. | 38 * data in the received <code>MessageEvent</code>. |
39 * | 39 * |
40 * This messaging system is similar to the system used for listening for | 40 * This messaging system is similar to the system used for listening for |
41 * messages from Web Workers. Refer to | 41 * messages from Web Workers. Refer to |
42 * <code>http://www.whatwg.org/specs/web-workers/current-work/</code> for | 42 * <code>http://www.whatwg.org/specs/web-workers/current-work/</code> for |
43 * further information. | 43 * further information. |
44 * | 44 * |
45 * <strong>Example:</strong> | 45 * <strong>Example:</strong> |
46 * | 46 * |
47 * @code | 47 * <code> |
48 * | 48 * |
49 * <body> | 49 * <body> |
50 * <object id="plugin" | 50 * <object id="plugin" |
51 * type="application/x-ppapi-postMessage-example"/> | 51 * type="application/x-ppapi-postMessage-example"/> |
52 * <script type="text/javascript"> | 52 * <script type="text/javascript"> |
53 * var plugin = document.getElementById('plugin'); | 53 * var plugin = document.getElementById('plugin'); |
54 * plugin.AddEventListener("message", | 54 * plugin.AddEventListener("message", |
55 * function(message) { alert(message.data); }, | 55 * function(message) { alert(message.data); }, |
56 * false); | 56 * false); |
57 * </script> | 57 * </script> |
58 * </body> | 58 * </body> |
59 * | 59 * |
60 * @endcode | 60 * </code> |
61 * | 61 * |
62 * The module instance then invokes PostMessage() as follows: | 62 * The module instance then invokes PostMessage() as follows: |
63 * | 63 * |
64 * @code | 64 * <code> |
65 * | 65 * |
66 * | 66 * |
67 * char hello_world[] = "Hello world!"; | 67 * char hello_world[] = "Hello world!"; |
68 * PP_Var hello_var = ppb_var_interface->VarFromUtf8(instance, | 68 * PP_Var hello_var = ppb_var_interface->VarFromUtf8(instance, |
69 * hello_world, | 69 * hello_world, |
70 * sizeof(hello_world)); | 70 * sizeof(hello_world)); |
71 * ppb_messaging_interface->PostMessage(instance, hello_var); // Copies var. | 71 * ppb_messaging_interface->PostMessage(instance, hello_var); // Copies var. |
72 * ppb_var_interface->Release(hello_var); | 72 * ppb_var_interface->Release(hello_var); |
73 * | 73 * |
74 * @endcode | 74 * </code> |
75 * | 75 * |
76 * The browser will pop-up an alert saying "Hello world!" | 76 * The browser will pop-up an alert saying "Hello world!" |
77 */ | 77 */ |
78 void PostMessage([in] PP_Instance instance, [in] PP_Var message); | 78 void PostMessage([in] PP_Instance instance, [in] PP_Var message); |
79 }; | 79 }; |
80 | 80 |
OLD | NEW |