OLD | NEW |
1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 /* Copyright (c) 2012 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 [generate_thunk] | 12 [generate_thunk] |
13 | 13 |
14 label Chrome { | 14 label Chrome { |
15 M14 = 1.0 | 15 M14 = 1.0, |
| 16 [channel=dev] M37 = 1.1 |
16 }; | 17 }; |
17 | 18 |
18 /** | 19 /** |
19 * The <code>PPB_Messaging</code> interface is implemented by the browser | 20 * The <code>PPB_Messaging</code> interface is implemented by the browser |
20 * and is related to sending messages to JavaScript message event listeners on | 21 * and is related to sending messages to JavaScript message event listeners on |
21 * the DOM element associated with specific module instance. | 22 * the DOM element associated with specific module instance. |
22 */ | 23 */ |
23 interface PPB_Messaging { | 24 interface PPB_Messaging { |
24 /** | 25 /** |
25 * PostMessage() asynchronously invokes any listeners for message events on | 26 * PostMessage() asynchronously invokes any listeners for message events on |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 * PP_Var hello_var = ppb_var_interface->VarFromUtf8(instance, | 75 * PP_Var hello_var = ppb_var_interface->VarFromUtf8(instance, |
75 * hello_world, | 76 * hello_world, |
76 * sizeof(hello_world)); | 77 * sizeof(hello_world)); |
77 * ppb_messaging_interface->PostMessage(instance, hello_var); // Copies var. | 78 * ppb_messaging_interface->PostMessage(instance, hello_var); // Copies var. |
78 * ppb_var_interface->Release(hello_var); | 79 * ppb_var_interface->Release(hello_var); |
79 * | 80 * |
80 * @endcode | 81 * @endcode |
81 * | 82 * |
82 * The browser will pop-up an alert saying "Hello world!" | 83 * The browser will pop-up an alert saying "Hello world!" |
83 */ | 84 */ |
| 85 [version=1.0] |
84 void PostMessage([in] PP_Instance instance, [in] PP_Var message); | 86 void PostMessage([in] PP_Instance instance, [in] PP_Var message); |
| 87 |
| 88 /** |
| 89 * <strong>Note:</strong> This function is not yet implemented. Please use |
| 90 * PPB_Messaging_1_0. |
| 91 * |
| 92 * Registers a handler for receiving messages from JavaScript. If a handler |
| 93 * is registered this way, it will replace PPP_Messaging, and all messages |
| 94 * sent from JavaScript via postMessage and postMessageAndAwaitResponse will |
| 95 * be dispatched to <code>handler</code>. |
| 96 * |
| 97 * The function calls will be dispatched via <code>message_loop</code>. This |
| 98 * means that the functions will be invoked on the thread to which |
| 99 * <code>message_loop</code> is attached, when <code>message_loop</code> is |
| 100 * run. It is illegal to pass the main thread message loop; |
| 101 * RegisterMessageHandler will return PP_ERROR_WRONG_THREAD in that case. |
| 102 * |
| 103 * Attempting to register a message handler when one is already registered |
| 104 * will cause the current MessageHandler to be unregistered and replaced. In |
| 105 * that case, no messages will be sent to the "default" message handler |
| 106 * (PPP_Messaging). Messages will stop arriving at the prior message handler |
| 107 * and will begin to be dispatched at the new message handler. |
| 108 * |
| 109 * @param[in] instance A <code>PP_Instance</code> identifying one instance |
| 110 * of a module. |
| 111 * @param[in] user_data A pointer the plugin may choose to use when handling |
| 112 * calls to functions within PPP_MessageHandler. The browser will pass this |
| 113 * same pointer when invoking functions within PPP_MessageHandler. |
| 114 * @param[in] handler The plugin-provided set of functions for handling |
| 115 * messages. |
| 116 * @param[in] message_loop Represents the message loop on which |
| 117 * PPP_MessageHandler functions should be invoked. |
| 118 * @return PP_OK on success, or an error from pp_errors.h. |
| 119 */ |
| 120 [version=1.1] |
| 121 int32_t RegisterMessageHandler([in] PP_Instance instance, |
| 122 [inout] mem_t user_data, |
| 123 [in] PPP_MessageHandler handler, |
| 124 [in] PP_Resource message_loop); |
| 125 /** |
| 126 * <strong>Note:</strong> This function is not yet implemented. Please use |
| 127 * PPB_Messaging_1_0. |
| 128 * |
| 129 * Unregisters the current message handler for <code>instance</code> if one |
| 130 * is registered. After this call, the message handler (if one was |
| 131 * registered) will have "Destroy" called on it and will receive no further |
| 132 * messages after that point. After that point, all messages sent from |
| 133 * JavaScript using postMessage() will be dispatched to PPP_Messaging (if |
| 134 * the plugin supports PPP_MESSAGING_INTERFACE). Attempts to call |
| 135 * postMessageAndAwaitResponse() from JavaScript will fail. |
| 136 * |
| 137 * Attempting to unregister a message handler when none is registered has no |
| 138 * effect. |
| 139 * |
| 140 * @param[in] instance A <code>PP_Instance</code> identifying one instance |
| 141 * of a module. |
| 142 */ |
| 143 [version=1.1] |
| 144 void UnregisterMessageHandler([in] PP_Instance instance); |
85 }; | 145 }; |
86 | 146 |
OLD | NEW |