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_2
* handler
,
93 PP_Resource message_loop
) override
;
94 virtual int32_t RegisterMessageHandler_1_1_Deprecated(
97 const PPP_MessageHandler_0_1_Deprecated
* handler
,
98 PP_Resource message_loop
) override
;
99 virtual void UnregisterMessageHandler(PP_Instance instance
) override
;
100 virtual PP_Bool
SetCursor(PP_Instance instance
,
101 PP_MouseCursor_Type type
,
103 const PP_Point
* hot_spot
) override
;
104 virtual int32_t LockMouse(PP_Instance instance
,
105 scoped_refptr
<TrackedCallback
> callback
) override
;
106 virtual void UnlockMouse(PP_Instance instance
) override
;
107 virtual void SetTextInputType(PP_Instance instance
,
108 PP_TextInput_Type type
) override
;
109 virtual void UpdateCaretPosition(PP_Instance instance
,
110 const PP_Rect
& caret
,
111 const PP_Rect
& bounding_box
) override
;
112 virtual void CancelCompositionText(PP_Instance instance
) override
;
113 virtual void SelectionChanged(PP_Instance instance
) override
;
114 virtual void UpdateSurroundingText(PP_Instance instance
,
117 uint32_t anchor
) override
;
118 virtual PP_Var
GetDocumentURL(PP_Instance instance
,
119 PP_URLComponents_Dev
* components
) override
;
120 #if !defined(OS_NACL)
121 virtual PP_Var
ResolveRelativeToDocument(
122 PP_Instance instance
,
124 PP_URLComponents_Dev
* components
) override
;
125 virtual PP_Bool
DocumentCanRequest(PP_Instance instance
, PP_Var url
) override
;
126 virtual PP_Bool
DocumentCanAccessDocument(PP_Instance instance
,
127 PP_Instance target
) override
;
128 virtual PP_Var
GetPluginInstanceURL(
129 PP_Instance instance
,
130 PP_URLComponents_Dev
* components
) override
;
131 virtual PP_Var
GetPluginReferrerURL(
132 PP_Instance instance
,
133 PP_URLComponents_Dev
* components
) override
;
134 virtual void PromiseResolved(PP_Instance instance
,
135 uint32 promise_id
) override
;
136 virtual void PromiseResolvedWithSession(PP_Instance instance
,
138 PP_Var web_session_id_var
) override
;
139 virtual void PromiseResolvedWithKeyIds(PP_Instance instance
,
141 PP_Var key_ids_var
) override
;
142 virtual void PromiseRejected(PP_Instance instance
,
144 PP_CdmExceptionCode exception_code
,
146 PP_Var error_description_var
) override
;
147 virtual void SessionMessage(PP_Instance instance
,
148 PP_Var web_session_id_var
,
150 PP_Var destination_url_var
) override
;
151 virtual void SessionKeysChange(PP_Instance instance
,
152 PP_Var web_session_id_var
,
153 PP_Bool has_additional_usable_key
) override
;
154 virtual void SessionExpirationChange(PP_Instance instance
,
155 PP_Var web_session_id_var
,
156 PP_Time new_expiry_time
) override
;
157 virtual void SessionReady(PP_Instance instance
,
158 PP_Var web_session_id_var
) override
;
159 virtual void SessionClosed(PP_Instance instance
,
160 PP_Var web_session_id_var
) override
;
161 virtual void SessionError(PP_Instance instance
,
162 PP_Var web_session_id_var
,
163 PP_CdmExceptionCode exception_code
,
165 PP_Var error_description_var
) override
;
166 virtual void DeliverBlock(PP_Instance instance
,
167 PP_Resource decrypted_block
,
168 const PP_DecryptedBlockInfo
* block_info
) override
;
169 virtual void DecoderInitializeDone(PP_Instance instance
,
170 PP_DecryptorStreamType decoder_type
,
172 PP_Bool success
) override
;
173 virtual void DecoderDeinitializeDone(PP_Instance instance
,
174 PP_DecryptorStreamType decoder_type
,
175 uint32_t request_id
) override
;
176 virtual void DecoderResetDone(PP_Instance instance
,
177 PP_DecryptorStreamType decoder_type
,
178 uint32_t request_id
) override
;
179 virtual void DeliverFrame(PP_Instance instance
,
180 PP_Resource decrypted_frame
,
181 const PP_DecryptedFrameInfo
* frame_info
) override
;
182 virtual void DeliverSamples(
183 PP_Instance instance
,
184 PP_Resource audio_frames
,
185 const PP_DecryptedSampleInfo
* sample_info
) override
;
186 #endif // !defined(OS_NACL)
188 static const ApiID kApiID
= API_ID_PPB_INSTANCE
;
191 // Plugin -> Host message handlers.
192 void OnHostMsgGetWindowObject(PP_Instance instance
,
193 SerializedVarReturnValue result
);
194 void OnHostMsgGetOwnerElementObject(PP_Instance instance
,
195 SerializedVarReturnValue result
);
196 void OnHostMsgBindGraphics(PP_Instance instance
,
198 void OnHostMsgIsFullFrame(PP_Instance instance
, PP_Bool
* result
);
199 void OnHostMsgExecuteScript(PP_Instance instance
,
200 SerializedVarReceiveInput script
,
201 SerializedVarOutParam out_exception
,
202 SerializedVarReturnValue result
);
203 void OnHostMsgGetAudioHardwareOutputSampleRate(PP_Instance instance
,
205 void OnHostMsgGetAudioHardwareOutputBufferSize(PP_Instance instance
,
207 void OnHostMsgGetDefaultCharSet(PP_Instance instance
,
208 SerializedVarReturnValue result
);
209 void OnHostMsgSetPluginToHandleFindRequests(PP_Instance instance
);
210 void OnHostMsgNumberOfFindResultsChanged(PP_Instance instance
,
212 PP_Bool final_result
);
213 void OnHostMsgSelectFindResultChanged(PP_Instance instance
,
215 void OnHostMsgSetTickmarks(PP_Instance instance
,
216 const std::vector
<PP_Rect
>& tickmarks
);
217 void OnHostMsgSetFullscreen(PP_Instance instance
,
220 void OnHostMsgGetScreenSize(PP_Instance instance
,
223 void OnHostMsgRequestInputEvents(PP_Instance instance
,
225 uint32_t event_classes
);
226 void OnHostMsgStartTrackingLatency(PP_Instance instance
);
227 void OnHostMsgClearInputEvents(PP_Instance instance
,
228 uint32_t event_classes
);
229 void OnHostMsgPostMessage(PP_Instance instance
,
230 SerializedVarReceiveInput message
);
231 void OnHostMsgLockMouse(PP_Instance instance
);
232 void OnHostMsgUnlockMouse(PP_Instance instance
);
233 void OnHostMsgSetCursor(PP_Instance instance
,
235 const ppapi::HostResource
& custom_image
,
236 const PP_Point
& hot_spot
);
237 void OnHostMsgSetTextInputType(PP_Instance instance
, PP_TextInput_Type type
);
238 void OnHostMsgUpdateCaretPosition(PP_Instance instance
,
239 const PP_Rect
& caret
,
240 const PP_Rect
& bounding_box
);
241 void OnHostMsgCancelCompositionText(PP_Instance instance
);
242 void OnHostMsgUpdateSurroundingText(
243 PP_Instance instance
,
244 const std::string
& text
,
247 void OnHostMsgGetDocumentURL(PP_Instance instance
,
248 PP_URLComponents_Dev
* components
,
249 SerializedVarReturnValue result
);
251 #if !defined(OS_NACL)
252 void OnHostMsgResolveRelativeToDocument(PP_Instance instance
,
253 SerializedVarReceiveInput relative
,
254 SerializedVarReturnValue result
);
255 void OnHostMsgDocumentCanRequest(PP_Instance instance
,
256 SerializedVarReceiveInput url
,
258 void OnHostMsgDocumentCanAccessDocument(PP_Instance active
,
261 void OnHostMsgGetPluginInstanceURL(PP_Instance instance
,
262 SerializedVarReturnValue result
);
263 void OnHostMsgGetPluginReferrerURL(PP_Instance instance
,
264 SerializedVarReturnValue result
);
266 virtual void OnHostMsgPromiseResolved(PP_Instance instance
,
267 uint32_t promise_id
);
268 virtual void OnHostMsgPromiseResolvedWithSession(
269 PP_Instance instance
,
271 SerializedVarReceiveInput web_session_id
);
272 virtual void OnHostMsgPromiseResolvedWithKeyIds(
273 PP_Instance instance
,
275 const std::vector
<std::vector
<uint8_t> >& key_ids
);
276 virtual void OnHostMsgPromiseRejected(
277 PP_Instance instance
,
279 PP_CdmExceptionCode exception_code
,
280 uint32_t system_code
,
281 SerializedVarReceiveInput error_description
);
282 virtual void OnHostMsgSessionMessage(
283 PP_Instance instance
,
284 SerializedVarReceiveInput web_session_id
,
285 SerializedVarReceiveInput message
,
286 SerializedVarReceiveInput destination_url
);
287 virtual void OnHostMsgSessionKeysChange(PP_Instance instance
,
288 const std::string
& web_session_id
,
289 PP_Bool has_additional_usable_key
);
290 virtual void OnHostMsgSessionExpirationChange(
291 PP_Instance instance
,
292 const std::string
& web_session_id
,
293 PP_Time new_expiry_time
);
294 virtual void OnHostMsgSessionReady(PP_Instance instance
,
295 SerializedVarReceiveInput web_session_id
);
296 virtual void OnHostMsgSessionClosed(PP_Instance instance
,
297 SerializedVarReceiveInput web_session_id
);
298 virtual void OnHostMsgSessionError(
299 PP_Instance instance
,
300 SerializedVarReceiveInput web_session_id
,
301 PP_CdmExceptionCode exception_code
,
302 uint32_t system_code
,
303 SerializedVarReceiveInput error_description
);
304 virtual void OnHostMsgDecoderInitializeDone(
305 PP_Instance instance
,
306 PP_DecryptorStreamType decoder_type
,
309 virtual void OnHostMsgDecoderDeinitializeDone(
310 PP_Instance instance
,
311 PP_DecryptorStreamType decoder_type
,
312 uint32_t request_id
);
313 virtual void OnHostMsgDecoderResetDone(PP_Instance instance
,
314 PP_DecryptorStreamType decoder_type
,
315 uint32_t request_id
);
316 virtual void OnHostMsgDeliverBlock(PP_Instance instance
,
317 PP_Resource decrypted_block
,
318 const std::string
& serialized_block_info
);
319 virtual void OnHostMsgDeliverFrame(PP_Instance instance
,
320 PP_Resource decrypted_frame
,
321 const std::string
& serialized_block_info
);
322 virtual void OnHostMsgDeliverSamples(
323 PP_Instance instance
,
324 PP_Resource audio_frames
,
325 const std::string
& serialized_sample_info
);
326 #endif // !defined(OS_NACL)
328 // Host -> Plugin message handlers.
329 void OnPluginMsgMouseLockComplete(PP_Instance instance
, int32_t result
);
331 void MouseLockCompleteInHost(int32_t result
, PP_Instance instance
);
334 void CancelAnyPendingRequestSurroundingText(PP_Instance instance
);
336 ProxyCompletionCallbackFactory
<PPB_Instance_Proxy
> callback_factory_
;
342 #endif // PPAPI_PROXY_PPB_INSTANCE_PROXY_H_