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 #include "content/renderer/pepper/resource_creation_impl.h" 6 7 #include "content/renderer/pepper/ppb_audio_impl.h" 8 #include "content/renderer/pepper/ppb_broker_impl.h" 9 #include "content/renderer/pepper/ppb_buffer_impl.h" 10 #include "content/renderer/pepper/ppb_flash_message_loop_impl.h" 11 #include "content/renderer/pepper/ppb_graphics_3d_impl.h" 12 #include "content/renderer/pepper/ppb_image_data_impl.h" 13 #include "content/renderer/pepper/ppb_scrollbar_impl.h" 14 #include "content/renderer/pepper/ppb_video_decoder_impl.h" 15 #include "ppapi/c/pp_bool.h" 16 #include "ppapi/c/pp_size.h" 17 #include "ppapi/c/pp_var.h" 18 #include "ppapi/shared_impl/ppb_audio_config_shared.h" 19 #include "ppapi/shared_impl/ppb_audio_shared.h" 20 #include "ppapi/shared_impl/ppb_image_data_shared.h" 21 #include "ppapi/shared_impl/ppb_input_event_shared.h" 22 #include "ppapi/shared_impl/var.h" 23 24 using ppapi::InputEventData; 25 using ppapi::PPB_InputEvent_Shared; 26 using ppapi::StringVar; 27 28 namespace content { 29 30 ResourceCreationImpl::ResourceCreationImpl(PepperPluginInstanceImpl* instance) { 31 } 32 33 ResourceCreationImpl::~ResourceCreationImpl() {} 34 35 PP_Resource ResourceCreationImpl::CreateAudio1_0( 36 PP_Instance instance, 37 PP_Resource config_id, 38 PPB_Audio_Callback_1_0 audio_callback, 39 void* user_data) { 40 return 0; // Not supported in-process. 41 } 42 43 PP_Resource ResourceCreationImpl::CreateAudio(PP_Instance instance, 44 PP_Resource config_id, 45 PPB_Audio_Callback audio_callback, 46 void* user_data) { 47 return 0; // Not supported in-process. 48 } 49 50 PP_Resource ResourceCreationImpl::CreateAudioConfig( 51 PP_Instance instance, 52 PP_AudioSampleRate sample_rate, 53 uint32_t sample_frame_count) { 54 return ppapi::PPB_AudioConfig_Shared::Create( 55 ppapi::OBJECT_IS_IMPL, instance, sample_rate, sample_frame_count); 56 } 57 58 PP_Resource ResourceCreationImpl::CreateAudioTrusted(PP_Instance instance) { 59 return (new PPB_Audio_Impl(instance))->GetReference(); 60 } 61 62 PP_Resource ResourceCreationImpl::CreateAudioInput(PP_Instance instance) { 63 return 0; // Not supported in-process. 64 } 65 66 PP_Resource ResourceCreationImpl::CreateCompositor(PP_Instance instance) { 67 return 0; // Not supported in-process. 68 } 69 70 PP_Resource ResourceCreationImpl::CreateBroker(PP_Instance instance) { 71 return (new PPB_Broker_Impl(instance))->GetReference(); 72 } 73 74 PP_Resource ResourceCreationImpl::CreateBuffer(PP_Instance instance, 75 uint32_t size) { 76 return PPB_Buffer_Impl::Create(instance, size); 77 } 78 79 PP_Resource ResourceCreationImpl::CreateFlashDRM(PP_Instance instance) { 80 return 0; // Not supported in-process. 81 } 82 83 PP_Resource ResourceCreationImpl::CreateFlashFontFile( 84 PP_Instance instance, 85 const PP_BrowserFont_Trusted_Description* description, 86 PP_PrivateFontCharset charset) { 87 return 0; // Not supported in-process. 88 } 89 90 PP_Resource ResourceCreationImpl::CreateFlashMenu( 91 PP_Instance instance, 92 const PP_Flash_Menu* menu_data) { 93 return 0; // Not supported in-process. 94 } 95 96 PP_Resource ResourceCreationImpl::CreateFlashMessageLoop(PP_Instance instance) { 97 return PPB_Flash_MessageLoop_Impl::Create(instance); 98 } 99 100 PP_Resource ResourceCreationImpl::CreateGraphics3D(PP_Instance instance, 101 PP_Resource share_context, 102 const int32_t* attrib_list) { 103 return PPB_Graphics3D_Impl::Create(instance, share_context, attrib_list); 104 } 105 106 PP_Resource ResourceCreationImpl::CreateGraphics3DRaw( 107 PP_Instance instance, 108 PP_Resource share_context, 109 const int32_t* attrib_list, 110 base::SharedMemoryHandle* shared_state) { 111 return PPB_Graphics3D_Impl::CreateRaw(instance, share_context, attrib_list, 112 shared_state); 113 } 114 115 PP_Resource ResourceCreationImpl::CreateHostResolver(PP_Instance instance) { 116 return 0; // Not supported in-process. 117 } 118 119 PP_Resource ResourceCreationImpl::CreateHostResolverPrivate( 120 PP_Instance instance) { 121 return 0; // Not supported in-process. 122 } 123 124 PP_Resource ResourceCreationImpl::CreateImageData(PP_Instance instance, 125 PP_ImageDataFormat format, 126 const PP_Size* size, 127 PP_Bool init_to_zero) { 128 return PPB_ImageData_Impl::Create(instance, 129 ppapi::PPB_ImageData_Shared::PLATFORM, 130 format, 131 *size, 132 init_to_zero); 133 } 134 135 PP_Resource ResourceCreationImpl::CreateImageDataSimple( 136 PP_Instance instance, 137 PP_ImageDataFormat format, 138 const PP_Size* size, 139 PP_Bool init_to_zero) { 140 return PPB_ImageData_Impl::Create(instance, 141 ppapi::PPB_ImageData_Shared::SIMPLE, 142 format, 143 *size, 144 init_to_zero); 145 } 146 147 PP_Resource ResourceCreationImpl::CreateIMEInputEvent( 148 PP_Instance instance, 149 PP_InputEvent_Type type, 150 PP_TimeTicks time_stamp, 151 struct PP_Var text, 152 uint32_t segment_number, 153 const uint32_t* segment_offsets, 154 int32_t target_segment, 155 uint32_t selection_start, 156 uint32_t selection_end) { 157 return PPB_InputEvent_Shared::CreateIMEInputEvent(ppapi::OBJECT_IS_IMPL, 158 instance, 159 type, 160 time_stamp, 161 text, 162 segment_number, 163 segment_offsets, 164 target_segment, 165 selection_start, 166 selection_end); 167 } 168 169 PP_Resource ResourceCreationImpl::CreateKeyboardInputEvent_1_0( 170 PP_Instance instance, 171 PP_InputEvent_Type type, 172 PP_TimeTicks time_stamp, 173 uint32_t modifiers, 174 uint32_t key_code, 175 struct PP_Var character_text) { 176 PP_Var code = StringVar::StringToPPVar(""); 177 return PPB_InputEvent_Shared::CreateKeyboardInputEvent(ppapi::OBJECT_IS_IMPL, 178 instance, 179 type, 180 time_stamp, 181 modifiers, 182 key_code, 183 character_text, 184 code); 185 } 186 187 PP_Resource ResourceCreationImpl::CreateKeyboardInputEvent_1_2( 188 PP_Instance instance, 189 PP_InputEvent_Type type, 190 PP_TimeTicks time_stamp, 191 uint32_t modifiers, 192 uint32_t key_code, 193 struct PP_Var character_text, 194 struct PP_Var code) { 195 return PPB_InputEvent_Shared::CreateKeyboardInputEvent(ppapi::OBJECT_IS_IMPL, 196 instance, 197 type, 198 time_stamp, 199 modifiers, 200 key_code, 201 character_text, 202 code); 203 } 204 205 PP_Resource ResourceCreationImpl::CreateMediaStreamVideoTrack( 206 PP_Instance instance) { 207 return 0; // Not supported in-process. 208 } 209 210 PP_Resource ResourceCreationImpl::CreateMouseInputEvent( 211 PP_Instance instance, 212 PP_InputEvent_Type type, 213 PP_TimeTicks time_stamp, 214 uint32_t modifiers, 215 PP_InputEvent_MouseButton mouse_button, 216 const PP_Point* mouse_position, 217 int32_t click_count, 218 const PP_Point* mouse_movement) { 219 return PPB_InputEvent_Shared::CreateMouseInputEvent(ppapi::OBJECT_IS_IMPL, 220 instance, 221 type, 222 time_stamp, 223 modifiers, 224 mouse_button, 225 mouse_position, 226 click_count, 227 mouse_movement); 228 } 229 230 PP_Resource ResourceCreationImpl::CreateNetAddressFromIPv4Address( 231 PP_Instance instance, 232 const PP_NetAddress_IPv4* ipv4_addr) { 233 return 0; // Not supported in-process. 234 } 235 236 PP_Resource ResourceCreationImpl::CreateNetAddressFromIPv6Address( 237 PP_Instance instance, 238 const PP_NetAddress_IPv6* ipv6_addr) { 239 return 0; // Not supported in-process. 240 } 241 242 PP_Resource ResourceCreationImpl::CreateNetAddressFromNetAddressPrivate( 243 PP_Instance instance, 244 const PP_NetAddress_Private& private_addr) { 245 return 0; // Not supported in-process. 246 } 247 248 PP_Resource ResourceCreationImpl::CreateNetworkMonitor(PP_Instance instance) { 249 return 0; // Not supported in-process. 250 } 251 252 PP_Resource ResourceCreationImpl::CreateOutputProtectionPrivate( 253 PP_Instance instance) { 254 return 0; // Not supported in-process. 255 } 256 257 PP_Resource ResourceCreationImpl::CreatePlatformVerificationPrivate( 258 PP_Instance instance) { 259 return 0; // Not supported in-process. 260 } 261 262 PP_Resource ResourceCreationImpl::CreateScrollbar(PP_Instance instance, 263 PP_Bool vertical) { 264 return PPB_Scrollbar_Impl::Create(instance, PP_ToBool(vertical)); 265 } 266 267 PP_Resource ResourceCreationImpl::CreateTalk(PP_Instance /* instance */) { 268 return 0; // Not supported in-process. 269 } 270 271 PP_Resource ResourceCreationImpl::CreateTCPServerSocketPrivate( 272 PP_Instance instance) { 273 return 0; // Not supported in-process. 274 } 275 276 PP_Resource ResourceCreationImpl::CreateTCPSocket1_0(PP_Instance instance) { 277 return 0; // Not supported in-process. 278 } 279 280 PP_Resource ResourceCreationImpl::CreateTCPSocket(PP_Instance instance) { 281 return 0; // Not supported in-process. 282 } 283 284 PP_Resource ResourceCreationImpl::CreateTCPSocketPrivate(PP_Instance instance) { 285 return 0; // Not supported in-process. 286 } 287 288 PP_Resource ResourceCreationImpl::CreateTouchInputEvent(PP_Instance instance, 289 PP_InputEvent_Type type, 290 PP_TimeTicks time_stamp, 291 uint32_t modifiers) { 292 return PPB_InputEvent_Shared::CreateTouchInputEvent( 293 ppapi::OBJECT_IS_IMPL, instance, type, time_stamp, modifiers); 294 } 295 296 PP_Resource ResourceCreationImpl::CreateUDPSocket(PP_Instance instance) { 297 return 0; // Not supported in-process. 298 } 299 300 PP_Resource ResourceCreationImpl::CreateUDPSocketPrivate(PP_Instance instance) { 301 return 0; // Not supported in-process. 302 } 303 304 PP_Resource ResourceCreationImpl::CreateVideoCapture(PP_Instance instance) { 305 return 0; // Not supported in-process. 306 } 307 308 PP_Resource ResourceCreationImpl::CreateVideoDecoder(PP_Instance instance) { 309 return 0; // Not supported in-process. 310 } 311 312 PP_Resource ResourceCreationImpl::CreateVideoDecoderDev( 313 PP_Instance instance, 314 PP_Resource graphics3d_id, 315 PP_VideoDecoder_Profile profile) { 316 return PPB_VideoDecoder_Impl::Create(instance, graphics3d_id, profile); 317 } 318 319 PP_Resource ResourceCreationImpl::CreateVideoDestination(PP_Instance instance) { 320 return 0; // Not supported in-process. 321 } 322 323 PP_Resource ResourceCreationImpl::CreateVideoSource(PP_Instance instance) { 324 return 0; // Not supported in-process. 325 } 326 327 PP_Resource ResourceCreationImpl::CreateWheelInputEvent( 328 PP_Instance instance, 329 PP_TimeTicks time_stamp, 330 uint32_t modifiers, 331 const PP_FloatPoint* wheel_delta, 332 const PP_FloatPoint* wheel_ticks, 333 PP_Bool scroll_by_page) { 334 return PPB_InputEvent_Shared::CreateWheelInputEvent(ppapi::OBJECT_IS_IMPL, 335 instance, 336 time_stamp, 337 modifiers, 338 wheel_delta, 339 wheel_ticks, 340 scroll_by_page); 341 } 342 343 PP_Resource ResourceCreationImpl::CreateX509CertificatePrivate( 344 PP_Instance instance) { 345 return 0; // Not supported in-process. 346 } 347 348 } // namespace content 349