Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / ppapi / proxy / ppb_instance_proxy.h
blob8d8c2b5b7c5e0606eaa8f2f7353c9ea92806157d
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 PostMessage(PP_Instance instance, PP_Var message) override;
80 int32_t RegisterMessageHandler(PP_Instance instance,
81 void* user_data,
82 const PPP_MessageHandler_0_2* handler,
83 PP_Resource message_loop) override;
84 void UnregisterMessageHandler(PP_Instance instance) override;
85 PP_Bool SetCursor(PP_Instance instance,
86 PP_MouseCursor_Type type,
87 PP_Resource image,
88 const PP_Point* hot_spot) override;
89 int32_t LockMouse(PP_Instance instance,
90 scoped_refptr<TrackedCallback> callback) override;
91 void UnlockMouse(PP_Instance instance) override;
92 void SetTextInputType(PP_Instance instance, PP_TextInput_Type type) override;
93 void UpdateCaretPosition(PP_Instance instance,
94 const PP_Rect& caret,
95 const PP_Rect& bounding_box) override;
96 void CancelCompositionText(PP_Instance instance) override;
97 void SelectionChanged(PP_Instance instance) override;
98 void UpdateSurroundingText(PP_Instance instance,
99 const char* text,
100 uint32_t caret,
101 uint32_t anchor) override;
102 PP_Var GetDocumentURL(PP_Instance instance,
103 PP_URLComponents_Dev* components) override;
104 #if !defined(OS_NACL)
105 PP_Var ResolveRelativeToDocument(PP_Instance instance,
106 PP_Var relative,
107 PP_URLComponents_Dev* components) override;
108 PP_Bool DocumentCanRequest(PP_Instance instance, PP_Var url) override;
109 PP_Bool DocumentCanAccessDocument(PP_Instance instance,
110 PP_Instance target) override;
111 PP_Var GetPluginInstanceURL(PP_Instance instance,
112 PP_URLComponents_Dev* components) override;
113 PP_Var GetPluginReferrerURL(PP_Instance instance,
114 PP_URLComponents_Dev* components) override;
115 void PromiseResolved(PP_Instance instance, uint32 promise_id) override;
116 void PromiseResolvedWithSession(PP_Instance instance,
117 uint32 promise_id,
118 PP_Var session_id_var) override;
119 void PromiseRejected(PP_Instance instance,
120 uint32 promise_id,
121 PP_CdmExceptionCode exception_code,
122 uint32 system_code,
123 PP_Var error_description_var) override;
124 void SessionMessage(PP_Instance instance,
125 PP_Var session_id_var,
126 PP_CdmMessageType message_type,
127 PP_Var message_var,
128 PP_Var legacy_destination_url_var) override;
129 void SessionKeysChange(
130 PP_Instance instance,
131 PP_Var session_id_var,
132 PP_Bool has_additional_usable_key,
133 uint32_t key_count,
134 const struct PP_KeyInformation key_information[]) override;
135 void SessionExpirationChange(PP_Instance instance,
136 PP_Var session_id_var,
137 PP_Time new_expiry_time) override;
138 void SessionClosed(PP_Instance instance, PP_Var session_id_var) override;
139 void LegacySessionError(PP_Instance instance,
140 PP_Var session_id_var,
141 PP_CdmExceptionCode exception_code,
142 uint32 system_code,
143 PP_Var error_description_var) override;
144 void DeliverBlock(PP_Instance instance,
145 PP_Resource decrypted_block,
146 const PP_DecryptedBlockInfo* block_info) override;
147 void DecoderInitializeDone(PP_Instance instance,
148 PP_DecryptorStreamType decoder_type,
149 uint32_t request_id,
150 PP_Bool success) override;
151 void DecoderDeinitializeDone(PP_Instance instance,
152 PP_DecryptorStreamType decoder_type,
153 uint32_t request_id) override;
154 void DecoderResetDone(PP_Instance instance,
155 PP_DecryptorStreamType decoder_type,
156 uint32_t request_id) override;
157 void DeliverFrame(PP_Instance instance,
158 PP_Resource decrypted_frame,
159 const PP_DecryptedFrameInfo* frame_info) override;
160 void DeliverSamples(PP_Instance instance,
161 PP_Resource audio_frames,
162 const PP_DecryptedSampleInfo* sample_info) override;
163 #endif // !defined(OS_NACL)
165 static const ApiID kApiID = API_ID_PPB_INSTANCE;
167 private:
168 // Plugin -> Host message handlers.
169 void OnHostMsgGetWindowObject(PP_Instance instance,
170 SerializedVarReturnValue result);
171 void OnHostMsgGetOwnerElementObject(PP_Instance instance,
172 SerializedVarReturnValue result);
173 void OnHostMsgBindGraphics(PP_Instance instance,
174 PP_Resource device);
175 void OnHostMsgIsFullFrame(PP_Instance instance, PP_Bool* result);
176 void OnHostMsgExecuteScript(PP_Instance instance,
177 SerializedVarReceiveInput script,
178 SerializedVarOutParam out_exception,
179 SerializedVarReturnValue result);
180 void OnHostMsgGetAudioHardwareOutputSampleRate(PP_Instance instance,
181 uint32_t *result);
182 void OnHostMsgGetAudioHardwareOutputBufferSize(PP_Instance instance,
183 uint32_t *result);
184 void OnHostMsgGetDefaultCharSet(PP_Instance instance,
185 SerializedVarReturnValue result);
186 void OnHostMsgSetPluginToHandleFindRequests(PP_Instance instance);
187 void OnHostMsgNumberOfFindResultsChanged(PP_Instance instance,
188 int32_t total,
189 PP_Bool final_result);
190 void OnHostMsgSelectFindResultChanged(PP_Instance instance,
191 int32_t index);
192 void OnHostMsgSetTickmarks(PP_Instance instance,
193 const std::vector<PP_Rect>& tickmarks);
194 void OnHostMsgSetFullscreen(PP_Instance instance,
195 PP_Bool fullscreen,
196 PP_Bool* result);
197 void OnHostMsgGetScreenSize(PP_Instance instance,
198 PP_Bool* result,
199 PP_Size* size);
200 void OnHostMsgRequestInputEvents(PP_Instance instance,
201 bool is_filtering,
202 uint32_t event_classes);
203 void OnHostMsgStartTrackingLatency(PP_Instance instance);
204 void OnHostMsgClearInputEvents(PP_Instance instance,
205 uint32_t event_classes);
206 void OnHostMsgPostMessage(PP_Instance instance,
207 SerializedVarReceiveInput message);
208 void OnHostMsgLockMouse(PP_Instance instance);
209 void OnHostMsgUnlockMouse(PP_Instance instance);
210 void OnHostMsgSetCursor(PP_Instance instance,
211 int32_t type,
212 const ppapi::HostResource& custom_image,
213 const PP_Point& hot_spot);
214 void OnHostMsgSetTextInputType(PP_Instance instance, PP_TextInput_Type type);
215 void OnHostMsgUpdateCaretPosition(PP_Instance instance,
216 const PP_Rect& caret,
217 const PP_Rect& bounding_box);
218 void OnHostMsgCancelCompositionText(PP_Instance instance);
219 void OnHostMsgUpdateSurroundingText(
220 PP_Instance instance,
221 const std::string& text,
222 uint32_t caret,
223 uint32_t anchor);
224 void OnHostMsgGetDocumentURL(PP_Instance instance,
225 PP_URLComponents_Dev* components,
226 SerializedVarReturnValue result);
228 #if !defined(OS_NACL)
229 void OnHostMsgResolveRelativeToDocument(PP_Instance instance,
230 SerializedVarReceiveInput relative,
231 SerializedVarReturnValue result);
232 void OnHostMsgDocumentCanRequest(PP_Instance instance,
233 SerializedVarReceiveInput url,
234 PP_Bool* result);
235 void OnHostMsgDocumentCanAccessDocument(PP_Instance active,
236 PP_Instance target,
237 PP_Bool* result);
238 void OnHostMsgGetPluginInstanceURL(PP_Instance instance,
239 SerializedVarReturnValue result);
240 void OnHostMsgGetPluginReferrerURL(PP_Instance instance,
241 SerializedVarReturnValue result);
243 virtual void OnHostMsgPromiseResolved(PP_Instance instance,
244 uint32_t promise_id);
245 virtual void OnHostMsgPromiseResolvedWithSession(
246 PP_Instance instance,
247 uint32_t promise_id,
248 SerializedVarReceiveInput session_id);
249 virtual void OnHostMsgPromiseRejected(
250 PP_Instance instance,
251 uint32_t promise_id,
252 PP_CdmExceptionCode exception_code,
253 uint32_t system_code,
254 SerializedVarReceiveInput error_description);
255 virtual void OnHostMsgSessionMessage(
256 PP_Instance instance,
257 SerializedVarReceiveInput session_id,
258 PP_CdmMessageType message_type,
259 SerializedVarReceiveInput message,
260 SerializedVarReceiveInput legacy_destination_url);
261 virtual void OnHostMsgSessionKeysChange(
262 PP_Instance instance,
263 const std::string& session_id,
264 PP_Bool has_additional_usable_key,
265 const std::vector<PP_KeyInformation>& key_information);
266 virtual void OnHostMsgSessionExpirationChange(
267 PP_Instance instance,
268 const std::string& session_id,
269 PP_Time new_expiry_time);
270 virtual void OnHostMsgSessionClosed(PP_Instance instance,
271 SerializedVarReceiveInput session_id);
272 virtual void OnHostMsgLegacySessionError(
273 PP_Instance instance,
274 SerializedVarReceiveInput 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_