Add wfh@ to chrome/browser/resources/plugin_metadata OWNERS.
[chromium-blink-merge.git] / ppapi / proxy / ppb_instance_proxy.h
blob6cf3d06d2ab400ce314e498fa290af39ecc22e63
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_
8 #include <string>
9 #include <vector>
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.
23 #ifdef PostMessage
24 #undef PostMessage
25 #endif
27 struct PP_DecryptedBlockInfo;
28 struct PP_DecryptedFrameInfo;
30 namespace ppapi {
31 namespace proxy {
33 class SerializedVarReceiveInput;
34 class SerializedVarOutParam;
35 class SerializedVarReturnValue;
37 class PPB_Instance_Proxy : public InterfaceProxy,
38 public PPB_Instance_Shared {
39 public:
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,
54 PP_Var script,
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,
61 int32_t total,
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 ZoomChanged(PP_Instance instance, double factor) override;
80 void ZoomLimitsChanged(PP_Instance instance,
81 double minimum_factor,
82 double maximium_factor) override;
83 void PostMessage(PP_Instance instance, PP_Var message) override;
84 int32_t RegisterMessageHandler(PP_Instance instance,
85 void* user_data,
86 const PPP_MessageHandler_0_2* handler,
87 PP_Resource message_loop) override;
88 int32_t RegisterMessageHandler_1_1_Deprecated(
89 PP_Instance instance,
90 void* user_data,
91 const PPP_MessageHandler_0_1_Deprecated* handler,
92 PP_Resource message_loop) override;
93 void UnregisterMessageHandler(PP_Instance instance) override;
94 PP_Bool SetCursor(PP_Instance instance,
95 PP_MouseCursor_Type type,
96 PP_Resource image,
97 const PP_Point* hot_spot) override;
98 int32_t LockMouse(PP_Instance instance,
99 scoped_refptr<TrackedCallback> callback) override;
100 void UnlockMouse(PP_Instance instance) override;
101 void SetTextInputType(PP_Instance instance, PP_TextInput_Type type) override;
102 void UpdateCaretPosition(PP_Instance instance,
103 const PP_Rect& caret,
104 const PP_Rect& bounding_box) override;
105 void CancelCompositionText(PP_Instance instance) override;
106 void SelectionChanged(PP_Instance instance) override;
107 void UpdateSurroundingText(PP_Instance instance,
108 const char* text,
109 uint32_t caret,
110 uint32_t anchor) override;
111 PP_Var GetDocumentURL(PP_Instance instance,
112 PP_URLComponents_Dev* components) override;
113 #if !defined(OS_NACL)
114 PP_Var ResolveRelativeToDocument(PP_Instance instance,
115 PP_Var relative,
116 PP_URLComponents_Dev* components) override;
117 PP_Bool DocumentCanRequest(PP_Instance instance, PP_Var url) override;
118 PP_Bool DocumentCanAccessDocument(PP_Instance instance,
119 PP_Instance target) override;
120 PP_Var GetPluginInstanceURL(PP_Instance instance,
121 PP_URLComponents_Dev* components) override;
122 PP_Var GetPluginReferrerURL(PP_Instance instance,
123 PP_URLComponents_Dev* components) override;
124 void PromiseResolved(PP_Instance instance, uint32 promise_id) override;
125 void PromiseResolvedWithSession(PP_Instance instance,
126 uint32 promise_id,
127 PP_Var session_id_var) override;
128 void PromiseRejected(PP_Instance instance,
129 uint32 promise_id,
130 PP_CdmExceptionCode exception_code,
131 uint32 system_code,
132 PP_Var error_description_var) override;
133 void SessionMessage(PP_Instance instance,
134 PP_Var session_id_var,
135 PP_CdmMessageType message_type,
136 PP_Var message_var,
137 PP_Var legacy_destination_url_var) override;
138 void SessionKeysChange(
139 PP_Instance instance,
140 PP_Var session_id_var,
141 PP_Bool has_additional_usable_key,
142 uint32_t key_count,
143 const struct PP_KeyInformation key_information[]) override;
144 void SessionExpirationChange(PP_Instance instance,
145 PP_Var session_id_var,
146 PP_Time new_expiry_time) override;
147 void SessionClosed(PP_Instance instance, PP_Var session_id_var) override;
148 void SessionError(PP_Instance instance,
149 PP_Var session_id_var,
150 PP_CdmExceptionCode exception_code,
151 uint32 system_code,
152 PP_Var error_description_var) override;
153 void DeliverBlock(PP_Instance instance,
154 PP_Resource decrypted_block,
155 const PP_DecryptedBlockInfo* block_info) override;
156 void DecoderInitializeDone(PP_Instance instance,
157 PP_DecryptorStreamType decoder_type,
158 uint32_t request_id,
159 PP_Bool success) override;
160 void DecoderDeinitializeDone(PP_Instance instance,
161 PP_DecryptorStreamType decoder_type,
162 uint32_t request_id) override;
163 void DecoderResetDone(PP_Instance instance,
164 PP_DecryptorStreamType decoder_type,
165 uint32_t request_id) override;
166 void DeliverFrame(PP_Instance instance,
167 PP_Resource decrypted_frame,
168 const PP_DecryptedFrameInfo* frame_info) override;
169 void DeliverSamples(PP_Instance instance,
170 PP_Resource audio_frames,
171 const PP_DecryptedSampleInfo* sample_info) override;
172 #endif // !defined(OS_NACL)
174 static const ApiID kApiID = API_ID_PPB_INSTANCE;
176 private:
177 // Plugin -> Host message handlers.
178 void OnHostMsgGetWindowObject(PP_Instance instance,
179 SerializedVarReturnValue result);
180 void OnHostMsgGetOwnerElementObject(PP_Instance instance,
181 SerializedVarReturnValue result);
182 void OnHostMsgBindGraphics(PP_Instance instance,
183 PP_Resource device);
184 void OnHostMsgIsFullFrame(PP_Instance instance, PP_Bool* result);
185 void OnHostMsgExecuteScript(PP_Instance instance,
186 SerializedVarReceiveInput script,
187 SerializedVarOutParam out_exception,
188 SerializedVarReturnValue result);
189 void OnHostMsgGetAudioHardwareOutputSampleRate(PP_Instance instance,
190 uint32_t *result);
191 void OnHostMsgGetAudioHardwareOutputBufferSize(PP_Instance instance,
192 uint32_t *result);
193 void OnHostMsgGetDefaultCharSet(PP_Instance instance,
194 SerializedVarReturnValue result);
195 void OnHostMsgSetPluginToHandleFindRequests(PP_Instance instance);
196 void OnHostMsgNumberOfFindResultsChanged(PP_Instance instance,
197 int32_t total,
198 PP_Bool final_result);
199 void OnHostMsgSelectFindResultChanged(PP_Instance instance,
200 int32_t index);
201 void OnHostMsgSetTickmarks(PP_Instance instance,
202 const std::vector<PP_Rect>& tickmarks);
203 void OnHostMsgSetFullscreen(PP_Instance instance,
204 PP_Bool fullscreen,
205 PP_Bool* result);
206 void OnHostMsgGetScreenSize(PP_Instance instance,
207 PP_Bool* result,
208 PP_Size* size);
209 void OnHostMsgRequestInputEvents(PP_Instance instance,
210 bool is_filtering,
211 uint32_t event_classes);
212 void OnHostMsgStartTrackingLatency(PP_Instance instance);
213 void OnHostMsgClearInputEvents(PP_Instance instance,
214 uint32_t event_classes);
215 void OnHostMsgPostMessage(PP_Instance instance,
216 SerializedVarReceiveInput message);
217 void OnHostMsgLockMouse(PP_Instance instance);
218 void OnHostMsgUnlockMouse(PP_Instance instance);
219 void OnHostMsgSetCursor(PP_Instance instance,
220 int32_t type,
221 const ppapi::HostResource& custom_image,
222 const PP_Point& hot_spot);
223 void OnHostMsgSetTextInputType(PP_Instance instance, PP_TextInput_Type type);
224 void OnHostMsgUpdateCaretPosition(PP_Instance instance,
225 const PP_Rect& caret,
226 const PP_Rect& bounding_box);
227 void OnHostMsgCancelCompositionText(PP_Instance instance);
228 void OnHostMsgUpdateSurroundingText(
229 PP_Instance instance,
230 const std::string& text,
231 uint32_t caret,
232 uint32_t anchor);
233 void OnHostMsgGetDocumentURL(PP_Instance instance,
234 PP_URLComponents_Dev* components,
235 SerializedVarReturnValue result);
237 #if !defined(OS_NACL)
238 void OnHostMsgResolveRelativeToDocument(PP_Instance instance,
239 SerializedVarReceiveInput relative,
240 SerializedVarReturnValue result);
241 void OnHostMsgDocumentCanRequest(PP_Instance instance,
242 SerializedVarReceiveInput url,
243 PP_Bool* result);
244 void OnHostMsgDocumentCanAccessDocument(PP_Instance active,
245 PP_Instance target,
246 PP_Bool* result);
247 void OnHostMsgGetPluginInstanceURL(PP_Instance instance,
248 SerializedVarReturnValue result);
249 void OnHostMsgGetPluginReferrerURL(PP_Instance instance,
250 SerializedVarReturnValue result);
252 virtual void OnHostMsgPromiseResolved(PP_Instance instance,
253 uint32_t promise_id);
254 virtual void OnHostMsgPromiseResolvedWithSession(
255 PP_Instance instance,
256 uint32_t promise_id,
257 SerializedVarReceiveInput session_id);
258 virtual void OnHostMsgPromiseRejected(
259 PP_Instance instance,
260 uint32_t promise_id,
261 PP_CdmExceptionCode exception_code,
262 uint32_t system_code,
263 SerializedVarReceiveInput error_description);
264 virtual void OnHostMsgSessionMessage(
265 PP_Instance instance,
266 SerializedVarReceiveInput session_id,
267 PP_CdmMessageType message_type,
268 SerializedVarReceiveInput message,
269 SerializedVarReceiveInput legacy_destination_url);
270 virtual void OnHostMsgSessionKeysChange(
271 PP_Instance instance,
272 const std::string& session_id,
273 PP_Bool has_additional_usable_key,
274 const std::vector<PP_KeyInformation>& key_information);
275 virtual void OnHostMsgSessionExpirationChange(
276 PP_Instance instance,
277 const std::string& session_id,
278 PP_Time new_expiry_time);
279 virtual void OnHostMsgSessionClosed(PP_Instance instance,
280 SerializedVarReceiveInput session_id);
281 virtual void OnHostMsgSessionError(
282 PP_Instance instance,
283 SerializedVarReceiveInput session_id,
284 PP_CdmExceptionCode exception_code,
285 uint32_t system_code,
286 SerializedVarReceiveInput error_description);
287 virtual void OnHostMsgDecoderInitializeDone(
288 PP_Instance instance,
289 PP_DecryptorStreamType decoder_type,
290 uint32_t request_id,
291 PP_Bool success);
292 virtual void OnHostMsgDecoderDeinitializeDone(
293 PP_Instance instance,
294 PP_DecryptorStreamType decoder_type,
295 uint32_t request_id);
296 virtual void OnHostMsgDecoderResetDone(PP_Instance instance,
297 PP_DecryptorStreamType decoder_type,
298 uint32_t request_id);
299 virtual void OnHostMsgDeliverBlock(PP_Instance instance,
300 PP_Resource decrypted_block,
301 const std::string& serialized_block_info);
302 virtual void OnHostMsgDeliverFrame(PP_Instance instance,
303 PP_Resource decrypted_frame,
304 const std::string& serialized_block_info);
305 virtual void OnHostMsgDeliverSamples(
306 PP_Instance instance,
307 PP_Resource audio_frames,
308 const std::string& serialized_sample_info);
309 #endif // !defined(OS_NACL)
311 // Host -> Plugin message handlers.
312 void OnPluginMsgMouseLockComplete(PP_Instance instance, int32_t result);
314 void MouseLockCompleteInHost(int32_t result, PP_Instance instance);
316 // Other helpers.
317 void CancelAnyPendingRequestSurroundingText(PP_Instance instance);
319 ProxyCompletionCallbackFactory<PPB_Instance_Proxy> callback_factory_;
322 } // namespace proxy
323 } // namespace ppapi
325 #endif // PPAPI_PROXY_PPB_INSTANCE_PROXY_H_