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/common.h"
8 #include "content/renderer/pepper/ppb_audio_impl.h"
9 #include "content/renderer/pepper/ppb_broker_impl.h"
10 #include "content/renderer/pepper/ppb_buffer_impl.h"
11 #include "content/renderer/pepper/ppb_flash_message_loop_impl.h"
12 #include "content/renderer/pepper/ppb_graphics_3d_impl.h"
13 #include "content/renderer/pepper/ppb_image_data_impl.h"
14 #include "content/renderer/pepper/ppb_scrollbar_impl.h"
15 #include "content/renderer/pepper/ppb_video_decoder_impl.h"
16 #include "ppapi/c/pp_size.h"
17 #include "ppapi/shared_impl/ppb_audio_config_shared.h"
18 #include "ppapi/shared_impl/ppb_audio_shared.h"
19 #include "ppapi/shared_impl/ppb_image_data_shared.h"
20 #include "ppapi/shared_impl/ppb_input_event_shared.h"
21 #include "ppapi/shared_impl/ppb_resource_array_shared.h"
22 #include "ppapi/shared_impl/var.h"
24 using ppapi::InputEventData
;
25 using ppapi::PPB_InputEvent_Shared
;
26 using ppapi::PPB_ResourceArray_Shared
;
27 using ppapi::StringVar
;
31 ResourceCreationImpl::ResourceCreationImpl(PepperPluginInstanceImpl
* instance
) {
34 ResourceCreationImpl::~ResourceCreationImpl() {
37 PP_Resource
ResourceCreationImpl::CreateAudio1_0(
39 PP_Resource config_id
,
40 PPB_Audio_Callback_1_0 audio_callback
,
42 return PPB_Audio_Impl::Create(
43 instance
, config_id
, ppapi::AudioCallbackCombined(audio_callback
),
47 PP_Resource
ResourceCreationImpl::CreateAudio(
49 PP_Resource config_id
,
50 PPB_Audio_Callback audio_callback
,
52 return PPB_Audio_Impl::Create(
53 instance
, config_id
, ppapi::AudioCallbackCombined(audio_callback
),
57 PP_Resource
ResourceCreationImpl::CreateAudioConfig(
59 PP_AudioSampleRate sample_rate
,
60 uint32_t sample_frame_count
) {
61 return ppapi::PPB_AudioConfig_Shared::Create(
62 ppapi::OBJECT_IS_IMPL
, instance
, sample_rate
, sample_frame_count
);
65 PP_Resource
ResourceCreationImpl::CreateAudioTrusted(
66 PP_Instance instance
) {
67 return (new PPB_Audio_Impl(instance
))->GetReference();
70 PP_Resource
ResourceCreationImpl::CreateAudioInput(PP_Instance instance
) {
71 return 0; // Not supported in-process.
74 PP_Resource
ResourceCreationImpl::CreateBroker(PP_Instance instance
) {
75 return (new PPB_Broker_Impl(instance
))->GetReference();
78 PP_Resource
ResourceCreationImpl::CreateBuffer(PP_Instance instance
,
80 return PPB_Buffer_Impl::Create(instance
, size
);
83 PP_Resource
ResourceCreationImpl::CreateFlashDRM(PP_Instance instance
) {
84 return 0; // Not supported in-process.
87 PP_Resource
ResourceCreationImpl::CreateFlashFontFile(
89 const PP_BrowserFont_Trusted_Description
* description
,
90 PP_PrivateFontCharset charset
) {
91 return 0; // Not supported in-process.
94 PP_Resource
ResourceCreationImpl::CreateFlashMenu(
96 const PP_Flash_Menu
* menu_data
) {
97 return 0; // Not supported in-process.
100 PP_Resource
ResourceCreationImpl::CreateFlashMessageLoop(PP_Instance instance
) {
101 return PPB_Flash_MessageLoop_Impl::Create(instance
);
104 PP_Resource
ResourceCreationImpl::CreateGraphics3D(
105 PP_Instance instance
,
106 PP_Resource share_context
,
107 const int32_t* attrib_list
) {
108 return PPB_Graphics3D_Impl::Create(instance
, share_context
, attrib_list
);
111 PP_Resource
ResourceCreationImpl::CreateGraphics3DRaw(
112 PP_Instance instance
,
113 PP_Resource share_context
,
114 const int32_t* attrib_list
) {
115 return PPB_Graphics3D_Impl::CreateRaw(instance
, share_context
, attrib_list
);
118 PP_Resource
ResourceCreationImpl::CreateHostResolver(PP_Instance instance
) {
119 return 0; // Not supported in-process.
122 PP_Resource
ResourceCreationImpl::CreateHostResolverPrivate(
123 PP_Instance instance
) {
124 return 0; // Not supported in-process.
127 PP_Resource
ResourceCreationImpl::CreateImageData(
128 PP_Instance instance
,
129 PP_ImageDataFormat format
,
131 PP_Bool init_to_zero
) {
132 return PPB_ImageData_Impl::Create(instance
,
133 ppapi::PPB_ImageData_Shared::PLATFORM
,
134 format
, *size
, init_to_zero
);
137 PP_Resource
ResourceCreationImpl::CreateImageDataSimple(
138 PP_Instance instance
,
139 PP_ImageDataFormat format
,
141 PP_Bool init_to_zero
) {
142 return PPB_ImageData_Impl::Create(instance
,
143 ppapi::PPB_ImageData_Shared::SIMPLE
,
144 format
, *size
, init_to_zero
);
147 PP_Resource
ResourceCreationImpl::CreateIMEInputEvent(
148 PP_Instance instance
,
149 PP_InputEvent_Type type
,
150 PP_TimeTicks time_stamp
,
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(
158 ppapi::OBJECT_IS_IMPL
, instance
, type
, time_stamp
, text
, segment_number
,
159 segment_offsets
, target_segment
, selection_start
, selection_end
);
162 PP_Resource
ResourceCreationImpl::CreateKeyboardInputEvent(
163 PP_Instance instance
,
164 PP_InputEvent_Type type
,
165 PP_TimeTicks time_stamp
,
168 struct PP_Var character_text
) {
169 return PPB_InputEvent_Shared::CreateKeyboardInputEvent(
170 ppapi::OBJECT_IS_IMPL
, instance
, type
, time_stamp
, modifiers
, key_code
,
174 PP_Resource
ResourceCreationImpl::CreateMouseInputEvent(
175 PP_Instance instance
,
176 PP_InputEvent_Type type
,
177 PP_TimeTicks time_stamp
,
179 PP_InputEvent_MouseButton mouse_button
,
180 const PP_Point
* mouse_position
,
182 const PP_Point
* mouse_movement
) {
183 return PPB_InputEvent_Shared::CreateMouseInputEvent(
184 ppapi::OBJECT_IS_IMPL
, instance
, type
, time_stamp
, modifiers
,
185 mouse_button
, mouse_position
, click_count
, mouse_movement
);
188 PP_Resource
ResourceCreationImpl::CreateNetAddressFromIPv4Address(
189 PP_Instance instance
,
190 const PP_NetAddress_IPv4
* ipv4_addr
) {
191 return 0; // Not supported in-process.
194 PP_Resource
ResourceCreationImpl::CreateNetAddressFromIPv6Address(
195 PP_Instance instance
,
196 const PP_NetAddress_IPv6
* ipv6_addr
) {
197 return 0; // Not supported in-process.
200 PP_Resource
ResourceCreationImpl::CreateNetAddressFromNetAddressPrivate(
201 PP_Instance instance
,
202 const PP_NetAddress_Private
& private_addr
) {
203 return 0; // Not supported in-process.
206 PP_Resource
ResourceCreationImpl::CreateTouchInputEvent(
207 PP_Instance instance
,
208 PP_InputEvent_Type type
,
209 PP_TimeTicks time_stamp
,
210 uint32_t modifiers
) {
211 return PPB_InputEvent_Shared::CreateTouchInputEvent(
212 ppapi::OBJECT_IS_IMPL
, instance
, type
, time_stamp
, modifiers
);
215 PP_Resource
ResourceCreationImpl::CreateNetworkMonitor(PP_Instance instance
) {
216 return 0; // Not supported in-process.
219 PP_Resource
ResourceCreationImpl::CreateOutputProtectionPrivate(
220 PP_Instance instance
) {
221 return 0; // Not supported in-process.
224 PP_Resource
ResourceCreationImpl::CreatePlatformVerificationPrivate(
225 PP_Instance instance
) {
226 return 0; // Not supported in-process.
229 PP_Resource
ResourceCreationImpl::CreateScrollbar(PP_Instance instance
,
231 return PPB_Scrollbar_Impl::Create(instance
, PP_ToBool(vertical
));
234 PP_Resource
ResourceCreationImpl::CreateTalk(PP_Instance
/* instance */) {
235 return 0; // Not supported in-process.
238 PP_Resource
ResourceCreationImpl::CreateResourceArray(
239 PP_Instance instance
,
240 const PP_Resource elements
[],
242 PPB_ResourceArray_Shared
* object
= new PPB_ResourceArray_Shared(
243 ppapi::OBJECT_IS_IMPL
, instance
, elements
, size
);
244 return object
->GetReference();
247 PP_Resource
ResourceCreationImpl::CreateTCPServerSocketPrivate(
248 PP_Instance instance
) {
249 return 0; // Not supported in-process.
252 PP_Resource
ResourceCreationImpl::CreateTCPSocket1_0(PP_Instance instance
) {
253 return 0; // Not supported in-process.
256 PP_Resource
ResourceCreationImpl::CreateTCPSocket(PP_Instance instance
) {
257 return 0; // Not supported in-process.
260 PP_Resource
ResourceCreationImpl::CreateTCPSocketPrivate(PP_Instance instance
) {
261 return 0; // Not supported in-process.
264 PP_Resource
ResourceCreationImpl::CreateUDPSocket(PP_Instance instance
) {
265 return 0; // Not supported in-process.
268 PP_Resource
ResourceCreationImpl::CreateUDPSocketPrivate(PP_Instance instance
) {
269 return 0; // Not supported in-process.
272 PP_Resource
ResourceCreationImpl::CreateVideoCapture(PP_Instance instance
) {
273 return 0; // VideoCapture is not supported in process now.
276 PP_Resource
ResourceCreationImpl::CreateVideoDecoder(
277 PP_Instance instance
,
278 PP_Resource graphics3d_id
,
279 PP_VideoDecoder_Profile profile
) {
280 return PPB_VideoDecoder_Impl::Create(instance
, graphics3d_id
, profile
);
283 PP_Resource
ResourceCreationImpl::CreateVideoDestination(
284 PP_Instance instance
) {
285 return 0; // Not supported in-process.
288 PP_Resource
ResourceCreationImpl::CreateVideoSource(
289 PP_Instance instance
) {
290 return 0; // Not supported in-process.
293 PP_Resource
ResourceCreationImpl::CreateWheelInputEvent(
294 PP_Instance instance
,
295 PP_TimeTicks time_stamp
,
297 const PP_FloatPoint
* wheel_delta
,
298 const PP_FloatPoint
* wheel_ticks
,
299 PP_Bool scroll_by_page
) {
300 return PPB_InputEvent_Shared::CreateWheelInputEvent(
301 ppapi::OBJECT_IS_IMPL
, instance
, time_stamp
, modifiers
,
302 wheel_delta
, wheel_ticks
, scroll_by_page
);
305 PP_Resource
ResourceCreationImpl::CreateX509CertificatePrivate(
306 PP_Instance instance
) {
307 return 0; // Not supported in-process.
310 } // namespace content