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.
5 #ifndef PPAPI_PROXY_PPB_INSTANCE_PROXY_H_
6 #define PPAPI_PROXY_PPB_INSTANCE_PROXY_H_
11 #include "ppapi/c/pp_instance.h"
12 #include "ppapi/c/pp_resource.h"
13 #include "ppapi/c/pp_var.h"
14 #include "ppapi/proxy/interface_proxy.h"
15 #include "ppapi/proxy/proxy_completion_callback_factory.h"
16 #include "ppapi/shared_impl/host_resource.h"
17 #include "ppapi/shared_impl/ppb_instance_shared.h"
18 #include "ppapi/shared_impl/singleton_resource_id.h"
19 #include "ppapi/thunk/ppb_instance_api.h"
20 #include "ppapi/utility/completion_callback_factory.h"
22 // Windows headers interfere with this file.
27 struct PP_DecryptedBlockInfo
;
28 struct PP_DecryptedFrameInfo
;
33 class SerializedVarReceiveInput
;
34 class SerializedVarOutParam
;
35 class SerializedVarReturnValue
;
37 class PPB_Instance_Proxy
: public InterfaceProxy
,
38 public PPB_Instance_Shared
{
40 PPB_Instance_Proxy(Dispatcher
* dispatcher
);
41 virtual ~PPB_Instance_Proxy();
43 // InterfaceProxy implementation.
44 virtual bool OnMessageReceived(const IPC::Message
& msg
);
46 // PPB_Instance_API implementation.
47 virtual PP_Bool
BindGraphics(PP_Instance instance
,
48 PP_Resource device
) OVERRIDE
;
49 virtual PP_Bool
IsFullFrame(PP_Instance instance
) OVERRIDE
;
50 virtual const ViewData
* GetViewData(PP_Instance instance
) OVERRIDE
;
51 virtual PP_Bool
FlashIsFullscreen(PP_Instance instance
) OVERRIDE
;
52 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
,
56 PP_Var
* exception
) OVERRIDE
;
57 virtual uint32_t GetAudioHardwareOutputSampleRate(PP_Instance instance
)
59 virtual uint32_t GetAudioHardwareOutputBufferSize(PP_Instance instance
)
61 virtual PP_Var
GetDefaultCharSet(PP_Instance instance
) OVERRIDE
;
62 virtual void SetPluginToHandleFindRequests(PP_Instance instance
) OVERRIDE
;
63 virtual void NumberOfFindResultsChanged(PP_Instance instance
,
65 PP_Bool final_result
) OVERRIDE
;
66 virtual void SelectedFindResultChanged(PP_Instance instance
,
67 int32_t index
) OVERRIDE
;
68 virtual void SetTickmarks(PP_Instance instance
,
69 const PP_Rect
* tickmarks
,
70 uint32_t count
) OVERRIDE
;
71 virtual PP_Bool
IsFullscreen(PP_Instance instance
) OVERRIDE
;
72 virtual PP_Bool
SetFullscreen(PP_Instance instance
,
73 PP_Bool fullscreen
) OVERRIDE
;
74 virtual PP_Bool
GetScreenSize(PP_Instance instance
,
75 PP_Size
* size
) OVERRIDE
;
76 virtual Resource
* GetSingletonResource(PP_Instance instance
,
77 SingletonResourceID id
) OVERRIDE
;
78 virtual int32_t RequestInputEvents(PP_Instance instance
,
79 uint32_t event_classes
) OVERRIDE
;
80 virtual int32_t RequestFilteringInputEvents(PP_Instance instance
,
81 uint32_t event_classes
) OVERRIDE
;
82 virtual void StartTrackingLatency(PP_Instance instance
) OVERRIDE
;
83 virtual void ClearInputEventRequest(PP_Instance instance
,
84 uint32_t event_classes
) OVERRIDE
;
85 virtual void ZoomChanged(PP_Instance instance
, double factor
) OVERRIDE
;
86 virtual void ZoomLimitsChanged(PP_Instance instance
,
87 double minimum_factor
,
88 double maximium_factor
) OVERRIDE
;
89 virtual void PostMessage(PP_Instance instance
, PP_Var message
) OVERRIDE
;
90 virtual int32_t RegisterMessageHandler(PP_Instance instance
,
92 const PPP_MessageHandler_0_1
* handler
,
93 PP_Resource message_loop
) OVERRIDE
;
94 virtual void UnregisterMessageHandler(PP_Instance instance
) OVERRIDE
;
95 virtual PP_Bool
SetCursor(PP_Instance instance
,
96 PP_MouseCursor_Type type
,
98 const PP_Point
* hot_spot
) OVERRIDE
;
99 virtual int32_t LockMouse(PP_Instance instance
,
100 scoped_refptr
<TrackedCallback
> callback
) OVERRIDE
;
101 virtual void UnlockMouse(PP_Instance instance
) OVERRIDE
;
102 virtual void SetTextInputType(PP_Instance instance
,
103 PP_TextInput_Type type
) OVERRIDE
;
104 virtual void UpdateCaretPosition(PP_Instance instance
,
105 const PP_Rect
& caret
,
106 const PP_Rect
& bounding_box
) OVERRIDE
;
107 virtual void CancelCompositionText(PP_Instance instance
) OVERRIDE
;
108 virtual void SelectionChanged(PP_Instance instance
) OVERRIDE
;
109 virtual void UpdateSurroundingText(PP_Instance instance
,
112 uint32_t anchor
) OVERRIDE
;
113 virtual PP_Var
GetDocumentURL(PP_Instance instance
,
114 PP_URLComponents_Dev
* components
) OVERRIDE
;
115 #if !defined(OS_NACL)
116 virtual PP_Var
ResolveRelativeToDocument(
117 PP_Instance instance
,
119 PP_URLComponents_Dev
* components
) OVERRIDE
;
120 virtual PP_Bool
DocumentCanRequest(PP_Instance instance
, PP_Var url
) OVERRIDE
;
121 virtual PP_Bool
DocumentCanAccessDocument(PP_Instance instance
,
122 PP_Instance target
) OVERRIDE
;
123 virtual PP_Var
GetPluginInstanceURL(
124 PP_Instance instance
,
125 PP_URLComponents_Dev
* components
) OVERRIDE
;
126 virtual PP_Var
GetPluginReferrerURL(
127 PP_Instance instance
,
128 PP_URLComponents_Dev
* components
) OVERRIDE
;
129 virtual void PromiseResolved(PP_Instance instance
,
130 uint32 promise_id
) OVERRIDE
;
131 virtual void PromiseResolvedWithSession(PP_Instance instance
,
133 PP_Var web_session_id_var
) OVERRIDE
;
134 virtual void PromiseResolvedWithKeyIds(PP_Instance instance
,
136 PP_Var key_ids_var
) OVERRIDE
;
137 virtual void PromiseRejected(PP_Instance instance
,
139 PP_CdmExceptionCode exception_code
,
141 PP_Var error_description_var
) OVERRIDE
;
142 virtual void SessionMessage(PP_Instance instance
,
143 PP_Var web_session_id_var
,
145 PP_Var destination_url_var
) OVERRIDE
;
146 virtual void SessionKeysChange(PP_Instance instance
,
147 PP_Var web_session_id_var
,
148 PP_Bool has_additional_usable_key
) OVERRIDE
;
149 virtual void SessionExpirationChange(PP_Instance instance
,
150 PP_Var web_session_id_var
,
151 PP_Time new_expiry_time
) OVERRIDE
;
152 virtual void SessionReady(PP_Instance instance
,
153 PP_Var web_session_id_var
) OVERRIDE
;
154 virtual void SessionClosed(PP_Instance instance
,
155 PP_Var web_session_id_var
) OVERRIDE
;
156 virtual void SessionError(PP_Instance instance
,
157 PP_Var web_session_id_var
,
158 PP_CdmExceptionCode exception_code
,
160 PP_Var error_description_var
) OVERRIDE
;
161 virtual void DeliverBlock(PP_Instance instance
,
162 PP_Resource decrypted_block
,
163 const PP_DecryptedBlockInfo
* block_info
) OVERRIDE
;
164 virtual void DecoderInitializeDone(PP_Instance instance
,
165 PP_DecryptorStreamType decoder_type
,
167 PP_Bool success
) OVERRIDE
;
168 virtual void DecoderDeinitializeDone(PP_Instance instance
,
169 PP_DecryptorStreamType decoder_type
,
170 uint32_t request_id
) OVERRIDE
;
171 virtual void DecoderResetDone(PP_Instance instance
,
172 PP_DecryptorStreamType decoder_type
,
173 uint32_t request_id
) OVERRIDE
;
174 virtual void DeliverFrame(PP_Instance instance
,
175 PP_Resource decrypted_frame
,
176 const PP_DecryptedFrameInfo
* frame_info
) OVERRIDE
;
177 virtual void DeliverSamples(
178 PP_Instance instance
,
179 PP_Resource audio_frames
,
180 const PP_DecryptedSampleInfo
* sample_info
) OVERRIDE
;
181 #endif // !defined(OS_NACL)
183 static const ApiID kApiID
= API_ID_PPB_INSTANCE
;
186 // Plugin -> Host message handlers.
187 void OnHostMsgGetWindowObject(PP_Instance instance
,
188 SerializedVarReturnValue result
);
189 void OnHostMsgGetOwnerElementObject(PP_Instance instance
,
190 SerializedVarReturnValue result
);
191 void OnHostMsgBindGraphics(PP_Instance instance
,
193 void OnHostMsgIsFullFrame(PP_Instance instance
, PP_Bool
* result
);
194 void OnHostMsgExecuteScript(PP_Instance instance
,
195 SerializedVarReceiveInput script
,
196 SerializedVarOutParam out_exception
,
197 SerializedVarReturnValue result
);
198 void OnHostMsgGetAudioHardwareOutputSampleRate(PP_Instance instance
,
200 void OnHostMsgGetAudioHardwareOutputBufferSize(PP_Instance instance
,
202 void OnHostMsgGetDefaultCharSet(PP_Instance instance
,
203 SerializedVarReturnValue result
);
204 void OnHostMsgSetPluginToHandleFindRequests(PP_Instance instance
);
205 void OnHostMsgNumberOfFindResultsChanged(PP_Instance instance
,
207 PP_Bool final_result
);
208 void OnHostMsgSelectFindResultChanged(PP_Instance instance
,
210 void OnHostMsgSetTickmarks(PP_Instance instance
,
211 const std::vector
<PP_Rect
>& tickmarks
);
212 void OnHostMsgSetFullscreen(PP_Instance instance
,
215 void OnHostMsgGetScreenSize(PP_Instance instance
,
218 void OnHostMsgRequestInputEvents(PP_Instance instance
,
220 uint32_t event_classes
);
221 void OnHostMsgStartTrackingLatency(PP_Instance instance
);
222 void OnHostMsgClearInputEvents(PP_Instance instance
,
223 uint32_t event_classes
);
224 void OnHostMsgPostMessage(PP_Instance instance
,
225 SerializedVarReceiveInput message
);
226 void OnHostMsgLockMouse(PP_Instance instance
);
227 void OnHostMsgUnlockMouse(PP_Instance instance
);
228 void OnHostMsgSetCursor(PP_Instance instance
,
230 const ppapi::HostResource
& custom_image
,
231 const PP_Point
& hot_spot
);
232 void OnHostMsgSetTextInputType(PP_Instance instance
, PP_TextInput_Type type
);
233 void OnHostMsgUpdateCaretPosition(PP_Instance instance
,
234 const PP_Rect
& caret
,
235 const PP_Rect
& bounding_box
);
236 void OnHostMsgCancelCompositionText(PP_Instance instance
);
237 void OnHostMsgUpdateSurroundingText(
238 PP_Instance instance
,
239 const std::string
& text
,
242 void OnHostMsgGetDocumentURL(PP_Instance instance
,
243 PP_URLComponents_Dev
* components
,
244 SerializedVarReturnValue result
);
246 #if !defined(OS_NACL)
247 void OnHostMsgResolveRelativeToDocument(PP_Instance instance
,
248 SerializedVarReceiveInput relative
,
249 SerializedVarReturnValue result
);
250 void OnHostMsgDocumentCanRequest(PP_Instance instance
,
251 SerializedVarReceiveInput url
,
253 void OnHostMsgDocumentCanAccessDocument(PP_Instance active
,
256 void OnHostMsgGetPluginInstanceURL(PP_Instance instance
,
257 SerializedVarReturnValue result
);
258 void OnHostMsgGetPluginReferrerURL(PP_Instance instance
,
259 SerializedVarReturnValue result
);
261 virtual void OnHostMsgPromiseResolved(PP_Instance instance
,
262 uint32_t promise_id
);
263 virtual void OnHostMsgPromiseResolvedWithSession(
264 PP_Instance instance
,
266 SerializedVarReceiveInput web_session_id
);
267 virtual void OnHostMsgPromiseResolvedWithKeyIds(
268 PP_Instance instance
,
270 const std::vector
<std::vector
<uint8_t> >& key_ids
);
271 virtual void OnHostMsgPromiseRejected(
272 PP_Instance instance
,
274 PP_CdmExceptionCode exception_code
,
275 uint32_t system_code
,
276 SerializedVarReceiveInput error_description
);
277 virtual void OnHostMsgSessionMessage(
278 PP_Instance instance
,
279 SerializedVarReceiveInput web_session_id
,
280 SerializedVarReceiveInput message
,
281 SerializedVarReceiveInput destination_url
);
282 virtual void OnHostMsgSessionKeysChange(PP_Instance instance
,
283 const std::string
& web_session_id
,
284 PP_Bool has_additional_usable_key
);
285 virtual void OnHostMsgSessionExpirationChange(
286 PP_Instance instance
,
287 const std::string
& web_session_id
,
288 PP_Time new_expiry_time
);
289 virtual void OnHostMsgSessionReady(PP_Instance instance
,
290 SerializedVarReceiveInput web_session_id
);
291 virtual void OnHostMsgSessionClosed(PP_Instance instance
,
292 SerializedVarReceiveInput web_session_id
);
293 virtual void OnHostMsgSessionError(
294 PP_Instance instance
,
295 SerializedVarReceiveInput web_session_id
,
296 PP_CdmExceptionCode exception_code
,
297 uint32_t system_code
,
298 SerializedVarReceiveInput error_description
);
299 virtual void OnHostMsgDecoderInitializeDone(
300 PP_Instance instance
,
301 PP_DecryptorStreamType decoder_type
,
304 virtual void OnHostMsgDecoderDeinitializeDone(
305 PP_Instance instance
,
306 PP_DecryptorStreamType decoder_type
,
307 uint32_t request_id
);
308 virtual void OnHostMsgDecoderResetDone(PP_Instance instance
,
309 PP_DecryptorStreamType decoder_type
,
310 uint32_t request_id
);
311 virtual void OnHostMsgDeliverBlock(PP_Instance instance
,
312 PP_Resource decrypted_block
,
313 const std::string
& serialized_block_info
);
314 virtual void OnHostMsgDeliverFrame(PP_Instance instance
,
315 PP_Resource decrypted_frame
,
316 const std::string
& serialized_block_info
);
317 virtual void OnHostMsgDeliverSamples(
318 PP_Instance instance
,
319 PP_Resource audio_frames
,
320 const std::string
& serialized_sample_info
);
321 #endif // !defined(OS_NACL)
323 // Host -> Plugin message handlers.
324 void OnPluginMsgMouseLockComplete(PP_Instance instance
, int32_t result
);
326 void MouseLockCompleteInHost(int32_t result
, PP_Instance instance
);
329 void CancelAnyPendingRequestSurroundingText(PP_Instance instance
);
331 ProxyCompletionCallbackFactory
<PPB_Instance_Proxy
> callback_factory_
;
337 #endif // PPAPI_PROXY_PPB_INSTANCE_PROXY_H_