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