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 #include "content/renderer/pepper/resource_creation_impl.h"
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"
24 using ppapi::InputEventData
;
25 using ppapi::PPB_InputEvent_Shared
;
26 using ppapi::StringVar
;
30 ResourceCreationImpl::ResourceCreationImpl(PepperPluginInstanceImpl
* instance
) {
33 ResourceCreationImpl::~ResourceCreationImpl() {}
35 PP_Resource
ResourceCreationImpl::CreateAudio1_0(
37 PP_Resource config_id
,
38 PPB_Audio_Callback_1_0 audio_callback
,
40 return 0; // Not supported in-process.
43 PP_Resource
ResourceCreationImpl::CreateAudio(PP_Instance instance
,
44 PP_Resource config_id
,
45 PPB_Audio_Callback audio_callback
,
47 return 0; // Not supported in-process.
50 PP_Resource
ResourceCreationImpl::CreateAudioConfig(
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
);
58 PP_Resource
ResourceCreationImpl::CreateAudioTrusted(PP_Instance instance
) {
59 return (new PPB_Audio_Impl(instance
))->GetReference();
62 PP_Resource
ResourceCreationImpl::CreateAudioInput(PP_Instance instance
) {
63 return 0; // Not supported in-process.
66 PP_Resource
ResourceCreationImpl::CreateCompositor(PP_Instance instance
) {
67 return 0; // Not supported in-process.
70 PP_Resource
ResourceCreationImpl::CreateBroker(PP_Instance instance
) {
71 return (new PPB_Broker_Impl(instance
))->GetReference();
74 PP_Resource
ResourceCreationImpl::CreateBuffer(PP_Instance instance
,
76 return PPB_Buffer_Impl::Create(instance
, size
);
79 PP_Resource
ResourceCreationImpl::CreateFlashDRM(PP_Instance instance
) {
80 return 0; // Not supported in-process.
83 PP_Resource
ResourceCreationImpl::CreateFlashFontFile(
85 const PP_BrowserFont_Trusted_Description
* description
,
86 PP_PrivateFontCharset charset
) {
87 return 0; // Not supported in-process.
90 PP_Resource
ResourceCreationImpl::CreateFlashMenu(
92 const PP_Flash_Menu
* menu_data
) {
93 return 0; // Not supported in-process.
96 PP_Resource
ResourceCreationImpl::CreateFlashMessageLoop(PP_Instance instance
) {
97 return PPB_Flash_MessageLoop_Impl::Create(instance
);
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
);
106 PP_Resource
ResourceCreationImpl::CreateGraphics3DRaw(
107 PP_Instance instance
,
108 PP_Resource share_context
,
109 const int32_t* attrib_list
) {
110 return PPB_Graphics3D_Impl::CreateRaw(instance
, share_context
, attrib_list
);
113 PP_Resource
ResourceCreationImpl::CreateHostResolver(PP_Instance instance
) {
114 return 0; // Not supported in-process.
117 PP_Resource
ResourceCreationImpl::CreateHostResolverPrivate(
118 PP_Instance instance
) {
119 return 0; // Not supported in-process.
122 PP_Resource
ResourceCreationImpl::CreateImageData(PP_Instance instance
,
123 PP_ImageDataFormat format
,
125 PP_Bool init_to_zero
) {
126 return PPB_ImageData_Impl::Create(instance
,
127 ppapi::PPB_ImageData_Shared::PLATFORM
,
133 PP_Resource
ResourceCreationImpl::CreateImageDataSimple(
134 PP_Instance instance
,
135 PP_ImageDataFormat format
,
137 PP_Bool init_to_zero
) {
138 return PPB_ImageData_Impl::Create(instance
,
139 ppapi::PPB_ImageData_Shared::SIMPLE
,
145 PP_Resource
ResourceCreationImpl::CreateIMEInputEvent(
146 PP_Instance instance
,
147 PP_InputEvent_Type type
,
148 PP_TimeTicks time_stamp
,
150 uint32_t segment_number
,
151 const uint32_t* segment_offsets
,
152 int32_t target_segment
,
153 uint32_t selection_start
,
154 uint32_t selection_end
) {
155 return PPB_InputEvent_Shared::CreateIMEInputEvent(ppapi::OBJECT_IS_IMPL
,
167 PP_Resource
ResourceCreationImpl::CreateKeyboardInputEvent_1_0(
168 PP_Instance instance
,
169 PP_InputEvent_Type type
,
170 PP_TimeTicks time_stamp
,
173 struct PP_Var character_text
) {
174 PP_Var code
= StringVar::StringToPPVar("");
175 return PPB_InputEvent_Shared::CreateKeyboardInputEvent(ppapi::OBJECT_IS_IMPL
,
185 PP_Resource
ResourceCreationImpl::CreateKeyboardInputEvent_1_2(
186 PP_Instance instance
,
187 PP_InputEvent_Type type
,
188 PP_TimeTicks time_stamp
,
191 struct PP_Var character_text
,
192 struct PP_Var code
) {
193 return PPB_InputEvent_Shared::CreateKeyboardInputEvent(ppapi::OBJECT_IS_IMPL
,
203 PP_Resource
ResourceCreationImpl::CreateMediaStreamVideoTrack(
204 PP_Instance instance
) {
205 return 0; // Not supported in-process.
208 PP_Resource
ResourceCreationImpl::CreateMouseInputEvent(
209 PP_Instance instance
,
210 PP_InputEvent_Type type
,
211 PP_TimeTicks time_stamp
,
213 PP_InputEvent_MouseButton mouse_button
,
214 const PP_Point
* mouse_position
,
216 const PP_Point
* mouse_movement
) {
217 return PPB_InputEvent_Shared::CreateMouseInputEvent(ppapi::OBJECT_IS_IMPL
,
228 PP_Resource
ResourceCreationImpl::CreateNetAddressFromIPv4Address(
229 PP_Instance instance
,
230 const PP_NetAddress_IPv4
* ipv4_addr
) {
231 return 0; // Not supported in-process.
234 PP_Resource
ResourceCreationImpl::CreateNetAddressFromIPv6Address(
235 PP_Instance instance
,
236 const PP_NetAddress_IPv6
* ipv6_addr
) {
237 return 0; // Not supported in-process.
240 PP_Resource
ResourceCreationImpl::CreateNetAddressFromNetAddressPrivate(
241 PP_Instance instance
,
242 const PP_NetAddress_Private
& private_addr
) {
243 return 0; // Not supported in-process.
246 PP_Resource
ResourceCreationImpl::CreateNetworkMonitor(PP_Instance instance
) {
247 return 0; // Not supported in-process.
250 PP_Resource
ResourceCreationImpl::CreateOutputProtectionPrivate(
251 PP_Instance instance
) {
252 return 0; // Not supported in-process.
255 PP_Resource
ResourceCreationImpl::CreatePlatformVerificationPrivate(
256 PP_Instance instance
) {
257 return 0; // Not supported in-process.
260 PP_Resource
ResourceCreationImpl::CreateScrollbar(PP_Instance instance
,
262 return PPB_Scrollbar_Impl::Create(instance
, PP_ToBool(vertical
));
265 PP_Resource
ResourceCreationImpl::CreateTalk(PP_Instance
/* instance */) {
266 return 0; // Not supported in-process.
269 PP_Resource
ResourceCreationImpl::CreateTCPServerSocketPrivate(
270 PP_Instance instance
) {
271 return 0; // Not supported in-process.
274 PP_Resource
ResourceCreationImpl::CreateTCPSocket1_0(PP_Instance instance
) {
275 return 0; // Not supported in-process.
278 PP_Resource
ResourceCreationImpl::CreateTCPSocket(PP_Instance instance
) {
279 return 0; // Not supported in-process.
282 PP_Resource
ResourceCreationImpl::CreateTCPSocketPrivate(PP_Instance instance
) {
283 return 0; // Not supported in-process.
286 PP_Resource
ResourceCreationImpl::CreateTouchInputEvent(PP_Instance instance
,
287 PP_InputEvent_Type type
,
288 PP_TimeTicks time_stamp
,
289 uint32_t modifiers
) {
290 return PPB_InputEvent_Shared::CreateTouchInputEvent(
291 ppapi::OBJECT_IS_IMPL
, instance
, type
, time_stamp
, modifiers
);
294 PP_Resource
ResourceCreationImpl::CreateUDPSocket(PP_Instance instance
) {
295 return 0; // Not supported in-process.
298 PP_Resource
ResourceCreationImpl::CreateUDPSocketPrivate(PP_Instance instance
) {
299 return 0; // Not supported in-process.
302 PP_Resource
ResourceCreationImpl::CreateVideoCapture(PP_Instance instance
) {
303 return 0; // Not supported in-process.
306 PP_Resource
ResourceCreationImpl::CreateVideoDecoder(PP_Instance instance
) {
307 return 0; // Not supported in-process.
310 PP_Resource
ResourceCreationImpl::CreateVideoDecoderDev(
311 PP_Instance instance
,
312 PP_Resource graphics3d_id
,
313 PP_VideoDecoder_Profile profile
) {
314 return PPB_VideoDecoder_Impl::Create(instance
, graphics3d_id
, profile
);
317 PP_Resource
ResourceCreationImpl::CreateVideoDestination(PP_Instance instance
) {
318 return 0; // Not supported in-process.
321 PP_Resource
ResourceCreationImpl::CreateVideoSource(PP_Instance instance
) {
322 return 0; // Not supported in-process.
325 PP_Resource
ResourceCreationImpl::CreateWheelInputEvent(
326 PP_Instance instance
,
327 PP_TimeTicks time_stamp
,
329 const PP_FloatPoint
* wheel_delta
,
330 const PP_FloatPoint
* wheel_ticks
,
331 PP_Bool scroll_by_page
) {
332 return PPB_InputEvent_Shared::CreateWheelInputEvent(ppapi::OBJECT_IS_IMPL
,
341 PP_Resource
ResourceCreationImpl::CreateX509CertificatePrivate(
342 PP_Instance instance
) {
343 return 0; // Not supported in-process.
346 } // namespace content