Chromium Code Reviews| 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=none] 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 * | |
|
teravest
2014/05/30 20:36:15
nit: you shouldn't need the extra newline here.
| |
| 90 * <strong>Note:</strong> This function is not yet implemented. Please use | |
| 91 * PPB_Messaging_1_0. | |
| 92 * | |
| 93 * Registers a handler for receiving messages from JavaScript. If a handler | |
| 94 * is registered this way, it will replace PPP_Messaging, and all messages | |
| 95 * sent from JavaScript via postMessage and postMessageAndAwaitResponse will | |
| 96 * be dispatched to <code>handler</code>. | |
| 97 * | |
| 98 * The function calls will be dispatched via <code>message_loop</code>. This | |
| 99 * means that the functions will be invoked on the thread to which | |
| 100 * <code>message_loop</code> is attached, when <code>message_loop</code> is | |
| 101 * run. It is illegal to pass the main thread message loop; | |
| 102 * RegisterMessageHandler will return PP_ERROR_WRONG_THREAD in that case. | |
| 103 * | |
| 104 * Attempting to register a message handler when one is already registered | |
| 105 * will cause the current MessageHandler to be unregistered and replaced. In | |
| 106 * that case, no messages will be sent to the "default" message handler | |
| 107 * (PPP_Messaging). Messages will stop arriving at the prior message handler | |
| 108 * and will begin to be dispatched at the new message handler. | |
| 109 * | |
| 110 * @param[in] instance A <code>PP_Instance</code> identifying one instance | |
| 111 * of a module. | |
| 112 * @param[in] user_data A pointer the plugin may choose to use when handling | |
|
jvoung (off chromium)
2014/05/30 21:23:57
comment says @param[in] for user_data, but idl say
| |
| 113 * calls to functions within PPP_MessageHandler. The browser will pass this | |
| 114 * same pointer when invoking functions within PPP_MessageHandler. | |
| 115 * @param[in] handler The plugin-provided set of functions for handling | |
| 116 * messages. | |
| 117 * @param[in] message_loop represents the message loop on which | |
|
teravest
2014/05/30 20:36:15
nit: s/represents/Represents/ for consistent style
| |
| 118 * PPP_MessageHandler functions should be invoked. | |
| 119 * @return PP_OK on success, or an error from pp_errors.h. | |
| 120 */ | |
| 121 [version=1.1] | |
| 122 int32_t RegisterMessageHandler([in] PP_Instance instance, | |
| 123 [inout] mem_t user_data, | |
| 124 [in] PPP_MessageHandler handler, | |
| 125 [in] PP_Resource message_loop); | |
| 126 /** | |
| 127 * | |
|
teravest
2014/05/30 20:36:15
nit: same as above for newline. Unless this is req
| |
| 128 * <strong>Note:</strong> This function is not yet implemented. Please use | |
| 129 * PPB_Messaging_1_0. | |
| 130 * | |
| 131 * Unregisters the current message handler for <code>instance</code> if one | |
| 132 * is registered. After this call, the message handler (if one was | |
| 133 * registered) will have "Destroy" called on it and will receive no further | |
| 134 * messages after that point. After that point, all messages sent from | |
| 135 * JavaScript using postMessage() will be dispatched to PPP_Messaging (if | |
| 136 * the plugin supports PPP_MESSAGING_INTERFACE). Attempts to call | |
| 137 * postMessageAndAwaitResponse() from JavaScript will fail. | |
| 138 * | |
| 139 * Attempting to unregister a message handler when none is registered has no | |
| 140 * effect. | |
| 141 * | |
| 142 * @param[in] instance A <code>PP_Instance</code> identifying one instance | |
| 143 * of a module. | |
| 144 */ | |
| 145 [version=1.1] | |
| 146 void UnregisterMessageHandler([in] PP_Instance instance); | |
| 85 }; | 147 }; |
| 86 | 148 |
| OLD | NEW |