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 ClearInputEventRequest(PP_Instance instance
,
77 uint32_t event_classes
) override
;
78 void PostMessage(PP_Instance instance
, PP_Var message
) override
;
79 int32_t RegisterMessageHandler(PP_Instance instance
,
81 const PPP_MessageHandler_0_2
* handler
,
82 PP_Resource message_loop
) override
;
83 void UnregisterMessageHandler(PP_Instance instance
) override
;
84 PP_Bool
SetCursor(PP_Instance instance
,
85 PP_MouseCursor_Type type
,
87 const PP_Point
* hot_spot
) override
;
88 int32_t LockMouse(PP_Instance instance
,
89 scoped_refptr
<TrackedCallback
> callback
) override
;
90 void UnlockMouse(PP_Instance instance
) override
;
91 void SetTextInputType(PP_Instance instance
, PP_TextInput_Type type
) override
;
92 void UpdateCaretPosition(PP_Instance instance
,
94 const PP_Rect
& bounding_box
) override
;
95 void CancelCompositionText(PP_Instance instance
) override
;
96 void SelectionChanged(PP_Instance instance
) override
;
97 void UpdateSurroundingText(PP_Instance instance
,
100 uint32_t anchor
) override
;
101 PP_Var
GetDocumentURL(PP_Instance instance
,
102 PP_URLComponents_Dev
* components
) override
;
103 #if !defined(OS_NACL)
104 PP_Var
ResolveRelativeToDocument(PP_Instance instance
,
106 PP_URLComponents_Dev
* components
) override
;
107 PP_Bool
DocumentCanRequest(PP_Instance instance
, PP_Var url
) override
;
108 PP_Bool
DocumentCanAccessDocument(PP_Instance instance
,
109 PP_Instance target
) override
;
110 PP_Var
GetPluginInstanceURL(PP_Instance instance
,
111 PP_URLComponents_Dev
* components
) override
;
112 PP_Var
GetPluginReferrerURL(PP_Instance instance
,
113 PP_URLComponents_Dev
* components
) override
;
114 void PromiseResolved(PP_Instance instance
, uint32 promise_id
) override
;
115 void PromiseResolvedWithSession(PP_Instance instance
,
117 PP_Var session_id_var
) override
;
118 void PromiseRejected(PP_Instance instance
,
120 PP_CdmExceptionCode exception_code
,
122 PP_Var error_description_var
) override
;
123 void SessionMessage(PP_Instance instance
,
124 PP_Var session_id_var
,
125 PP_CdmMessageType message_type
,
127 PP_Var legacy_destination_url_var
) override
;
128 void SessionKeysChange(
129 PP_Instance instance
,
130 PP_Var session_id_var
,
131 PP_Bool has_additional_usable_key
,
133 const struct PP_KeyInformation key_information
[]) override
;
134 void SessionExpirationChange(PP_Instance instance
,
135 PP_Var session_id_var
,
136 PP_Time new_expiry_time
) override
;
137 void SessionClosed(PP_Instance instance
, PP_Var session_id_var
) override
;
138 void LegacySessionError(PP_Instance instance
,
139 PP_Var session_id_var
,
140 PP_CdmExceptionCode exception_code
,
142 PP_Var error_description_var
) override
;
143 void DeliverBlock(PP_Instance instance
,
144 PP_Resource decrypted_block
,
145 const PP_DecryptedBlockInfo
* block_info
) override
;
146 void DecoderInitializeDone(PP_Instance instance
,
147 PP_DecryptorStreamType decoder_type
,
149 PP_Bool success
) override
;
150 void DecoderDeinitializeDone(PP_Instance instance
,
151 PP_DecryptorStreamType decoder_type
,
152 uint32_t request_id
) override
;
153 void DecoderResetDone(PP_Instance instance
,
154 PP_DecryptorStreamType decoder_type
,
155 uint32_t request_id
) override
;
156 void DeliverFrame(PP_Instance instance
,
157 PP_Resource decrypted_frame
,
158 const PP_DecryptedFrameInfo
* frame_info
) override
;
159 void DeliverSamples(PP_Instance instance
,
160 PP_Resource audio_frames
,
161 const PP_DecryptedSampleInfo
* sample_info
) override
;
162 #endif // !defined(OS_NACL)
164 static const ApiID kApiID
= API_ID_PPB_INSTANCE
;
167 // Plugin -> Host message handlers.
168 void OnHostMsgGetWindowObject(PP_Instance instance
,
169 SerializedVarReturnValue result
);
170 void OnHostMsgGetOwnerElementObject(PP_Instance instance
,
171 SerializedVarReturnValue result
);
172 void OnHostMsgBindGraphics(PP_Instance instance
,
174 void OnHostMsgIsFullFrame(PP_Instance instance
, PP_Bool
* result
);
175 void OnHostMsgExecuteScript(PP_Instance instance
,
176 SerializedVarReceiveInput script
,
177 SerializedVarOutParam out_exception
,
178 SerializedVarReturnValue result
);
179 void OnHostMsgGetAudioHardwareOutputSampleRate(PP_Instance instance
,
181 void OnHostMsgGetAudioHardwareOutputBufferSize(PP_Instance instance
,
183 void OnHostMsgGetDefaultCharSet(PP_Instance instance
,
184 SerializedVarReturnValue result
);
185 void OnHostMsgSetPluginToHandleFindRequests(PP_Instance instance
);
186 void OnHostMsgNumberOfFindResultsChanged(PP_Instance instance
,
188 PP_Bool final_result
);
189 void OnHostMsgSelectFindResultChanged(PP_Instance instance
,
191 void OnHostMsgSetTickmarks(PP_Instance instance
,
192 const std::vector
<PP_Rect
>& tickmarks
);
193 void OnHostMsgSetFullscreen(PP_Instance instance
,
196 void OnHostMsgGetScreenSize(PP_Instance instance
,
199 void OnHostMsgRequestInputEvents(PP_Instance instance
,
201 uint32_t event_classes
);
202 void OnHostMsgClearInputEvents(PP_Instance instance
,
203 uint32_t event_classes
);
204 void OnHostMsgPostMessage(PP_Instance instance
,
205 SerializedVarReceiveInput message
);
206 void OnHostMsgLockMouse(PP_Instance instance
);
207 void OnHostMsgUnlockMouse(PP_Instance instance
);
208 void OnHostMsgSetCursor(PP_Instance instance
,
210 const ppapi::HostResource
& custom_image
,
211 const PP_Point
& hot_spot
);
212 void OnHostMsgSetTextInputType(PP_Instance instance
, PP_TextInput_Type type
);
213 void OnHostMsgUpdateCaretPosition(PP_Instance instance
,
214 const PP_Rect
& caret
,
215 const PP_Rect
& bounding_box
);
216 void OnHostMsgCancelCompositionText(PP_Instance instance
);
217 void OnHostMsgUpdateSurroundingText(
218 PP_Instance instance
,
219 const std::string
& text
,
222 void OnHostMsgGetDocumentURL(PP_Instance instance
,
223 PP_URLComponents_Dev
* components
,
224 SerializedVarReturnValue result
);
226 #if !defined(OS_NACL)
227 void OnHostMsgResolveRelativeToDocument(PP_Instance instance
,
228 SerializedVarReceiveInput relative
,
229 SerializedVarReturnValue result
);
230 void OnHostMsgDocumentCanRequest(PP_Instance instance
,
231 SerializedVarReceiveInput url
,
233 void OnHostMsgDocumentCanAccessDocument(PP_Instance active
,
236 void OnHostMsgGetPluginInstanceURL(PP_Instance instance
,
237 SerializedVarReturnValue result
);
238 void OnHostMsgGetPluginReferrerURL(PP_Instance instance
,
239 SerializedVarReturnValue result
);
241 virtual void OnHostMsgPromiseResolved(PP_Instance instance
,
242 uint32_t promise_id
);
243 virtual void OnHostMsgPromiseResolvedWithSession(
244 PP_Instance instance
,
246 SerializedVarReceiveInput session_id
);
247 virtual void OnHostMsgPromiseRejected(
248 PP_Instance instance
,
250 PP_CdmExceptionCode exception_code
,
251 uint32_t system_code
,
252 SerializedVarReceiveInput error_description
);
253 virtual void OnHostMsgSessionMessage(
254 PP_Instance instance
,
255 SerializedVarReceiveInput session_id
,
256 PP_CdmMessageType message_type
,
257 SerializedVarReceiveInput message
,
258 SerializedVarReceiveInput legacy_destination_url
);
259 virtual void OnHostMsgSessionKeysChange(
260 PP_Instance instance
,
261 const std::string
& session_id
,
262 PP_Bool has_additional_usable_key
,
263 const std::vector
<PP_KeyInformation
>& key_information
);
264 virtual void OnHostMsgSessionExpirationChange(
265 PP_Instance instance
,
266 const std::string
& session_id
,
267 PP_Time new_expiry_time
);
268 virtual void OnHostMsgSessionClosed(PP_Instance instance
,
269 SerializedVarReceiveInput session_id
);
270 virtual void OnHostMsgLegacySessionError(
271 PP_Instance instance
,
272 SerializedVarReceiveInput session_id
,
273 PP_CdmExceptionCode exception_code
,
274 uint32_t system_code
,
275 SerializedVarReceiveInput error_description
);
276 virtual void OnHostMsgDecoderInitializeDone(
277 PP_Instance instance
,
278 PP_DecryptorStreamType decoder_type
,
281 virtual void OnHostMsgDecoderDeinitializeDone(
282 PP_Instance instance
,
283 PP_DecryptorStreamType decoder_type
,
284 uint32_t request_id
);
285 virtual void OnHostMsgDecoderResetDone(PP_Instance instance
,
286 PP_DecryptorStreamType decoder_type
,
287 uint32_t request_id
);
288 virtual void OnHostMsgDeliverBlock(PP_Instance instance
,
289 PP_Resource decrypted_block
,
290 const std::string
& serialized_block_info
);
291 virtual void OnHostMsgDeliverFrame(PP_Instance instance
,
292 PP_Resource decrypted_frame
,
293 const std::string
& serialized_block_info
);
294 virtual void OnHostMsgDeliverSamples(
295 PP_Instance instance
,
296 PP_Resource audio_frames
,
297 const std::string
& serialized_sample_info
);
298 #endif // !defined(OS_NACL)
300 // Host -> Plugin message handlers.
301 void OnPluginMsgMouseLockComplete(PP_Instance instance
, int32_t result
);
303 void MouseLockCompleteInHost(int32_t result
, PP_Instance instance
);
306 void CancelAnyPendingRequestSurroundingText(PP_Instance instance
);
308 ProxyCompletionCallbackFactory
<PPB_Instance_Proxy
> callback_factory_
;
314 #endif // PPAPI_PROXY_PPB_INSTANCE_PROXY_H_