blob: 274d1e307ff8efbec463e1144acabd41e7199003 [file] [log] [blame]
[email protected]0a424af2012-01-10 19:24:281// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]4c2e9352010-11-05 22:13:022// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef PPAPI_PROXY_PPB_INSTANCE_PROXY_H_
6#define PPAPI_PROXY_PPB_INSTANCE_PROXY_H_
7
[email protected]98ad9782012-08-22 04:06:228#include <string>
9
[email protected]4c2e9352010-11-05 22:13:0210#include "ppapi/c/pp_instance.h"
11#include "ppapi/c/pp_resource.h"
[email protected]3b98ced72012-03-09 02:08:3312#include "ppapi/c/pp_time.h"
[email protected]4c2e9352010-11-05 22:13:0213#include "ppapi/c/pp_var.h"
14#include "ppapi/proxy/interface_proxy.h"
[email protected]47a961c2012-07-13 19:18:5215#include "ppapi/proxy/proxy_completion_callback_factory.h"
[email protected]be0a84b2011-08-13 04:18:4416#include "ppapi/shared_impl/host_resource.h"
[email protected]9a578392011-12-07 18:59:2717#include "ppapi/shared_impl/ppb_instance_shared.h"
[email protected]ceadc392011-06-15 23:04:2418#include "ppapi/thunk/ppb_instance_api.h"
[email protected]ae5ff9ae2012-01-06 22:50:3319#include "ppapi/utility/completion_callback_factory.h"
[email protected]4c2e9352010-11-05 22:13:0220
[email protected]0f41c012011-10-21 19:49:2021// Windows headers interfere with this file.
22#ifdef PostMessage
23#undef PostMessage
24#endif
25
[email protected]98ad9782012-08-22 04:06:2226struct PP_DecryptedBlockInfo;
[email protected]181d9c12012-10-03 22:53:4827struct PP_DecryptedFrameInfo;
[email protected]98ad9782012-08-22 04:06:2228
[email protected]4d2efd22011-08-18 21:58:0229namespace ppapi {
[email protected]4c2e9352010-11-05 22:13:0230namespace proxy {
31
32class SerializedVarReceiveInput;
33class SerializedVarOutParam;
34class SerializedVarReturnValue;
35
[email protected]ceadc392011-06-15 23:04:2436class PPB_Instance_Proxy : public InterfaceProxy,
[email protected]a9b16dd2012-01-31 05:00:2637 public PPB_Instance_Shared {
[email protected]4c2e9352010-11-05 22:13:0238 public:
[email protected]5c966022011-09-13 18:09:3739 PPB_Instance_Proxy(Dispatcher* dispatcher);
[email protected]4c2e9352010-11-05 22:13:0240 virtual ~PPB_Instance_Proxy();
41
[email protected]ceadc392011-06-15 23:04:2442 static const Info* GetInfoPrivate();
[email protected]4c2e9352010-11-05 22:13:0243
44 // InterfaceProxy implementation.
[email protected]a95986a82010-12-24 06:19:2845 virtual bool OnMessageReceived(const IPC::Message& msg);
[email protected]4c2e9352010-11-05 22:13:0246
[email protected]4f2006122012-04-30 05:13:1747 // PPB_Instance_API implementation.
[email protected]ceadc392011-06-15 23:04:2448 virtual PP_Bool BindGraphics(PP_Instance instance,
49 PP_Resource device) OVERRIDE;
50 virtual PP_Bool IsFullFrame(PP_Instance instance) OVERRIDE;
[email protected]e8f07ac2012-01-03 17:43:3651 virtual const ViewData* GetViewData(PP_Instance instance) OVERRIDE;
[email protected]ceadc392011-06-15 23:04:2452 virtual PP_Var GetWindowObject(PP_Instance instance) OVERRIDE;
53 virtual PP_Var GetOwnerElementObject(PP_Instance instance) OVERRIDE;
54 virtual PP_Var ExecuteScript(PP_Instance instance,
55 PP_Var script,
56 PP_Var* exception) OVERRIDE;
[email protected]c59ed5892012-02-18 01:10:1957 virtual uint32_t GetAudioHardwareOutputSampleRate(PP_Instance instance)
58 OVERRIDE;
59 virtual uint32_t GetAudioHardwareOutputBufferSize(PP_Instance instance)
60 OVERRIDE;
[email protected]8d770e492011-10-11 04:54:3161 virtual PP_Var GetDefaultCharSet(PP_Instance instance) OVERRIDE;
[email protected]59cf7022011-09-14 22:44:1962 virtual void NumberOfFindResultsChanged(PP_Instance instance,
63 int32_t total,
64 PP_Bool final_result) OVERRIDE;
65 virtual void SelectedFindResultChanged(PP_Instance instance,
66 int32_t index) OVERRIDE;
[email protected]7a26d92e2012-02-17 20:15:2567 virtual PP_Var GetFontFamilies(PP_Instance instance) OVERRIDE;
[email protected]06e0a342011-09-27 04:24:3068 virtual PP_Bool SetFullscreen(PP_Instance instance,
[email protected]3b98ced72012-03-09 02:08:3369 PP_Bool fullscreen) OVERRIDE;
[email protected]06e0a342011-09-27 04:24:3070 virtual PP_Bool GetScreenSize(PP_Instance instance,
[email protected]a085aed72012-04-24 05:32:0471 PP_Size* size) OVERRIDE;
72 virtual thunk::PPB_Flash_API* GetFlashAPI() OVERRIDE;
[email protected]11d0c362012-10-11 02:02:1173 virtual thunk::PPB_Flash_Functions_API* GetFlashFunctionsAPI(
74 PP_Instance instance) OVERRIDE;
[email protected]f5118812012-08-24 19:54:3075 virtual thunk::PPB_Gamepad_API* GetGamepadAPI(PP_Instance instance) OVERRIDE;
[email protected]493d14212011-07-07 15:38:4876 virtual int32_t RequestInputEvents(PP_Instance instance,
77 uint32_t event_classes) OVERRIDE;
78 virtual int32_t RequestFilteringInputEvents(PP_Instance instance,
79 uint32_t event_classes) OVERRIDE;
80 virtual void ClearInputEventRequest(PP_Instance instance,
81 uint32_t event_classes) OVERRIDE;
[email protected]3b98ced72012-03-09 02:08:3382 virtual void ClosePendingUserGesture(PP_Instance instance,
83 PP_TimeTicks timestamp) OVERRIDE;
[email protected]55a5a522011-07-06 22:52:4084 virtual void ZoomChanged(PP_Instance instance, double factor) OVERRIDE;
85 virtual void ZoomLimitsChanged(PP_Instance instance,
86 double minimum_factor,
87 double maximium_factor) OVERRIDE;
[email protected]c962f862012-04-12 00:02:0488 virtual void PostMessage(PP_Instance instance, PP_Var message) OVERRIDE;
89 virtual PP_Bool SetCursor(PP_Instance instance,
90 PP_MouseCursor_Type type,
91 PP_Resource image,
92 const PP_Point* hot_spot) OVERRIDE;
93 virtual int32_t LockMouse(PP_Instance instance,
[email protected]aed96532012-06-23 14:27:4294 scoped_refptr<TrackedCallback> callback) OVERRIDE;
[email protected]c962f862012-04-12 00:02:0495 virtual void UnlockMouse(PP_Instance instance) OVERRIDE;
[email protected]4c44183a2012-04-27 16:52:2396 virtual void SetTextInputType(PP_Instance instance,
97 PP_TextInput_Type type) OVERRIDE;
98 virtual void UpdateCaretPosition(PP_Instance instance,
99 const PP_Rect& caret,
100 const PP_Rect& bounding_box) OVERRIDE;
101 virtual void CancelCompositionText(PP_Instance instance) OVERRIDE;
102 virtual void SelectionChanged(PP_Instance instance) OVERRIDE;
103 virtual void UpdateSurroundingText(PP_Instance instance,
104 const char* text,
105 uint32_t caret,
106 uint32_t anchor) OVERRIDE;
[email protected]c962f862012-04-12 00:02:04107
108#if !defined(OS_NACL)
[email protected]03460232011-10-10 17:23:57109 virtual PP_Var ResolveRelativeToDocument(
110 PP_Instance instance,
111 PP_Var relative,
112 PP_URLComponents_Dev* components) OVERRIDE;
113 virtual PP_Bool DocumentCanRequest(PP_Instance instance, PP_Var url) OVERRIDE;
114 virtual PP_Bool DocumentCanAccessDocument(PP_Instance instance,
115 PP_Instance target) OVERRIDE;
116 virtual PP_Var GetDocumentURL(PP_Instance instance,
117 PP_URLComponents_Dev* components) OVERRIDE;
118 virtual PP_Var GetPluginInstanceURL(
119 PP_Instance instance,
120 PP_URLComponents_Dev* components) OVERRIDE;
[email protected]e5aeef02012-08-17 00:18:43121 virtual void NeedKey(PP_Instance instance,
122 PP_Var key_system,
123 PP_Var session_id,
124 PP_Var init_data) OVERRIDE;
125 virtual void KeyAdded(PP_Instance instance,
126 PP_Var key_system,
127 PP_Var session_id) OVERRIDE;
128 virtual void KeyMessage(PP_Instance instance,
129 PP_Var key_system,
130 PP_Var session_id,
131 PP_Resource message,
132 PP_Var default_url) OVERRIDE;
133 virtual void KeyError(PP_Instance instance,
134 PP_Var key_system,
135 PP_Var session_id,
136 int32_t media_error,
137 int32_t system_code) OVERRIDE;
138 virtual void DeliverBlock(PP_Instance instance,
139 PP_Resource decrypted_block,
[email protected]98ad9782012-08-22 04:06:22140 const PP_DecryptedBlockInfo* block_info) OVERRIDE;
[email protected]e5aeef02012-08-17 00:18:43141 virtual void DeliverFrame(PP_Instance instance,
142 PP_Resource decrypted_frame,
[email protected]181d9c12012-10-03 22:53:48143 const PP_DecryptedFrameInfo* frame_info) OVERRIDE;
[email protected]e5aeef02012-08-17 00:18:43144 virtual void DeliverSamples(PP_Instance instance,
145 PP_Resource decrypted_samples,
[email protected]98ad9782012-08-22 04:06:22146 const PP_DecryptedBlockInfo* block_info) OVERRIDE;
[email protected]c962f862012-04-12 00:02:04147#endif // !defined(OS_NACL)
[email protected]ceadc392011-06-15 23:04:24148
[email protected]ac4b54d2011-10-20 23:09:28149 static const ApiID kApiID = API_ID_PPB_INSTANCE;
[email protected]5c966022011-09-13 18:09:37150
[email protected]4c2e9352010-11-05 22:13:02151 private:
[email protected]0f41c012011-10-21 19:49:20152 // Plugin -> Host message handlers.
[email protected]e8f07ac2012-01-03 17:43:36153 void OnHostMsgGetWindowObject(PP_Instance instance,
154 SerializedVarReturnValue result);
155 void OnHostMsgGetOwnerElementObject(PP_Instance instance,
[email protected]03460232011-10-10 17:23:57156 SerializedVarReturnValue result);
[email protected]e8f07ac2012-01-03 17:43:36157 void OnHostMsgBindGraphics(PP_Instance instance,
158 const ppapi::HostResource& device,
159 PP_Bool* result);
160 void OnHostMsgIsFullFrame(PP_Instance instance, PP_Bool* result);
161 void OnHostMsgExecuteScript(PP_Instance instance,
162 SerializedVarReceiveInput script,
163 SerializedVarOutParam out_exception,
164 SerializedVarReturnValue result);
[email protected]c59ed5892012-02-18 01:10:19165 void OnHostMsgGetAudioHardwareOutputSampleRate(PP_Instance instance,
166 uint32_t *result);
167 void OnHostMsgGetAudioHardwareOutputBufferSize(PP_Instance instance,
168 uint32_t *result);
[email protected]e8f07ac2012-01-03 17:43:36169 void OnHostMsgGetDefaultCharSet(PP_Instance instance,
170 SerializedVarReturnValue result);
[email protected]e8f07ac2012-01-03 17:43:36171 void OnHostMsgSetFullscreen(PP_Instance instance,
172 PP_Bool fullscreen,
173 PP_Bool* result);
174 void OnHostMsgGetScreenSize(PP_Instance instance,
175 PP_Bool* result,
176 PP_Size* size);
[email protected]e8f07ac2012-01-03 17:43:36177 void OnHostMsgRequestInputEvents(PP_Instance instance,
178 bool is_filtering,
179 uint32_t event_classes);
180 void OnHostMsgClearInputEvents(PP_Instance instance,
181 uint32_t event_classes);
[email protected]3b98ced72012-03-09 02:08:33182 void OnMsgHandleInputEventAck(PP_Instance instance,
183 PP_TimeTicks timestamp);
[email protected]e8f07ac2012-01-03 17:43:36184 void OnHostMsgPostMessage(PP_Instance instance,
185 SerializedVarReceiveInput message);
186 void OnHostMsgLockMouse(PP_Instance instance);
187 void OnHostMsgUnlockMouse(PP_Instance instance);
[email protected]c962f862012-04-12 00:02:04188 void OnHostMsgSetCursor(PP_Instance instance,
189 int32_t type,
190 const ppapi::HostResource& custom_image,
191 const PP_Point& hot_spot);
[email protected]4c44183a2012-04-27 16:52:23192 void OnHostMsgSetTextInputType(PP_Instance instance, PP_TextInput_Type type);
193 void OnHostMsgUpdateCaretPosition(PP_Instance instance,
194 const PP_Rect& caret,
195 const PP_Rect& bounding_box);
196 void OnHostMsgCancelCompositionText(PP_Instance instance);
197 void OnHostMsgUpdateSurroundingText(
198 PP_Instance instance,
199 const std::string& text,
200 uint32_t caret,
201 uint32_t anchor);
[email protected]e5aeef02012-08-17 00:18:43202
[email protected]c962f862012-04-12 00:02:04203#if !defined(OS_NACL)
[email protected]e8f07ac2012-01-03 17:43:36204 void OnHostMsgResolveRelativeToDocument(PP_Instance instance,
205 SerializedVarReceiveInput relative,
206 SerializedVarReturnValue result);
207 void OnHostMsgDocumentCanRequest(PP_Instance instance,
208 SerializedVarReceiveInput url,
209 PP_Bool* result);
210 void OnHostMsgDocumentCanAccessDocument(PP_Instance active,
211 PP_Instance target,
212 PP_Bool* result);
213 void OnHostMsgGetDocumentURL(PP_Instance instance,
214 SerializedVarReturnValue result);
215 void OnHostMsgGetPluginInstanceURL(PP_Instance instance,
216 SerializedVarReturnValue result);
[email protected]e5aeef02012-08-17 00:18:43217 virtual void OnHostMsgNeedKey(PP_Instance instance,
218 SerializedVarReceiveInput key_system,
219 SerializedVarReceiveInput session_id,
220 SerializedVarReceiveInput init_data);
221 virtual void OnHostMsgKeyAdded(PP_Instance instance,
222 SerializedVarReceiveInput key_system,
223 SerializedVarReceiveInput session_id);
224 virtual void OnHostMsgKeyMessage(PP_Instance instance,
225 SerializedVarReceiveInput key_system,
226 SerializedVarReceiveInput session_id,
227 PP_Resource message,
228 SerializedVarReceiveInput default_url);
229 virtual void OnHostMsgKeyError(PP_Instance instance,
230 SerializedVarReceiveInput key_system,
231 SerializedVarReceiveInput session_id,
232 int32_t media_error,
233 int32_t system_code);
234 virtual void OnHostMsgDeliverBlock(PP_Instance instance,
235 PP_Resource decrypted_block,
[email protected]98ad9782012-08-22 04:06:22236 const std::string& serialized_block_info);
[email protected]e5aeef02012-08-17 00:18:43237 virtual void OnHostMsgDeliverFrame(PP_Instance instance,
238 PP_Resource decrypted_frame,
[email protected]98ad9782012-08-22 04:06:22239 const std::string& serialized_block_info);
240 virtual void OnHostMsgDeliverSamples(
241 PP_Instance instance,
242 PP_Resource decrypted_samples,
243 const std::string& serialized_block_info);
[email protected]c962f862012-04-12 00:02:04244#endif // !defined(OS_NACL)
[email protected]0f41c012011-10-21 19:49:20245
246 // Host -> Plugin message handlers.
[email protected]e8f07ac2012-01-03 17:43:36247 void OnPluginMsgMouseLockComplete(PP_Instance instance, int32_t result);
[email protected]0f41c012011-10-21 19:49:20248
249 void MouseLockCompleteInHost(int32_t result, PP_Instance instance);
250
[email protected]a8e72142012-08-21 17:24:20251 // Other helpers.
252 void CancelAnyPendingRequestSurroundingText(PP_Instance instance);
253
[email protected]47a961c2012-07-13 19:18:52254 ProxyCompletionCallbackFactory<PPB_Instance_Proxy> callback_factory_;
[email protected]4c2e9352010-11-05 22:13:02255};
256
257} // namespace proxy
[email protected]4d2efd22011-08-18 21:58:02258} // namespace ppapi
[email protected]4c2e9352010-11-05 22:13:02259
260#endif // PPAPI_PROXY_PPB_INSTANCE_PROXY_H_