• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef PPAPI_PROXY_PPB_INSTANCE_PROXY_H_
6 #define PPAPI_PROXY_PPB_INSTANCE_PROXY_H_
7 
8 #include <string>
9 
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"
20 
21 // Windows headers interfere with this file.
22 #ifdef PostMessage
23 #undef PostMessage
24 #endif
25 
26 struct PP_DecryptedBlockInfo;
27 struct PP_DecryptedFrameInfo;
28 
29 namespace ppapi {
30 namespace proxy {
31 
32 class SerializedVarReceiveInput;
33 class SerializedVarOutParam;
34 class SerializedVarReturnValue;
35 
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();
41 
42   static const Info* GetInfoPrivate();
43 
44   // InterfaceProxy implementation.
45   virtual bool OnMessageReceived(const IPC::Message& msg);
46 
47   // PPB_Instance_API implementation.
48   virtual PP_Bool BindGraphics(PP_Instance instance,
49                                PP_Resource device) OVERRIDE;
50   virtual PP_Bool IsFullFrame(PP_Instance instance) OVERRIDE;
51   virtual const ViewData* GetViewData(PP_Instance instance) OVERRIDE;
52   virtual PP_Bool FlashIsFullscreen(PP_Instance instance) OVERRIDE;
53   virtual PP_Var GetWindowObject(PP_Instance instance) OVERRIDE;
54   virtual PP_Var GetOwnerElementObject(PP_Instance instance) OVERRIDE;
55   virtual PP_Var ExecuteScript(PP_Instance instance,
56                                PP_Var script,
57                                PP_Var* exception) OVERRIDE;
58   virtual uint32_t GetAudioHardwareOutputSampleRate(PP_Instance instance)
59       OVERRIDE;
60   virtual uint32_t GetAudioHardwareOutputBufferSize(PP_Instance instance)
61       OVERRIDE;
62   virtual PP_Var GetDefaultCharSet(PP_Instance instance) OVERRIDE;
63   virtual void NumberOfFindResultsChanged(PP_Instance instance,
64                                           int32_t total,
65                                           PP_Bool final_result) OVERRIDE;
66   virtual void SelectedFindResultChanged(PP_Instance instance,
67                                          int32_t index) OVERRIDE;
68   virtual PP_Bool IsFullscreen(PP_Instance instance) OVERRIDE;
69   virtual PP_Bool SetFullscreen(PP_Instance instance,
70                                 PP_Bool fullscreen) OVERRIDE;
71   virtual PP_Bool GetScreenSize(PP_Instance instance,
72                                 PP_Size* size) OVERRIDE;
73   virtual Resource* GetSingletonResource(PP_Instance instance,
74                                          SingletonResourceID id) OVERRIDE;
75   virtual int32_t RequestInputEvents(PP_Instance instance,
76                                      uint32_t event_classes) OVERRIDE;
77   virtual int32_t RequestFilteringInputEvents(PP_Instance instance,
78                                               uint32_t event_classes) OVERRIDE;
79   virtual void ClearInputEventRequest(PP_Instance instance,
80                                       uint32_t event_classes) OVERRIDE;
81   virtual void ZoomChanged(PP_Instance instance, double factor) OVERRIDE;
82   virtual void ZoomLimitsChanged(PP_Instance instance,
83                                  double minimum_factor,
84                                  double maximium_factor) OVERRIDE;
85   virtual void PostMessage(PP_Instance instance, PP_Var message) OVERRIDE;
86   virtual PP_Bool SetCursor(PP_Instance instance,
87                             PP_MouseCursor_Type type,
88                             PP_Resource image,
89                             const PP_Point* hot_spot) OVERRIDE;
90   virtual int32_t LockMouse(PP_Instance instance,
91                             scoped_refptr<TrackedCallback> callback) OVERRIDE;
92   virtual void UnlockMouse(PP_Instance instance) OVERRIDE;
93   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;
104   virtual PP_Var GetDocumentURL(PP_Instance instance,
105                                 PP_URLComponents_Dev* components) OVERRIDE;
106 #if !defined(OS_NACL)
107   virtual PP_Var ResolveRelativeToDocument(
108       PP_Instance instance,
109       PP_Var relative,
110       PP_URLComponents_Dev* components) OVERRIDE;
111   virtual PP_Bool DocumentCanRequest(PP_Instance instance, PP_Var url) OVERRIDE;
112   virtual PP_Bool DocumentCanAccessDocument(PP_Instance instance,
113                                             PP_Instance target) OVERRIDE;
114   virtual PP_Var GetPluginInstanceURL(
115       PP_Instance instance,
116       PP_URLComponents_Dev* components) OVERRIDE;
117   virtual PP_Var GetPluginReferrerURL(
118       PP_Instance instance,
119       PP_URLComponents_Dev* components) OVERRIDE;
120   virtual void SessionCreated(PP_Instance instance,
121                               uint32_t session_id,
122                               PP_Var web_session_id) OVERRIDE;
123   virtual void SessionMessage(PP_Instance instance,
124                               uint32_t session_id,
125                               PP_Var message,
126                               PP_Var destination_url) OVERRIDE;
127   virtual void SessionReady(PP_Instance instance, uint32_t session_id) OVERRIDE;
128   virtual void SessionClosed(PP_Instance instance,
129                              uint32_t session_id) OVERRIDE;
130   virtual void SessionError(PP_Instance instance,
131                             uint32_t session_id,
132                             int32_t media_error,
133                             int32_t system_code) OVERRIDE;
134   virtual void DeliverBlock(PP_Instance instance,
135                             PP_Resource decrypted_block,
136                             const PP_DecryptedBlockInfo* block_info) OVERRIDE;
137   virtual void DecoderInitializeDone(PP_Instance instance,
138                                      PP_DecryptorStreamType decoder_type,
139                                      uint32_t request_id,
140                                      PP_Bool success) OVERRIDE;
141   virtual void DecoderDeinitializeDone(PP_Instance instance,
142                                        PP_DecryptorStreamType decoder_type,
143                                        uint32_t request_id) OVERRIDE;
144   virtual void DecoderResetDone(PP_Instance instance,
145                                 PP_DecryptorStreamType decoder_type,
146                                 uint32_t request_id) OVERRIDE;
147   virtual void DeliverFrame(PP_Instance instance,
148                             PP_Resource decrypted_frame,
149                             const PP_DecryptedFrameInfo* frame_info) OVERRIDE;
150   virtual void DeliverSamples(
151       PP_Instance instance,
152       PP_Resource audio_frames,
153       const PP_DecryptedSampleInfo* sample_info) OVERRIDE;
154 #endif  // !defined(OS_NACL)
155 
156   static const ApiID kApiID = API_ID_PPB_INSTANCE;
157 
158  private:
159   // Plugin -> Host message handlers.
160   void OnHostMsgGetWindowObject(PP_Instance instance,
161                                 SerializedVarReturnValue result);
162   void OnHostMsgGetOwnerElementObject(PP_Instance instance,
163                                       SerializedVarReturnValue result);
164   void OnHostMsgBindGraphics(PP_Instance instance,
165                              PP_Resource device);
166   void OnHostMsgIsFullFrame(PP_Instance instance, PP_Bool* result);
167   void OnHostMsgExecuteScript(PP_Instance instance,
168                               SerializedVarReceiveInput script,
169                               SerializedVarOutParam out_exception,
170                               SerializedVarReturnValue result);
171   void OnHostMsgGetAudioHardwareOutputSampleRate(PP_Instance instance,
172                                                  uint32_t *result);
173   void OnHostMsgGetAudioHardwareOutputBufferSize(PP_Instance instance,
174                                                  uint32_t *result);
175   void OnHostMsgGetDefaultCharSet(PP_Instance instance,
176                                   SerializedVarReturnValue result);
177   void OnHostMsgSetFullscreen(PP_Instance instance,
178                               PP_Bool fullscreen,
179                               PP_Bool* result);
180   void OnHostMsgGetScreenSize(PP_Instance instance,
181                               PP_Bool* result,
182                               PP_Size* size);
183   void OnHostMsgRequestInputEvents(PP_Instance instance,
184                                    bool is_filtering,
185                                    uint32_t event_classes);
186   void OnHostMsgClearInputEvents(PP_Instance instance,
187                                  uint32_t event_classes);
188   void OnHostMsgPostMessage(PP_Instance instance,
189                             SerializedVarReceiveInput message);
190   void OnHostMsgLockMouse(PP_Instance instance);
191   void OnHostMsgUnlockMouse(PP_Instance instance);
192   void OnHostMsgSetCursor(PP_Instance instance,
193                           int32_t type,
194                           const ppapi::HostResource& custom_image,
195                           const PP_Point& hot_spot);
196   void OnHostMsgSetTextInputType(PP_Instance instance, PP_TextInput_Type type);
197   void OnHostMsgUpdateCaretPosition(PP_Instance instance,
198                                     const PP_Rect& caret,
199                                     const PP_Rect& bounding_box);
200   void OnHostMsgCancelCompositionText(PP_Instance instance);
201   void OnHostMsgUpdateSurroundingText(
202       PP_Instance instance,
203       const std::string& text,
204       uint32_t caret,
205       uint32_t anchor);
206   void OnHostMsgGetDocumentURL(PP_Instance instance,
207                                PP_URLComponents_Dev* components,
208                                SerializedVarReturnValue result);
209 
210 #if !defined(OS_NACL)
211   void OnHostMsgResolveRelativeToDocument(PP_Instance instance,
212                                           SerializedVarReceiveInput relative,
213                                           SerializedVarReturnValue result);
214   void OnHostMsgDocumentCanRequest(PP_Instance instance,
215                                    SerializedVarReceiveInput url,
216                                    PP_Bool* result);
217   void OnHostMsgDocumentCanAccessDocument(PP_Instance active,
218                                           PP_Instance target,
219                                           PP_Bool* result);
220   void OnHostMsgGetPluginInstanceURL(PP_Instance instance,
221                                      SerializedVarReturnValue result);
222   void OnHostMsgGetPluginReferrerURL(PP_Instance instance,
223                                      SerializedVarReturnValue result);
224   virtual void OnHostMsgSessionCreated(
225       PP_Instance instance,
226       uint32_t session_id,
227       SerializedVarReceiveInput web_session_id);
228   virtual void OnHostMsgSessionMessage(
229       PP_Instance instance,
230       uint32_t session_id,
231       SerializedVarReceiveInput message,
232       SerializedVarReceiveInput destination_url);
233   virtual void OnHostMsgSessionReady(PP_Instance instance, uint32_t session_id);
234   virtual void OnHostMsgSessionClosed(PP_Instance instance,
235                                       uint32_t session_id);
236   virtual void OnHostMsgSessionError(PP_Instance instance,
237                                      uint32_t session_id,
238                                      int32_t media_error,
239                                      int32_t system_code);
240   virtual void OnHostMsgDecoderInitializeDone(
241       PP_Instance instance,
242       PP_DecryptorStreamType decoder_type,
243       uint32_t request_id,
244       PP_Bool success);
245   virtual void OnHostMsgDecoderDeinitializeDone(
246       PP_Instance instance,
247       PP_DecryptorStreamType decoder_type,
248       uint32_t request_id);
249   virtual void OnHostMsgDecoderResetDone(PP_Instance instance,
250                                          PP_DecryptorStreamType decoder_type,
251                                          uint32_t request_id);
252   virtual void OnHostMsgDeliverBlock(PP_Instance instance,
253                                      PP_Resource decrypted_block,
254                                      const std::string& serialized_block_info);
255   virtual void OnHostMsgDeliverFrame(PP_Instance instance,
256                                      PP_Resource decrypted_frame,
257                                      const std::string& serialized_block_info);
258   virtual void OnHostMsgDeliverSamples(
259       PP_Instance instance,
260       PP_Resource audio_frames,
261       const std::string& serialized_sample_info);
262 #endif  // !defined(OS_NACL)
263 
264   // Host -> Plugin message handlers.
265   void OnPluginMsgMouseLockComplete(PP_Instance instance, int32_t result);
266 
267   void MouseLockCompleteInHost(int32_t result, PP_Instance instance);
268 
269   // Other helpers.
270   void CancelAnyPendingRequestSurroundingText(PP_Instance instance);
271 
272   ProxyCompletionCallbackFactory<PPB_Instance_Proxy> callback_factory_;
273 };
274 
275 }  // namespace proxy
276 }  // namespace ppapi
277 
278 #endif  // PPAPI_PROXY_PPB_INSTANCE_PROXY_H_
279