• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3  * found in the LICENSE file.
4  */
5 
6 /* From ppp_messaging.idl modified Wed Jun  5 10:32:43 2013. */
7 
8 #ifndef PPAPI_C_PPP_MESSAGING_H_
9 #define PPAPI_C_PPP_MESSAGING_H_
10 
11 #include "ppapi/c/pp_bool.h"
12 #include "ppapi/c/pp_instance.h"
13 #include "ppapi/c/pp_macros.h"
14 #include "ppapi/c/pp_stdint.h"
15 #include "ppapi/c/pp_var.h"
16 
17 #define PPP_MESSAGING_INTERFACE_1_0 "PPP_Messaging;1.0"
18 #define PPP_MESSAGING_INTERFACE PPP_MESSAGING_INTERFACE_1_0
19 
20 /**
21  * @file
22  * This file defines the PPP_Messaging interface containing pointers to
23  * functions that you must implement to handle postMessage messages
24  * on the associated DOM element.
25  *
26  */
27 
28 
29 /**
30  * @addtogroup Interfaces
31  * @{
32  */
33 /**
34  * The <code>PPP_Messaging</code> interface contains pointers to functions
35  * that you must implement to handle postMessage events on the associated
36  * DOM element.
37  */
38 struct PPP_Messaging_1_0 {
39   /**
40    * HandleMessage() is a function that the browser calls when PostMessage()
41    * is invoked on the DOM element for the module instance in JavaScript. Note
42    * that PostMessage() in the JavaScript interface is asynchronous, meaning
43    * JavaScript execution will not be blocked while HandleMessage() is
44    * processing the message.
45    *
46    * @param[in] instance A <code>PP_Instance</code> identifying one instance
47    * of a module.
48    * @param[in] message A <code>PP_Var</code> which has been converted from a
49    * JavaScript value. JavaScript array/object types are supported from Chrome
50    * M29 onward. All JavaScript values are copied when passing them to the
51    * plugin.
52    *
53    * When converting JavaScript arrays, any object properties whose name
54    * is not an array index are ignored. When passing arrays and objects, the
55    * entire reference graph will be converted and transferred. If the reference
56    * graph has cycles, the message will not be sent and an error will be logged
57    * to the console.
58    *
59    * The following JavaScript code invokes <code>HandleMessage</code>, passing
60    * the module instance on which it was invoked, with <code>message</code>
61    * being a string <code>PP_Var</code> containing "Hello world!"
62    *
63    * <strong>Example:</strong>
64    *
65    * @code
66    *
67    * <body>
68    *   <object id="plugin"
69    *           type="application/x-ppapi-postMessage-example"/>
70    *   <script type="text/javascript">
71    *     document.getElementById('plugin').postMessage("Hello world!");
72    *   </script>
73    * </body>
74    *
75    * @endcode
76    *
77    */
78   void (*HandleMessage)(PP_Instance instance, struct PP_Var message);
79 };
80 
81 typedef struct PPP_Messaging_1_0 PPP_Messaging;
82 /**
83  * @}
84  */
85 
86 #endif  /* PPAPI_C_PPP_MESSAGING_H_ */
87 
88