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 #ifndef WEBKIT_PLUGINS_PPAPI_MESSAGE_CHANNEL_H_ | 5 #ifndef WEBKIT_PLUGINS_PPAPI_MESSAGE_CHANNEL_H_ |
6 #define WEBKIT_PLUGINS_PPAPI_MESSAGE_CHANNEL_H_ | 6 #define WEBKIT_PLUGINS_PPAPI_MESSAGE_CHANNEL_H_ |
7 | 7 |
8 #include "base/task.h" | 8 #include "base/task.h" |
9 #include "ppapi/shared_impl/resource.h" | 9 #include "ppapi/shared_impl/resource.h" |
10 #include "third_party/npapi/bindings/npruntime.h" | 10 #include "third_party/npapi/bindings/npruntime.h" |
11 | 11 |
12 struct PP_Var; | 12 struct PP_Var; |
| 13 namespace WebKit { |
| 14 class WebSerializedScriptValue; |
| 15 } |
13 | 16 |
14 namespace webkit { | 17 namespace webkit { |
15 namespace ppapi { | 18 namespace ppapi { |
16 | 19 |
17 class PluginInstance; | 20 class PluginInstance; |
18 | 21 |
19 // MessageChannel implements bidirectional postMessage functionality, allowing | 22 // MessageChannel implements bidirectional postMessage functionality, allowing |
20 // calls from JavaScript to plugins and vice-versa. See | 23 // calls from JavaScript to plugins and vice-versa. See |
21 // PPB_Messaging::PostMessage and PPP_Messaging::HandleMessage for more | 24 // PPB_Messaging::PostMessage and PPP_Messaging::HandleMessage for more |
22 // information. | 25 // information. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 // We pass all non-postMessage calls through to the passthrough_object_. | 76 // We pass all non-postMessage calls through to the passthrough_object_. |
74 // This way, a plugin can use PPB_Class or PPP_Class_Deprecated and also | 77 // This way, a plugin can use PPB_Class or PPP_Class_Deprecated and also |
75 // postMessage. This is necessary to support backwards-compatibility, and | 78 // postMessage. This is necessary to support backwards-compatibility, and |
76 // also trusted plugins for which we will continue to support synchronous | 79 // also trusted plugins for which we will continue to support synchronous |
77 // scripting. | 80 // scripting. |
78 NPObject* passthrough_object_; | 81 NPObject* passthrough_object_; |
79 | 82 |
80 // The NPObject we use to expose postMessage to JavaScript. | 83 // The NPObject we use to expose postMessage to JavaScript. |
81 MessageChannelNPObject* np_object_; | 84 MessageChannelNPObject* np_object_; |
82 | 85 |
83 // An NPVariant referring to the JavaScript function we use to send a message | |
84 // to a JavaScript target. | |
85 NPVariant onmessage_invoker_; | |
86 | |
87 // Evaluates the JavaScript code for onmessage_invoker_ and makes | |
88 // it a callable NPVariant for that function. Returns true on success, false | |
89 // otherwise. | |
90 bool EvaluateOnMessageInvoker(); | |
91 | |
92 // Post a message to the onmessage handler for this channel's instance | 86 // Post a message to the onmessage handler for this channel's instance |
93 // synchronously. This is used by PostMessageToJavaScript. | 87 // synchronously. This is used by PostMessageToJavaScript. |
94 void PostMessageToJavaScriptImpl(PP_Var message_data); | 88 void PostMessageToJavaScriptImpl( |
| 89 const WebKit::WebSerializedScriptValue& message_data); |
95 // Post a message to the PPP_Instance HandleMessage function for this | 90 // Post a message to the PPP_Instance HandleMessage function for this |
96 // channel's instance. This is used by PostMessageToNative. | 91 // channel's instance. This is used by PostMessageToNative. |
97 void PostMessageToNativeImpl(PP_Var message_data); | 92 void PostMessageToNativeImpl(PP_Var message_data); |
98 | 93 |
99 // This is used to ensure pending tasks will not fire after this object is | 94 // This is used to ensure pending tasks will not fire after this object is |
100 // destroyed. | 95 // destroyed. |
101 base::WeakPtrFactory<MessageChannel> weak_ptr_factory_; | 96 base::WeakPtrFactory<MessageChannel> weak_ptr_factory_; |
102 | 97 |
103 DISALLOW_COPY_AND_ASSIGN(MessageChannel); | 98 DISALLOW_COPY_AND_ASSIGN(MessageChannel); |
104 }; | 99 }; |
105 | 100 |
106 } // namespace ppapi | 101 } // namespace ppapi |
107 } // namespace webkit | 102 } // namespace webkit |
108 | 103 |
109 #endif // WEBKIT_PLUGINS_PPAPI_MESSAGE_CHANNEL_H_ | 104 #endif // WEBKIT_PLUGINS_PPAPI_MESSAGE_CHANNEL_H_ |
110 | 105 |
OLD | NEW |