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