Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ppapi / proxy / ppb_instance_proxy.h
blob24086741d54e1f72b0f78f35fdb92778ae4d12e1
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>
10 #include "ppapi/c/pp_instance.h"
11 #include "ppapi/c/pp_resource.h"
12 #include "ppapi/c/pp_var.h"
13 #include "ppapi/proxy/interface_proxy.h"
14 #include "ppapi/proxy/proxy_completion_callback_factory.h"
15 #include "ppapi/shared_impl/host_resource.h"
16 #include "ppapi/shared_impl/ppb_instance_shared.h"
17 #include "ppapi/shared_impl/singleton_resource_id.h"
18 #include "ppapi/thunk/ppb_instance_api.h"
19 #include "ppapi/utility/completion_callback_factory.h"
21 // Windows headers interfere with this file.
22 #ifdef PostMessage
23 #undef PostMessage
24 #endif
26 struct PP_DecryptedBlockInfo;
27 struct PP_DecryptedFrameInfo;
29 namespace ppapi {
30 namespace proxy {
32 class SerializedVarReceiveInput;
33 class SerializedVarOutParam;
34 class SerializedVarReturnValue;
36 class PPB_Instance_Proxy : public InterfaceProxy,
37 public PPB_Instance_Shared {
38 public:
39 PPB_Instance_Proxy(Dispatcher* dispatcher);
40 virtual ~PPB_Instance_Proxy();
42 // InterfaceProxy implementation.
43 virtual bool OnMessageReceived(const IPC::Message& msg);
45 // PPB_Instance_API implementation.
46 virtual PP_Bool BindGraphics(PP_Instance instance,
47 PP_Resource device) OVERRIDE;
48 virtual PP_Bool IsFullFrame(PP_Instance instance) OVERRIDE;
49 virtual const ViewData* GetViewData(PP_Instance instance) OVERRIDE;
50 virtual PP_Bool FlashIsFullscreen(PP_Instance instance) OVERRIDE;
51 virtual PP_Var GetWindowObject(PP_Instance instance) OVERRIDE;
52 virtual PP_Var GetOwnerElementObject(PP_Instance instance) OVERRIDE;
53 virtual PP_Var ExecuteScript(PP_Instance instance,
54 PP_Var script,
55 PP_Var* exception) OVERRIDE;
56 virtual uint32_t GetAudioHardwareOutputSampleRate(PP_Instance instance)
57 OVERRIDE;
58 virtual uint32_t GetAudioHardwareOutputBufferSize(PP_Instance instance)
59 OVERRIDE;
60 virtual PP_Var GetDefaultCharSet(PP_Instance instance) OVERRIDE;
61 virtual void SetPluginToHandleFindRequests(PP_Instance instance) OVERRIDE;
62 virtual void NumberOfFindResultsChanged(PP_Instance instance,
63 int32_t total,
64 PP_Bool final_result) OVERRIDE;
65 virtual void SelectedFindResultChanged(PP_Instance instance,
66 int32_t index) OVERRIDE;
67 virtual void SetTickmarks(PP_Instance instance,
68 const PP_Rect* tickmarks,
69 uint32_t count) OVERRIDE;
70 virtual PP_Bool IsFullscreen(PP_Instance instance) OVERRIDE;
71 virtual PP_Bool SetFullscreen(PP_Instance instance,
72 PP_Bool fullscreen) OVERRIDE;
73 virtual PP_Bool GetScreenSize(PP_Instance instance,
74 PP_Size* size) OVERRIDE;
75 virtual Resource* GetSingletonResource(PP_Instance instance,
76 SingletonResourceID id) OVERRIDE;
77 virtual int32_t RequestInputEvents(PP_Instance instance,
78 uint32_t event_classes) OVERRIDE;
79 virtual int32_t RequestFilteringInputEvents(PP_Instance instance,
80 uint32_t event_classes) OVERRIDE;
81 virtual void StartTrackingLatency(PP_Instance instance) OVERRIDE;
82 virtual void ClearInputEventRequest(PP_Instance instance,
83 uint32_t event_classes) OVERRIDE;
84 virtual void ZoomChanged(PP_Instance instance, double factor) OVERRIDE;
85 virtual void ZoomLimitsChanged(PP_Instance instance,
86 double minimum_factor,
87 double maximium_factor) OVERRIDE;
88 virtual void PostMessage(PP_Instance instance, PP_Var message) OVERRIDE;
89 virtual int32_t RegisterMessageHandler(PP_Instance instance,
90 void* user_data,
91 const PPP_MessageHandler_0_1* handler,
92 PP_Resource message_loop) OVERRIDE;
93 virtual void UnregisterMessageHandler(PP_Instance instance) OVERRIDE;
94 virtual PP_Bool SetCursor(PP_Instance instance,
95 PP_MouseCursor_Type type,
96 PP_Resource image,
97 const PP_Point* hot_spot) OVERRIDE;
98 virtual int32_t LockMouse(PP_Instance instance,
99 scoped_refptr<TrackedCallback> callback) OVERRIDE;
100 virtual void UnlockMouse(PP_Instance instance) OVERRIDE;
101 virtual void SetTextInputType(PP_Instance instance,
102 PP_TextInput_Type type) OVERRIDE;
103 virtual void UpdateCaretPosition(PP_Instance instance,
104 const PP_Rect& caret,
105 const PP_Rect& bounding_box) OVERRIDE;
106 virtual void CancelCompositionText(PP_Instance instance) OVERRIDE;
107 virtual void SelectionChanged(PP_Instance instance) OVERRIDE;
108 virtual void UpdateSurroundingText(PP_Instance instance,
109 const char* text,
110 uint32_t caret,
111 uint32_t anchor) OVERRIDE;
112 virtual PP_Var GetDocumentURL(PP_Instance instance,
113 PP_URLComponents_Dev* components) OVERRIDE;
114 #if !defined(OS_NACL)
115 virtual PP_Var ResolveRelativeToDocument(
116 PP_Instance instance,
117 PP_Var relative,
118 PP_URLComponents_Dev* components) OVERRIDE;
119 virtual PP_Bool DocumentCanRequest(PP_Instance instance, PP_Var url) OVERRIDE;
120 virtual PP_Bool DocumentCanAccessDocument(PP_Instance instance,
121 PP_Instance target) OVERRIDE;
122 virtual PP_Var GetPluginInstanceURL(
123 PP_Instance instance,
124 PP_URLComponents_Dev* components) OVERRIDE;
125 virtual PP_Var GetPluginReferrerURL(
126 PP_Instance instance,
127 PP_URLComponents_Dev* components) OVERRIDE;
128 virtual void PromiseResolved(PP_Instance instance,
129 uint32 promise_id) OVERRIDE;
130 virtual void PromiseResolvedWithSession(PP_Instance instance,
131 uint32 promise_id,
132 PP_Var web_session_id_var) OVERRIDE;
133 virtual void PromiseRejected(PP_Instance instance,
134 uint32 promise_id,
135 PP_CdmExceptionCode exception_code,
136 uint32 system_code,
137 PP_Var error_description_var) OVERRIDE;
138 virtual void SessionMessage(PP_Instance instance,
139 PP_Var web_session_id_var,
140 PP_Var message_var,
141 PP_Var destination_url_var) OVERRIDE;
142 virtual void SessionReady(PP_Instance instance,
143 PP_Var web_session_id_var) OVERRIDE;
144 virtual void SessionClosed(PP_Instance instance,
145 PP_Var web_session_id_var) OVERRIDE;
146 virtual void SessionError(PP_Instance instance,
147 PP_Var web_session_id_var,
148 PP_CdmExceptionCode exception_code,
149 uint32 system_code,
150 PP_Var error_description_var) OVERRIDE;
151 virtual void DeliverBlock(PP_Instance instance,
152 PP_Resource decrypted_block,
153 const PP_DecryptedBlockInfo* block_info) OVERRIDE;
154 virtual void DecoderInitializeDone(PP_Instance instance,
155 PP_DecryptorStreamType decoder_type,
156 uint32_t request_id,
157 PP_Bool success) OVERRIDE;
158 virtual void DecoderDeinitializeDone(PP_Instance instance,
159 PP_DecryptorStreamType decoder_type,
160 uint32_t request_id) OVERRIDE;
161 virtual void DecoderResetDone(PP_Instance instance,
162 PP_DecryptorStreamType decoder_type,
163 uint32_t request_id) OVERRIDE;
164 virtual void DeliverFrame(PP_Instance instance,
165 PP_Resource decrypted_frame,
166 const PP_DecryptedFrameInfo* frame_info) OVERRIDE;
167 virtual void DeliverSamples(
168 PP_Instance instance,
169 PP_Resource audio_frames,
170 const PP_DecryptedSampleInfo* sample_info) OVERRIDE;
171 #endif // !defined(OS_NACL)
173 static const ApiID kApiID = API_ID_PPB_INSTANCE;
175 private:
176 // Plugin -> Host message handlers.
177 void OnHostMsgGetWindowObject(PP_Instance instance,
178 SerializedVarReturnValue result);
179 void OnHostMsgGetOwnerElementObject(PP_Instance instance,
180 SerializedVarReturnValue result);
181 void OnHostMsgBindGraphics(PP_Instance instance,
182 PP_Resource device);
183 void OnHostMsgIsFullFrame(PP_Instance instance, PP_Bool* result);
184 void OnHostMsgExecuteScript(PP_Instance instance,
185 SerializedVarReceiveInput script,
186 SerializedVarOutParam out_exception,
187 SerializedVarReturnValue result);
188 void OnHostMsgGetAudioHardwareOutputSampleRate(PP_Instance instance,
189 uint32_t *result);
190 void OnHostMsgGetAudioHardwareOutputBufferSize(PP_Instance instance,
191 uint32_t *result);
192 void OnHostMsgGetDefaultCharSet(PP_Instance instance,
193 SerializedVarReturnValue result);
194 void OnHostMsgSetPluginToHandleFindRequests(PP_Instance instance);
195 void OnHostMsgNumberOfFindResultsChanged(PP_Instance instance,
196 int32_t total,
197 PP_Bool final_result);
198 void OnHostMsgSelectFindResultChanged(PP_Instance instance,
199 int32_t index);
200 void OnHostMsgSetTickmarks(PP_Instance instance,
201 const std::vector<PP_Rect>& tickmarks);
202 void OnHostMsgSetFullscreen(PP_Instance instance,
203 PP_Bool fullscreen,
204 PP_Bool* result);
205 void OnHostMsgGetScreenSize(PP_Instance instance,
206 PP_Bool* result,
207 PP_Size* size);
208 void OnHostMsgRequestInputEvents(PP_Instance instance,
209 bool is_filtering,
210 uint32_t event_classes);
211 void OnHostMsgStartTrackingLatency(PP_Instance instance);
212 void OnHostMsgClearInputEvents(PP_Instance instance,
213 uint32_t event_classes);
214 void OnHostMsgPostMessage(PP_Instance instance,
215 SerializedVarReceiveInput message);
216 void OnHostMsgLockMouse(PP_Instance instance);
217 void OnHostMsgUnlockMouse(PP_Instance instance);
218 void OnHostMsgSetCursor(PP_Instance instance,
219 int32_t type,
220 const ppapi::HostResource& custom_image,
221 const PP_Point& hot_spot);
222 void OnHostMsgSetTextInputType(PP_Instance instance, PP_TextInput_Type type);
223 void OnHostMsgUpdateCaretPosition(PP_Instance instance,
224 const PP_Rect& caret,
225 const PP_Rect& bounding_box);
226 void OnHostMsgCancelCompositionText(PP_Instance instance);
227 void OnHostMsgUpdateSurroundingText(
228 PP_Instance instance,
229 const std::string& text,
230 uint32_t caret,
231 uint32_t anchor);
232 void OnHostMsgGetDocumentURL(PP_Instance instance,
233 PP_URLComponents_Dev* components,
234 SerializedVarReturnValue result);
236 #if !defined(OS_NACL)
237 void OnHostMsgResolveRelativeToDocument(PP_Instance instance,
238 SerializedVarReceiveInput relative,
239 SerializedVarReturnValue result);
240 void OnHostMsgDocumentCanRequest(PP_Instance instance,
241 SerializedVarReceiveInput url,
242 PP_Bool* result);
243 void OnHostMsgDocumentCanAccessDocument(PP_Instance active,
244 PP_Instance target,
245 PP_Bool* result);
246 void OnHostMsgGetPluginInstanceURL(PP_Instance instance,
247 SerializedVarReturnValue result);
248 void OnHostMsgGetPluginReferrerURL(PP_Instance instance,
249 SerializedVarReturnValue result);
251 virtual void OnHostMsgPromiseResolved(PP_Instance instance,
252 uint32_t promise_id);
253 virtual void OnHostMsgPromiseResolvedWithSession(
254 PP_Instance instance,
255 uint32_t promise_id,
256 SerializedVarReceiveInput web_session_id);
257 virtual void OnHostMsgPromiseRejected(
258 PP_Instance instance,
259 uint32_t promise_id,
260 PP_CdmExceptionCode exception_code,
261 uint32_t system_code,
262 SerializedVarReceiveInput error_description);
263 virtual void OnHostMsgSessionMessage(
264 PP_Instance instance,
265 SerializedVarReceiveInput web_session_id,
266 SerializedVarReceiveInput message,
267 SerializedVarReceiveInput destination_url);
268 virtual void OnHostMsgSessionReady(PP_Instance instance,
269 SerializedVarReceiveInput web_session_id);
270 virtual void OnHostMsgSessionClosed(PP_Instance instance,
271 SerializedVarReceiveInput web_session_id);
272 virtual void OnHostMsgSessionError(
273 PP_Instance instance,
274 SerializedVarReceiveInput web_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,
281 uint32_t request_id,
282 PP_Bool success);
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);
307 // Other helpers.
308 void CancelAnyPendingRequestSurroundingText(PP_Instance instance);
310 ProxyCompletionCallbackFactory<PPB_Instance_Proxy> callback_factory_;
313 } // namespace proxy
314 } // namespace ppapi
316 #endif // PPAPI_PROXY_PPB_INSTANCE_PROXY_H_