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/common/content_switches_internal.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_bool.h"
17 #include "ppapi/c/pp_size.h"
18 #include "ppapi/c/pp_var.h"
19 #include "ppapi/shared_impl/ppb_audio_config_shared.h"
20 #include "ppapi/shared_impl/ppb_audio_shared.h"
21 #include "ppapi/shared_impl/ppb_image_data_shared.h"
22 #include "ppapi/shared_impl/ppb_input_event_shared.h"
23 #include "ppapi/shared_impl/var.h"
26 #include "base/command_line.h"
27 #include "base/win/windows_version.h"
30 using ppapi::InputEventData
;
31 using ppapi::PPB_InputEvent_Shared
;
32 using ppapi::StringVar
;
36 ResourceCreationImpl::ResourceCreationImpl(PepperPluginInstanceImpl
* instance
) {
39 ResourceCreationImpl::~ResourceCreationImpl() {}
41 PP_Resource
ResourceCreationImpl::CreateAudio1_0(
43 PP_Resource config_id
,
44 PPB_Audio_Callback_1_0 audio_callback
,
46 return 0; // Not supported in-process.
49 PP_Resource
ResourceCreationImpl::CreateAudio(PP_Instance instance
,
50 PP_Resource config_id
,
51 PPB_Audio_Callback audio_callback
,
53 return 0; // Not supported in-process.
56 PP_Resource
ResourceCreationImpl::CreateAudioConfig(
58 PP_AudioSampleRate sample_rate
,
59 uint32_t sample_frame_count
) {
60 return ppapi::PPB_AudioConfig_Shared::Create(
61 ppapi::OBJECT_IS_IMPL
, instance
, sample_rate
, sample_frame_count
);
64 PP_Resource
ResourceCreationImpl::CreateAudioTrusted(PP_Instance instance
) {
65 return (new PPB_Audio_Impl(instance
))->GetReference();
68 PP_Resource
ResourceCreationImpl::CreateAudioInput(PP_Instance instance
) {
69 return 0; // Not supported in-process.
72 PP_Resource
ResourceCreationImpl::CreateCompositor(PP_Instance instance
) {
73 return 0; // Not supported in-process.
76 PP_Resource
ResourceCreationImpl::CreateBroker(PP_Instance instance
) {
77 return (new PPB_Broker_Impl(instance
))->GetReference();
80 PP_Resource
ResourceCreationImpl::CreateBuffer(PP_Instance instance
,
82 return PPB_Buffer_Impl::Create(instance
, size
);
85 PP_Resource
ResourceCreationImpl::CreateCameraDevicePrivate(
86 PP_Instance instance
) {
87 return 0; // Not supported in-process.
90 PP_Resource
ResourceCreationImpl::CreateFlashDRM(PP_Instance instance
) {
91 return 0; // Not supported in-process.
94 PP_Resource
ResourceCreationImpl::CreateFlashFontFile(
96 const PP_BrowserFont_Trusted_Description
* description
,
97 PP_PrivateFontCharset charset
) {
98 return 0; // Not supported in-process.
101 PP_Resource
ResourceCreationImpl::CreateFlashMenu(
102 PP_Instance instance
,
103 const PP_Flash_Menu
* menu_data
) {
104 return 0; // Not supported in-process.
107 PP_Resource
ResourceCreationImpl::CreateFlashMessageLoop(PP_Instance instance
) {
108 return PPB_Flash_MessageLoop_Impl::Create(instance
);
111 PP_Resource
ResourceCreationImpl::CreateGraphics3D(PP_Instance instance
,
112 PP_Resource share_context
,
113 const int32_t* attrib_list
) {
114 return PPB_Graphics3D_Impl::Create(instance
, share_context
, attrib_list
);
117 PP_Resource
ResourceCreationImpl::CreateGraphics3DRaw(
118 PP_Instance instance
,
119 PP_Resource share_context
,
120 const int32_t* attrib_list
,
121 gpu::Capabilities
* capabilities
,
122 base::SharedMemoryHandle
* shared_state
) {
123 return PPB_Graphics3D_Impl::CreateRaw(instance
, share_context
, attrib_list
,
124 capabilities
, shared_state
);
127 PP_Resource
ResourceCreationImpl::CreateHostResolver(PP_Instance instance
) {
128 return 0; // Not supported in-process.
131 PP_Resource
ResourceCreationImpl::CreateHostResolverPrivate(
132 PP_Instance instance
) {
133 return 0; // Not supported in-process.
136 PP_Resource
ResourceCreationImpl::CreateImageData(PP_Instance instance
,
137 PP_ImageDataFormat format
,
139 PP_Bool init_to_zero
) {
141 // If Win32K lockdown mitigations are enabled for Windows 8 and beyond,
142 // we use the SIMPLE image data type as the PLATFORM image data type
143 // calls GDI functions to create DIB sections etc which fail in Win32K
146 // Look into whether this causes a loss of functionality. From cursory
147 // testing things seem to work well.
148 if (IsWin32kRendererLockdownEnabled())
149 return CreateImageDataSimple(instance
, format
, size
, init_to_zero
);
151 return PPB_ImageData_Impl::Create(instance
,
152 ppapi::PPB_ImageData_Shared::PLATFORM
,
158 PP_Resource
ResourceCreationImpl::CreateImageDataSimple(
159 PP_Instance instance
,
160 PP_ImageDataFormat format
,
162 PP_Bool init_to_zero
) {
163 return PPB_ImageData_Impl::Create(instance
,
164 ppapi::PPB_ImageData_Shared::SIMPLE
,
170 PP_Resource
ResourceCreationImpl::CreateIMEInputEvent(
171 PP_Instance instance
,
172 PP_InputEvent_Type type
,
173 PP_TimeTicks time_stamp
,
175 uint32_t segment_number
,
176 const uint32_t* segment_offsets
,
177 int32_t target_segment
,
178 uint32_t selection_start
,
179 uint32_t selection_end
) {
180 return PPB_InputEvent_Shared::CreateIMEInputEvent(ppapi::OBJECT_IS_IMPL
,
192 PP_Resource
ResourceCreationImpl::CreateKeyboardInputEvent_1_0(
193 PP_Instance instance
,
194 PP_InputEvent_Type type
,
195 PP_TimeTicks time_stamp
,
198 struct PP_Var character_text
) {
199 PP_Var code
= StringVar::StringToPPVar("");
200 return PPB_InputEvent_Shared::CreateKeyboardInputEvent(ppapi::OBJECT_IS_IMPL
,
210 PP_Resource
ResourceCreationImpl::CreateKeyboardInputEvent_1_2(
211 PP_Instance instance
,
212 PP_InputEvent_Type type
,
213 PP_TimeTicks time_stamp
,
216 struct PP_Var character_text
,
217 struct PP_Var code
) {
218 return PPB_InputEvent_Shared::CreateKeyboardInputEvent(ppapi::OBJECT_IS_IMPL
,
228 PP_Resource
ResourceCreationImpl::CreateMediaStreamVideoTrack(
229 PP_Instance instance
) {
230 return 0; // Not supported in-process.
233 PP_Resource
ResourceCreationImpl::CreateMouseInputEvent(
234 PP_Instance instance
,
235 PP_InputEvent_Type type
,
236 PP_TimeTicks time_stamp
,
238 PP_InputEvent_MouseButton mouse_button
,
239 const PP_Point
* mouse_position
,
241 const PP_Point
* mouse_movement
) {
242 return PPB_InputEvent_Shared::CreateMouseInputEvent(ppapi::OBJECT_IS_IMPL
,
253 PP_Resource
ResourceCreationImpl::CreateNetAddressFromIPv4Address(
254 PP_Instance instance
,
255 const PP_NetAddress_IPv4
* ipv4_addr
) {
256 return 0; // Not supported in-process.
259 PP_Resource
ResourceCreationImpl::CreateNetAddressFromIPv6Address(
260 PP_Instance instance
,
261 const PP_NetAddress_IPv6
* ipv6_addr
) {
262 return 0; // Not supported in-process.
265 PP_Resource
ResourceCreationImpl::CreateNetAddressFromNetAddressPrivate(
266 PP_Instance instance
,
267 const PP_NetAddress_Private
& private_addr
) {
268 return 0; // Not supported in-process.
271 PP_Resource
ResourceCreationImpl::CreateNetworkMonitor(PP_Instance instance
) {
272 return 0; // Not supported in-process.
275 PP_Resource
ResourceCreationImpl::CreateOutputProtectionPrivate(
276 PP_Instance instance
) {
277 return 0; // Not supported in-process.
280 PP_Resource
ResourceCreationImpl::CreatePlatformVerificationPrivate(
281 PP_Instance instance
) {
282 return 0; // Not supported in-process.
285 PP_Resource
ResourceCreationImpl::CreateScrollbar(PP_Instance instance
,
287 return PPB_Scrollbar_Impl::Create(instance
, PP_ToBool(vertical
));
290 PP_Resource
ResourceCreationImpl::CreateTalk(PP_Instance
/* instance */) {
291 return 0; // Not supported in-process.
294 PP_Resource
ResourceCreationImpl::CreateTCPServerSocketPrivate(
295 PP_Instance instance
) {
296 return 0; // Not supported in-process.
299 PP_Resource
ResourceCreationImpl::CreateTCPSocket1_0(PP_Instance instance
) {
300 return 0; // Not supported in-process.
303 PP_Resource
ResourceCreationImpl::CreateTCPSocket(PP_Instance instance
) {
304 return 0; // Not supported in-process.
307 PP_Resource
ResourceCreationImpl::CreateTCPSocketPrivate(PP_Instance instance
) {
308 return 0; // Not supported in-process.
311 PP_Resource
ResourceCreationImpl::CreateTouchInputEvent(PP_Instance instance
,
312 PP_InputEvent_Type type
,
313 PP_TimeTicks time_stamp
,
314 uint32_t modifiers
) {
315 return PPB_InputEvent_Shared::CreateTouchInputEvent(
316 ppapi::OBJECT_IS_IMPL
, instance
, type
, time_stamp
, modifiers
);
319 PP_Resource
ResourceCreationImpl::CreateUDPSocket(PP_Instance instance
) {
320 return 0; // Not supported in-process.
323 PP_Resource
ResourceCreationImpl::CreateUDPSocketPrivate(PP_Instance instance
) {
324 return 0; // Not supported in-process.
327 PP_Resource
ResourceCreationImpl::CreateVideoCapture(PP_Instance instance
) {
328 return 0; // Not supported in-process.
331 PP_Resource
ResourceCreationImpl::CreateVideoDecoder(PP_Instance instance
) {
332 return 0; // Not supported in-process.
335 PP_Resource
ResourceCreationImpl::CreateVideoDecoderDev(
336 PP_Instance instance
,
337 PP_Resource graphics3d_id
,
338 PP_VideoDecoder_Profile profile
) {
339 return PPB_VideoDecoder_Impl::Create(instance
, graphics3d_id
, profile
);
342 PP_Resource
ResourceCreationImpl::CreateVideoDestination(PP_Instance instance
) {
343 return 0; // Not supported in-process.
346 PP_Resource
ResourceCreationImpl::CreateVideoEncoder(PP_Instance instance
) {
347 return 0; // Not supported in-process.
350 PP_Resource
ResourceCreationImpl::CreateVideoSource(PP_Instance instance
) {
351 return 0; // Not supported in-process.
354 PP_Resource
ResourceCreationImpl::CreateWheelInputEvent(
355 PP_Instance instance
,
356 PP_TimeTicks time_stamp
,
358 const PP_FloatPoint
* wheel_delta
,
359 const PP_FloatPoint
* wheel_ticks
,
360 PP_Bool scroll_by_page
) {
361 return PPB_InputEvent_Shared::CreateWheelInputEvent(ppapi::OBJECT_IS_IMPL
,
370 PP_Resource
ResourceCreationImpl::CreateX509CertificatePrivate(
371 PP_Instance instance
) {
372 return 0; // Not supported in-process.
375 } // namespace content