blob: 1585f756d39264fdabc448bf2969822f3ebb92a6 [file] [log] [blame]
[email protected]0a424af2012-01-10 19:24:281// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]4c2e9352010-11-05 22:13:022// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef PPAPI_PROXY_PPB_INSTANCE_PROXY_H_
6#define PPAPI_PROXY_PPB_INSTANCE_PROXY_H_
7
8#include "ppapi/c/pp_instance.h"
9#include "ppapi/c/pp_resource.h"
[email protected]3b98ced72012-03-09 02:08:3310#include "ppapi/c/pp_time.h"
[email protected]4c2e9352010-11-05 22:13:0211#include "ppapi/c/pp_var.h"
12#include "ppapi/proxy/interface_proxy.h"
[email protected]47a961c2012-07-13 19:18:5213#include "ppapi/proxy/proxy_completion_callback_factory.h"
[email protected]be0a84b2011-08-13 04:18:4414#include "ppapi/shared_impl/host_resource.h"
[email protected]9a578392011-12-07 18:59:2715#include "ppapi/shared_impl/ppb_instance_shared.h"
[email protected]ceadc392011-06-15 23:04:2416#include "ppapi/thunk/ppb_instance_api.h"
[email protected]ae5ff9ae2012-01-06 22:50:3317#include "ppapi/utility/completion_callback_factory.h"
[email protected]4c2e9352010-11-05 22:13:0218
[email protected]0f41c012011-10-21 19:49:2019// Windows headers interfere with this file.
20#ifdef PostMessage
21#undef PostMessage
22#endif
23
[email protected]4d2efd22011-08-18 21:58:0224namespace ppapi {
[email protected]4c2e9352010-11-05 22:13:0225namespace proxy {
26
27class SerializedVarReceiveInput;
28class SerializedVarOutParam;
29class SerializedVarReturnValue;
30
[email protected]ceadc392011-06-15 23:04:2431class PPB_Instance_Proxy : public InterfaceProxy,
[email protected]a9b16dd2012-01-31 05:00:2632 public PPB_Instance_Shared {
[email protected]4c2e9352010-11-05 22:13:0233 public:
[email protected]5c966022011-09-13 18:09:3734 PPB_Instance_Proxy(Dispatcher* dispatcher);
[email protected]4c2e9352010-11-05 22:13:0235 virtual ~PPB_Instance_Proxy();
36
[email protected]ceadc392011-06-15 23:04:2437 static const Info* GetInfoPrivate();
[email protected]4c2e9352010-11-05 22:13:0238
39 // InterfaceProxy implementation.
[email protected]a95986a82010-12-24 06:19:2840 virtual bool OnMessageReceived(const IPC::Message& msg);
[email protected]4c2e9352010-11-05 22:13:0241
[email protected]4f2006122012-04-30 05:13:1742 // PPB_Instance_API implementation.
[email protected]ceadc392011-06-15 23:04:2443 virtual PP_Bool BindGraphics(PP_Instance instance,
44 PP_Resource device) OVERRIDE;
45 virtual PP_Bool IsFullFrame(PP_Instance instance) OVERRIDE;
[email protected]e8f07ac2012-01-03 17:43:3646 virtual const ViewData* GetViewData(PP_Instance instance) OVERRIDE;
[email protected]ceadc392011-06-15 23:04:2447 virtual PP_Var GetWindowObject(PP_Instance instance) OVERRIDE;
48 virtual PP_Var GetOwnerElementObject(PP_Instance instance) OVERRIDE;
49 virtual PP_Var ExecuteScript(PP_Instance instance,
50 PP_Var script,
51 PP_Var* exception) OVERRIDE;
[email protected]c59ed5892012-02-18 01:10:1952 virtual uint32_t GetAudioHardwareOutputSampleRate(PP_Instance instance)
53 OVERRIDE;
54 virtual uint32_t GetAudioHardwareOutputBufferSize(PP_Instance instance)
55 OVERRIDE;
[email protected]8d770e492011-10-11 04:54:3156 virtual PP_Var GetDefaultCharSet(PP_Instance instance) OVERRIDE;
[email protected]59cf7022011-09-14 22:44:1957 virtual void NumberOfFindResultsChanged(PP_Instance instance,
58 int32_t total,
59 PP_Bool final_result) OVERRIDE;
60 virtual void SelectedFindResultChanged(PP_Instance instance,
61 int32_t index) OVERRIDE;
[email protected]7a26d92e2012-02-17 20:15:2562 virtual PP_Var GetFontFamilies(PP_Instance instance) OVERRIDE;
[email protected]06e0a342011-09-27 04:24:3063 virtual PP_Bool SetFullscreen(PP_Instance instance,
[email protected]3b98ced72012-03-09 02:08:3364 PP_Bool fullscreen) OVERRIDE;
[email protected]06e0a342011-09-27 04:24:3065 virtual PP_Bool GetScreenSize(PP_Instance instance,
[email protected]a085aed72012-04-24 05:32:0466 PP_Size* size) OVERRIDE;
67 virtual thunk::PPB_Flash_API* GetFlashAPI() OVERRIDE;
[email protected]957c93a2012-03-01 06:44:5168 virtual void SampleGamepads(PP_Instance instance,
[email protected]d5cc7192012-03-07 16:53:1669 PP_GamepadsSampleData* data) OVERRIDE;
[email protected]493d14212011-07-07 15:38:4870 virtual int32_t RequestInputEvents(PP_Instance instance,
71 uint32_t event_classes) OVERRIDE;
72 virtual int32_t RequestFilteringInputEvents(PP_Instance instance,
73 uint32_t event_classes) OVERRIDE;
74 virtual void ClearInputEventRequest(PP_Instance instance,
75 uint32_t event_classes) OVERRIDE;
[email protected]3b98ced72012-03-09 02:08:3376 virtual void ClosePendingUserGesture(PP_Instance instance,
77 PP_TimeTicks timestamp) OVERRIDE;
[email protected]55a5a522011-07-06 22:52:4078 virtual void ZoomChanged(PP_Instance instance, double factor) OVERRIDE;
79 virtual void ZoomLimitsChanged(PP_Instance instance,
80 double minimum_factor,
81 double maximium_factor) OVERRIDE;
[email protected]c962f862012-04-12 00:02:0482 virtual void PostMessage(PP_Instance instance, PP_Var message) OVERRIDE;
83 virtual PP_Bool SetCursor(PP_Instance instance,
84 PP_MouseCursor_Type type,
85 PP_Resource image,
86 const PP_Point* hot_spot) OVERRIDE;
87 virtual int32_t LockMouse(PP_Instance instance,
[email protected]aed96532012-06-23 14:27:4288 scoped_refptr<TrackedCallback> callback) OVERRIDE;
[email protected]c962f862012-04-12 00:02:0489 virtual void UnlockMouse(PP_Instance instance) OVERRIDE;
[email protected]772a74622012-06-14 21:15:5090 virtual PP_Bool GetDefaultPrintSettings(
91 PP_Instance instance,
92 PP_PrintSettings_Dev* print_settings) OVERRIDE;
[email protected]4c44183a2012-04-27 16:52:2393 virtual void SetTextInputType(PP_Instance instance,
94 PP_TextInput_Type type) OVERRIDE;
95 virtual void UpdateCaretPosition(PP_Instance instance,
96 const PP_Rect& caret,
97 const PP_Rect& bounding_box) OVERRIDE;
98 virtual void CancelCompositionText(PP_Instance instance) OVERRIDE;
99 virtual void SelectionChanged(PP_Instance instance) OVERRIDE;
100 virtual void UpdateSurroundingText(PP_Instance instance,
101 const char* text,
102 uint32_t caret,
103 uint32_t anchor) OVERRIDE;
[email protected]c962f862012-04-12 00:02:04104
105#if !defined(OS_NACL)
[email protected]03460232011-10-10 17:23:57106 virtual PP_Var ResolveRelativeToDocument(
107 PP_Instance instance,
108 PP_Var relative,
109 PP_URLComponents_Dev* components) OVERRIDE;
110 virtual PP_Bool DocumentCanRequest(PP_Instance instance, PP_Var url) OVERRIDE;
111 virtual PP_Bool DocumentCanAccessDocument(PP_Instance instance,
112 PP_Instance target) OVERRIDE;
113 virtual PP_Var GetDocumentURL(PP_Instance instance,
114 PP_URLComponents_Dev* components) OVERRIDE;
115 virtual PP_Var GetPluginInstanceURL(
116 PP_Instance instance,
117 PP_URLComponents_Dev* components) OVERRIDE;
[email protected]e5aeef02012-08-17 00:18:43118 virtual void NeedKey(PP_Instance instance,
119 PP_Var key_system,
120 PP_Var session_id,
121 PP_Var init_data) OVERRIDE;
122 virtual void KeyAdded(PP_Instance instance,
123 PP_Var key_system,
124 PP_Var session_id) OVERRIDE;
125 virtual void KeyMessage(PP_Instance instance,
126 PP_Var key_system,
127 PP_Var session_id,
128 PP_Resource message,
129 PP_Var default_url) OVERRIDE;
130 virtual void KeyError(PP_Instance instance,
131 PP_Var key_system,
132 PP_Var session_id,
133 int32_t media_error,
134 int32_t system_code) OVERRIDE;
135 virtual void DeliverBlock(PP_Instance instance,
136 PP_Resource decrypted_block,
137 int32_t request_id) OVERRIDE;
138 virtual void DeliverFrame(PP_Instance instance,
139 PP_Resource decrypted_frame,
140 int32_t request_id) OVERRIDE;
141 virtual void DeliverSamples(PP_Instance instance,
142 PP_Resource decrypted_samples,
143 int32_t request_id) OVERRIDE;
[email protected]c962f862012-04-12 00:02:04144#endif // !defined(OS_NACL)
[email protected]ceadc392011-06-15 23:04:24145
[email protected]ac4b54d2011-10-20 23:09:28146 static const ApiID kApiID = API_ID_PPB_INSTANCE;
[email protected]5c966022011-09-13 18:09:37147
[email protected]4c2e9352010-11-05 22:13:02148 private:
[email protected]0f41c012011-10-21 19:49:20149 // Plugin -> Host message handlers.
[email protected]e8f07ac2012-01-03 17:43:36150 void OnHostMsgGetWindowObject(PP_Instance instance,
151 SerializedVarReturnValue result);
152 void OnHostMsgGetOwnerElementObject(PP_Instance instance,
[email protected]03460232011-10-10 17:23:57153 SerializedVarReturnValue result);
[email protected]e8f07ac2012-01-03 17:43:36154 void OnHostMsgBindGraphics(PP_Instance instance,
155 const ppapi::HostResource& device,
156 PP_Bool* result);
157 void OnHostMsgIsFullFrame(PP_Instance instance, PP_Bool* result);
158 void OnHostMsgExecuteScript(PP_Instance instance,
159 SerializedVarReceiveInput script,
160 SerializedVarOutParam out_exception,
161 SerializedVarReturnValue result);
[email protected]c59ed5892012-02-18 01:10:19162 void OnHostMsgGetAudioHardwareOutputSampleRate(PP_Instance instance,
163 uint32_t *result);
164 void OnHostMsgGetAudioHardwareOutputBufferSize(PP_Instance instance,
165 uint32_t *result);
[email protected]e8f07ac2012-01-03 17:43:36166 void OnHostMsgGetDefaultCharSet(PP_Instance instance,
167 SerializedVarReturnValue result);
[email protected]e8f07ac2012-01-03 17:43:36168 void OnHostMsgSetFullscreen(PP_Instance instance,
169 PP_Bool fullscreen,
170 PP_Bool* result);
171 void OnHostMsgGetScreenSize(PP_Instance instance,
172 PP_Bool* result,
173 PP_Size* size);
[email protected]e8f07ac2012-01-03 17:43:36174 void OnHostMsgRequestInputEvents(PP_Instance instance,
175 bool is_filtering,
176 uint32_t event_classes);
177 void OnHostMsgClearInputEvents(PP_Instance instance,
178 uint32_t event_classes);
[email protected]3b98ced72012-03-09 02:08:33179 void OnMsgHandleInputEventAck(PP_Instance instance,
180 PP_TimeTicks timestamp);
[email protected]e8f07ac2012-01-03 17:43:36181 void OnHostMsgPostMessage(PP_Instance instance,
182 SerializedVarReceiveInput message);
183 void OnHostMsgLockMouse(PP_Instance instance);
184 void OnHostMsgUnlockMouse(PP_Instance instance);
[email protected]4d80a3db2012-06-21 17:58:24185 void OnHostMsgGetDefaultPrintSettings(PP_Instance instance,
186 PP_PrintSettings_Dev* settings,
187 bool* result);
[email protected]c962f862012-04-12 00:02:04188 void OnHostMsgSetCursor(PP_Instance instance,
189 int32_t type,
190 const ppapi::HostResource& custom_image,
191 const PP_Point& hot_spot);
[email protected]4c44183a2012-04-27 16:52:23192 void OnHostMsgSetTextInputType(PP_Instance instance, PP_TextInput_Type type);
193 void OnHostMsgUpdateCaretPosition(PP_Instance instance,
194 const PP_Rect& caret,
195 const PP_Rect& bounding_box);
196 void OnHostMsgCancelCompositionText(PP_Instance instance);
197 void OnHostMsgUpdateSurroundingText(
198 PP_Instance instance,
199 const std::string& text,
200 uint32_t caret,
201 uint32_t anchor);
[email protected]e5aeef02012-08-17 00:18:43202
[email protected]c962f862012-04-12 00:02:04203#if !defined(OS_NACL)
[email protected]e8f07ac2012-01-03 17:43:36204 void OnHostMsgResolveRelativeToDocument(PP_Instance instance,
205 SerializedVarReceiveInput relative,
206 SerializedVarReturnValue result);
207 void OnHostMsgDocumentCanRequest(PP_Instance instance,
208 SerializedVarReceiveInput url,
209 PP_Bool* result);
210 void OnHostMsgDocumentCanAccessDocument(PP_Instance active,
211 PP_Instance target,
212 PP_Bool* result);
213 void OnHostMsgGetDocumentURL(PP_Instance instance,
214 SerializedVarReturnValue result);
215 void OnHostMsgGetPluginInstanceURL(PP_Instance instance,
216 SerializedVarReturnValue result);
[email protected]e5aeef02012-08-17 00:18:43217 virtual void OnHostMsgNeedKey(PP_Instance instance,
218 SerializedVarReceiveInput key_system,
219 SerializedVarReceiveInput session_id,
220 SerializedVarReceiveInput init_data);
221 virtual void OnHostMsgKeyAdded(PP_Instance instance,
222 SerializedVarReceiveInput key_system,
223 SerializedVarReceiveInput session_id);
224 virtual void OnHostMsgKeyMessage(PP_Instance instance,
225 SerializedVarReceiveInput key_system,
226 SerializedVarReceiveInput session_id,
227 PP_Resource message,
228 SerializedVarReceiveInput default_url);
229 virtual void OnHostMsgKeyError(PP_Instance instance,
230 SerializedVarReceiveInput key_system,
231 SerializedVarReceiveInput session_id,
232 int32_t media_error,
233 int32_t system_code);
234 virtual void OnHostMsgDeliverBlock(PP_Instance instance,
235 PP_Resource decrypted_block,
236 int32_t request_id);
237 virtual void OnHostMsgDeliverFrame(PP_Instance instance,
238 PP_Resource decrypted_frame,
239 int32_t request_id);
240 virtual void OnHostMsgDeliverSamples(PP_Instance instance,
241 PP_Resource decrypted_samples,
242 int32_t request_id);
[email protected]c962f862012-04-12 00:02:04243#endif // !defined(OS_NACL)
[email protected]0f41c012011-10-21 19:49:20244
245 // Host -> Plugin message handlers.
[email protected]e8f07ac2012-01-03 17:43:36246 void OnPluginMsgMouseLockComplete(PP_Instance instance, int32_t result);
[email protected]0f41c012011-10-21 19:49:20247
248 void MouseLockCompleteInHost(int32_t result, PP_Instance instance);
249
[email protected]a8e72142012-08-21 17:24:20250 // Other helpers.
251 void CancelAnyPendingRequestSurroundingText(PP_Instance instance);
252
[email protected]47a961c2012-07-13 19:18:52253 ProxyCompletionCallbackFactory<PPB_Instance_Proxy> callback_factory_;
[email protected]4c2e9352010-11-05 22:13:02254};
255
256} // namespace proxy
[email protected]4d2efd22011-08-18 21:58:02257} // namespace ppapi
[email protected]4c2e9352010-11-05 22:13:02258
259#endif // PPAPI_PROXY_PPB_INSTANCE_PROXY_H_