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_RESOURCE_CREATION_PROXY_H_ 6 #define PPAPI_PROXY_RESOURCE_CREATION_PROXY_H_ 7 8 #include <string> 9 10 #include "base/basictypes.h" 11 #include "ipc/ipc_channel.h" 12 #include "ppapi/c/pp_bool.h" 13 #include "ppapi/c/pp_instance.h" 14 #include "ppapi/proxy/interface_proxy.h" 15 #include "ppapi/proxy/serialized_structs.h" 16 #include "ppapi/thunk/resource_creation_api.h" 17 18 struct PP_Size; 19 20 namespace ppapi { 21 22 class HostResource; 23 24 namespace proxy { 25 26 struct Connection; 27 class Dispatcher; 28 29 class ResourceCreationProxy : public InterfaceProxy, 30 public thunk::ResourceCreationAPI { 31 public: 32 explicit ResourceCreationProxy(Dispatcher* dispatcher); 33 virtual ~ResourceCreationProxy(); 34 35 // Factory function used for registration (normal code can just use the 36 // constructor). 37 static InterfaceProxy* Create(Dispatcher* dispatcher); 38 39 // ResourceCreationAPI (called in plugin). 40 virtual PP_Resource CreateFileIO(PP_Instance instance) OVERRIDE; 41 virtual PP_Resource CreateFileRef( 42 PP_Instance instance, 43 const FileRefCreateInfo& create_info) OVERRIDE; 44 virtual PP_Resource CreateFileSystem(PP_Instance instance, 45 PP_FileSystemType type) OVERRIDE; 46 virtual PP_Resource CreateIMEInputEvent(PP_Instance instance, 47 PP_InputEvent_Type type, 48 PP_TimeTicks time_stamp, 49 struct PP_Var text, 50 uint32_t segment_number, 51 const uint32_t* segment_offsets, 52 int32_t target_segment, 53 uint32_t selection_start, 54 uint32_t selection_end) OVERRIDE; 55 virtual PP_Resource CreateKeyboardInputEvent( 56 PP_Instance instance, 57 PP_InputEvent_Type type, 58 PP_TimeTicks time_stamp, 59 uint32_t modifiers, 60 uint32_t key_code, 61 PP_Var character_text) OVERRIDE; 62 virtual PP_Resource CreateMouseInputEvent( 63 PP_Instance instance, 64 PP_InputEvent_Type type, 65 PP_TimeTicks time_stamp, 66 uint32_t modifiers, 67 PP_InputEvent_MouseButton mouse_button, 68 const PP_Point* mouse_position, 69 int32_t click_count, 70 const PP_Point* mouse_movement) OVERRIDE; 71 virtual PP_Resource CreateTouchInputEvent( 72 PP_Instance instance, 73 PP_InputEvent_Type type, 74 PP_TimeTicks time_stamp, 75 uint32_t modifiers) OVERRIDE; 76 virtual PP_Resource CreateResourceArray(PP_Instance instance, 77 const PP_Resource elements[], 78 uint32_t size) OVERRIDE; 79 virtual PP_Resource CreateTrueTypeFont( 80 PP_Instance instance, 81 const PP_TrueTypeFontDesc_Dev* desc) OVERRIDE; 82 virtual PP_Resource CreateURLLoader(PP_Instance instance) OVERRIDE; 83 virtual PP_Resource CreateURLRequestInfo( 84 PP_Instance instance) OVERRIDE; 85 virtual PP_Resource CreateWheelInputEvent( 86 PP_Instance instance, 87 PP_TimeTicks time_stamp, 88 uint32_t modifiers, 89 const PP_FloatPoint* wheel_delta, 90 const PP_FloatPoint* wheel_ticks, 91 PP_Bool scroll_by_page) OVERRIDE; 92 virtual PP_Resource CreateAudio1_0(PP_Instance instance, 93 PP_Resource config_id, 94 PPB_Audio_Callback_1_0 audio_callback, 95 void* user_data) OVERRIDE; 96 virtual PP_Resource CreateAudio(PP_Instance instance, 97 PP_Resource config_id, 98 PPB_Audio_Callback audio_callback, 99 void* user_data) OVERRIDE; 100 virtual PP_Resource CreateAudioTrusted(PP_Instance instance) OVERRIDE; 101 virtual PP_Resource CreateAudioConfig(PP_Instance instance, 102 PP_AudioSampleRate sample_rate, 103 uint32_t sample_frame_count) OVERRIDE; 104 virtual PP_Resource CreateFileChooser(PP_Instance instance, 105 PP_FileChooserMode_Dev mode, 106 const PP_Var& accept_types) OVERRIDE; 107 virtual PP_Resource CreateGraphics2D(PP_Instance pp_instance, 108 const PP_Size* size, 109 PP_Bool is_always_opaque) OVERRIDE; 110 virtual PP_Resource CreateGraphics3D(PP_Instance instance, 111 PP_Resource share_context, 112 const int32_t* attrib_list) OVERRIDE; 113 virtual PP_Resource CreateGraphics3DRaw( 114 PP_Instance instance, 115 PP_Resource share_context, 116 const int32_t* attrib_list) OVERRIDE; 117 virtual PP_Resource CreateHostResolver(PP_Instance instance) OVERRIDE; 118 virtual PP_Resource CreateHostResolverPrivate(PP_Instance instance) OVERRIDE; 119 virtual PP_Resource CreateImageData(PP_Instance instance, 120 PP_ImageDataFormat format, 121 const PP_Size* size, 122 PP_Bool init_to_zero) OVERRIDE; 123 virtual PP_Resource CreateImageDataSimple(PP_Instance instance, 124 PP_ImageDataFormat format, 125 const PP_Size* size, 126 PP_Bool init_to_zero) OVERRIDE; 127 virtual PP_Resource CreateNetAddressFromIPv4Address( 128 PP_Instance instance, 129 const PP_NetAddress_IPv4* ipv4_addr) OVERRIDE; 130 virtual PP_Resource CreateNetAddressFromIPv6Address( 131 PP_Instance instance, 132 const PP_NetAddress_IPv6* ipv6_addr) OVERRIDE; 133 virtual PP_Resource CreateNetAddressFromNetAddressPrivate( 134 PP_Instance instance, 135 const PP_NetAddress_Private& private_addr) OVERRIDE; 136 virtual PP_Resource CreateNetworkMonitor(PP_Instance instance) OVERRIDE; 137 virtual PP_Resource CreateOutputProtectionPrivate( 138 PP_Instance instance) OVERRIDE; 139 virtual PP_Resource CreatePrinting(PP_Instance) OVERRIDE; 140 virtual PP_Resource CreateTCPServerSocketPrivate( 141 PP_Instance instance) OVERRIDE; 142 virtual PP_Resource CreateTCPSocket1_0(PP_Instance instance) OVERRIDE; 143 virtual PP_Resource CreateTCPSocket(PP_Instance instance) OVERRIDE; 144 virtual PP_Resource CreateTCPSocketPrivate(PP_Instance instance) OVERRIDE; 145 virtual PP_Resource CreateUDPSocket(PP_Instance instance) OVERRIDE; 146 virtual PP_Resource CreateUDPSocketPrivate(PP_Instance instance) OVERRIDE; 147 virtual PP_Resource CreateVideoDestination(PP_Instance instance) OVERRIDE; 148 virtual PP_Resource CreateVideoSource(PP_Instance instance) OVERRIDE; 149 virtual PP_Resource CreateWebSocket(PP_Instance instance) OVERRIDE; 150 virtual PP_Resource CreateX509CertificatePrivate( 151 PP_Instance instance) OVERRIDE; 152 #if !defined(OS_NACL) 153 virtual PP_Resource CreateAudioInput(PP_Instance instance) OVERRIDE; 154 virtual PP_Resource CreateBroker(PP_Instance instance) OVERRIDE; 155 virtual PP_Resource CreateBrowserFont( 156 PP_Instance instance, 157 const PP_BrowserFont_Trusted_Description* description) OVERRIDE; 158 virtual PP_Resource CreateBuffer(PP_Instance instance, 159 uint32_t size) OVERRIDE; 160 virtual PP_Resource CreateFlashDRM(PP_Instance instance) OVERRIDE; 161 virtual PP_Resource CreateFlashFontFile( 162 PP_Instance instance, 163 const PP_BrowserFont_Trusted_Description* description, 164 PP_PrivateFontCharset charset) OVERRIDE; 165 virtual PP_Resource CreateFlashMenu(PP_Instance instance, 166 const PP_Flash_Menu* menu_data) OVERRIDE; 167 virtual PP_Resource CreateFlashMessageLoop(PP_Instance instance) OVERRIDE; 168 virtual PP_Resource CreatePlatformVerificationPrivate( 169 PP_Instance instance) OVERRIDE; 170 virtual PP_Resource CreateScrollbar(PP_Instance instance, 171 PP_Bool vertical) OVERRIDE; 172 virtual PP_Resource CreateTalk(PP_Instance instance) OVERRIDE; 173 virtual PP_Resource CreateVideoCapture(PP_Instance instance) OVERRIDE; 174 virtual PP_Resource CreateVideoDecoder( 175 PP_Instance instance, 176 PP_Resource context3d_id, 177 PP_VideoDecoder_Profile profile) OVERRIDE; 178 #endif // !defined(OS_NACL) 179 180 virtual bool Send(IPC::Message* msg) OVERRIDE; 181 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; 182 183 private: 184 Connection GetConnection(); 185 DISALLOW_COPY_AND_ASSIGN(ResourceCreationProxy); 186 }; 187 188 } // namespace proxy 189 } // namespace ppapi 190 191 #endif // PPAPI_PROXY_RESOURCE_CREATION_PROXY_H_ 192