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 ~PPB_Instance_Proxy() override
;
43 // InterfaceProxy implementation.
44 bool OnMessageReceived(const IPC::Message
& msg
) override
;
46 // PPB_Instance_API implementation.
47 PP_Bool
BindGraphics(PP_Instance instance
, PP_Resource device
) override
;
48 PP_Bool
IsFullFrame(PP_Instance instance
) override
;
49 const ViewData
* GetViewData(PP_Instance instance
) override
;
50 PP_Bool
FlashIsFullscreen(PP_Instance instance
) override
;
51 PP_Var
GetWindowObject(PP_Instance instance
) override
;
52 PP_Var
GetOwnerElementObject(PP_Instance instance
) override
;
53 PP_Var
ExecuteScript(PP_Instance instance
,
55 PP_Var
* exception
) override
;
56 uint32_t GetAudioHardwareOutputSampleRate(PP_Instance instance
) override
;
57 uint32_t GetAudioHardwareOutputBufferSize(PP_Instance instance
) override
;
58 PP_Var
GetDefaultCharSet(PP_Instance instance
) override
;
59 void SetPluginToHandleFindRequests(PP_Instance instance
) override
;
60 void NumberOfFindResultsChanged(PP_Instance instance
,
62 PP_Bool final_result
) override
;
63 void SelectedFindResultChanged(PP_Instance instance
, int32_t index
) override
;
64 void SetTickmarks(PP_Instance instance
,
65 const PP_Rect
* tickmarks
,
66 uint32_t count
) override
;
67 PP_Bool
IsFullscreen(PP_Instance instance
) override
;
68 PP_Bool
SetFullscreen(PP_Instance instance
, PP_Bool fullscreen
) override
;
69 PP_Bool
GetScreenSize(PP_Instance instance
, PP_Size
* size
) override
;
70 Resource
* GetSingletonResource(PP_Instance instance
,
71 SingletonResourceID id
) override
;
72 int32_t RequestInputEvents(PP_Instance instance
,
73 uint32_t event_classes
) override
;
74 int32_t RequestFilteringInputEvents(PP_Instance instance
,
75 uint32_t event_classes
) override
;
76 void StartTrackingLatency(PP_Instance instance
) override
;
77 void ClearInputEventRequest(PP_Instance instance
,
78 uint32_t event_classes
) override
;
79 void PostMessage(PP_Instance instance
, PP_Var message
) override
;
80 int32_t RegisterMessageHandler(PP_Instance instance
,
82 const PPP_MessageHandler_0_2
* handler
,
83 PP_Resource message_loop
) override
;
84 void UnregisterMessageHandler(PP_Instance instance
) override
;
85 PP_Bool
SetCursor(PP_Instance instance
,
86 PP_MouseCursor_Type type
,
88 const PP_Point
* hot_spot
) override
;
89 int32_t LockMouse(PP_Instance instance
,
90 scoped_refptr
<TrackedCallback
> callback
) override
;
91 void UnlockMouse(PP_Instance instance
) override
;
92 void SetTextInputType(PP_Instance instance
, PP_TextInput_Type type
) override
;
93 void UpdateCaretPosition(PP_Instance instance
,
95 const PP_Rect
& bounding_box
) override
;
96 void CancelCompositionText(PP_Instance instance
) override
;
97 void SelectionChanged(PP_Instance instance
) override
;
98 void UpdateSurroundingText(PP_Instance instance
,
101 uint32_t anchor
) override
;
102 PP_Var
GetDocumentURL(PP_Instance instance
,
103 PP_URLComponents_Dev
* components
) override
;
104 #if !defined(OS_NACL)
105 PP_Var
ResolveRelativeToDocument(PP_Instance instance
,
107 PP_URLComponents_Dev
* components
) override
;
108 PP_Bool
DocumentCanRequest(PP_Instance instance
, PP_Var url
) override
;
109 PP_Bool
DocumentCanAccessDocument(PP_Instance instance
,
110 PP_Instance target
) override
;
111 PP_Var
GetPluginInstanceURL(PP_Instance instance
,
112 PP_URLComponents_Dev
* components
) override
;
113 PP_Var
GetPluginReferrerURL(PP_Instance instance
,
114 PP_URLComponents_Dev
* components
) override
;
115 void PromiseResolved(PP_Instance instance
, uint32 promise_id
) override
;
116 void PromiseResolvedWithSession(PP_Instance instance
,
118 PP_Var session_id_var
) override
;
119 void PromiseRejected(PP_Instance instance
,
121 PP_CdmExceptionCode exception_code
,
123 PP_Var error_description_var
) override
;
124 void SessionMessage(PP_Instance instance
,
125 PP_Var session_id_var
,
126 PP_CdmMessageType message_type
,
128 PP_Var legacy_destination_url_var
) override
;
129 void SessionKeysChange(
130 PP_Instance instance
,
131 PP_Var session_id_var
,
132 PP_Bool has_additional_usable_key
,
134 const struct PP_KeyInformation key_information
[]) override
;
135 void SessionExpirationChange(PP_Instance instance
,
136 PP_Var session_id_var
,
137 PP_Time new_expiry_time
) override
;
138 void SessionClosed(PP_Instance instance
, PP_Var session_id_var
) override
;
139 void LegacySessionError(PP_Instance instance
,
140 PP_Var session_id_var
,
141 PP_CdmExceptionCode exception_code
,
143 PP_Var error_description_var
) override
;
144 void DeliverBlock(PP_Instance instance
,
145 PP_Resource decrypted_block
,
146 const PP_DecryptedBlockInfo
* block_info
) override
;
147 void DecoderInitializeDone(PP_Instance instance
,
148 PP_DecryptorStreamType decoder_type
,
150 PP_Bool success
) override
;
151 void DecoderDeinitializeDone(PP_Instance instance
,
152 PP_DecryptorStreamType decoder_type
,
153 uint32_t request_id
) override
;
154 void DecoderResetDone(PP_Instance instance
,
155 PP_DecryptorStreamType decoder_type
,
156 uint32_t request_id
) override
;
157 void DeliverFrame(PP_Instance instance
,
158 PP_Resource decrypted_frame
,
159 const PP_DecryptedFrameInfo
* frame_info
) override
;
160 void DeliverSamples(PP_Instance instance
,
161 PP_Resource audio_frames
,
162 const PP_DecryptedSampleInfo
* sample_info
) override
;
163 #endif // !defined(OS_NACL)
165 static const ApiID kApiID
= API_ID_PPB_INSTANCE
;
168 // Plugin -> Host message handlers.
169 void OnHostMsgGetWindowObject(PP_Instance instance
,
170 SerializedVarReturnValue result
);
171 void OnHostMsgGetOwnerElementObject(PP_Instance instance
,
172 SerializedVarReturnValue result
);
173 void OnHostMsgBindGraphics(PP_Instance instance
,
175 void OnHostMsgIsFullFrame(PP_Instance instance
, PP_Bool
* result
);
176 void OnHostMsgExecuteScript(PP_Instance instance
,
177 SerializedVarReceiveInput script
,
178 SerializedVarOutParam out_exception
,
179 SerializedVarReturnValue result
);
180 void OnHostMsgGetAudioHardwareOutputSampleRate(PP_Instance instance
,
182 void OnHostMsgGetAudioHardwareOutputBufferSize(PP_Instance instance
,
184 void OnHostMsgGetDefaultCharSet(PP_Instance instance
,
185 SerializedVarReturnValue result
);
186 void OnHostMsgSetPluginToHandleFindRequests(PP_Instance instance
);
187 void OnHostMsgNumberOfFindResultsChanged(PP_Instance instance
,
189 PP_Bool final_result
);
190 void OnHostMsgSelectFindResultChanged(PP_Instance instance
,
192 void OnHostMsgSetTickmarks(PP_Instance instance
,
193 const std::vector
<PP_Rect
>& tickmarks
);
194 void OnHostMsgSetFullscreen(PP_Instance instance
,
197 void OnHostMsgGetScreenSize(PP_Instance instance
,
200 void OnHostMsgRequestInputEvents(PP_Instance instance
,
202 uint32_t event_classes
);
203 void OnHostMsgStartTrackingLatency(PP_Instance instance
);
204 void OnHostMsgClearInputEvents(PP_Instance instance
,
205 uint32_t event_classes
);
206 void OnHostMsgPostMessage(PP_Instance instance
,
207 SerializedVarReceiveInput message
);
208 void OnHostMsgLockMouse(PP_Instance instance
);
209 void OnHostMsgUnlockMouse(PP_Instance instance
);
210 void OnHostMsgSetCursor(PP_Instance instance
,
212 const ppapi::HostResource
& custom_image
,
213 const PP_Point
& hot_spot
);
214 void OnHostMsgSetTextInputType(PP_Instance instance
, PP_TextInput_Type type
);
215 void OnHostMsgUpdateCaretPosition(PP_Instance instance
,
216 const PP_Rect
& caret
,
217 const PP_Rect
& bounding_box
);
218 void OnHostMsgCancelCompositionText(PP_Instance instance
);
219 void OnHostMsgUpdateSurroundingText(
220 PP_Instance instance
,
221 const std::string
& text
,
224 void OnHostMsgGetDocumentURL(PP_Instance instance
,
225 PP_URLComponents_Dev
* components
,
226 SerializedVarReturnValue result
);
228 #if !defined(OS_NACL)
229 void OnHostMsgResolveRelativeToDocument(PP_Instance instance
,
230 SerializedVarReceiveInput relative
,
231 SerializedVarReturnValue result
);
232 void OnHostMsgDocumentCanRequest(PP_Instance instance
,
233 SerializedVarReceiveInput url
,
235 void OnHostMsgDocumentCanAccessDocument(PP_Instance active
,
238 void OnHostMsgGetPluginInstanceURL(PP_Instance instance
,
239 SerializedVarReturnValue result
);
240 void OnHostMsgGetPluginReferrerURL(PP_Instance instance
,
241 SerializedVarReturnValue result
);
243 virtual void OnHostMsgPromiseResolved(PP_Instance instance
,
244 uint32_t promise_id
);
245 virtual void OnHostMsgPromiseResolvedWithSession(
246 PP_Instance instance
,
248 SerializedVarReceiveInput session_id
);
249 virtual void OnHostMsgPromiseRejected(
250 PP_Instance instance
,
252 PP_CdmExceptionCode exception_code
,
253 uint32_t system_code
,
254 SerializedVarReceiveInput error_description
);
255 virtual void OnHostMsgSessionMessage(
256 PP_Instance instance
,
257 SerializedVarReceiveInput session_id
,
258 PP_CdmMessageType message_type
,
259 SerializedVarReceiveInput message
,
260 SerializedVarReceiveInput legacy_destination_url
);
261 virtual void OnHostMsgSessionKeysChange(
262 PP_Instance instance
,
263 const std::string
& session_id
,
264 PP_Bool has_additional_usable_key
,
265 const std::vector
<PP_KeyInformation
>& key_information
);
266 virtual void OnHostMsgSessionExpirationChange(
267 PP_Instance instance
,
268 const std::string
& session_id
,
269 PP_Time new_expiry_time
);
270 virtual void OnHostMsgSessionClosed(PP_Instance instance
,
271 SerializedVarReceiveInput session_id
);
272 virtual void OnHostMsgLegacySessionError(
273 PP_Instance instance
,
274 SerializedVarReceiveInput session_id
,
275 PP_CdmExceptionCode exception_code
,
276 uint32_t system_code
,
277 SerializedVarReceiveInput error_description
);
278 virtual void OnHostMsgDecoderInitializeDone(
279 PP_Instance instance
,
280 PP_DecryptorStreamType decoder_type
,
283 virtual void OnHostMsgDecoderDeinitializeDone(
284 PP_Instance instance
,
285 PP_DecryptorStreamType decoder_type
,
286 uint32_t request_id
);
287 virtual void OnHostMsgDecoderResetDone(PP_Instance instance
,
288 PP_DecryptorStreamType decoder_type
,
289 uint32_t request_id
);
290 virtual void OnHostMsgDeliverBlock(PP_Instance instance
,
291 PP_Resource decrypted_block
,
292 const std::string
& serialized_block_info
);
293 virtual void OnHostMsgDeliverFrame(PP_Instance instance
,
294 PP_Resource decrypted_frame
,
295 const std::string
& serialized_block_info
);
296 virtual void OnHostMsgDeliverSamples(
297 PP_Instance instance
,
298 PP_Resource audio_frames
,
299 const std::string
& serialized_sample_info
);
300 #endif // !defined(OS_NACL)
302 // Host -> Plugin message handlers.
303 void OnPluginMsgMouseLockComplete(PP_Instance instance
, int32_t result
);
305 void MouseLockCompleteInHost(int32_t result
, PP_Instance instance
);
308 void CancelAnyPendingRequestSurroundingText(PP_Instance instance
);
310 ProxyCompletionCallbackFactory
<PPB_Instance_Proxy
> callback_factory_
;
316 #endif // PPAPI_PROXY_PPB_INSTANCE_PROXY_H_