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_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"
25 #include "base/command_line.h"
26 #include "base/win/windows_version.h"
29 using ppapi::InputEventData
;
30 using ppapi::PPB_InputEvent_Shared
;
31 using ppapi::StringVar
;
35 ResourceCreationImpl::ResourceCreationImpl(PepperPluginInstanceImpl
* instance
) {
38 ResourceCreationImpl::~ResourceCreationImpl() {}
40 PP_Resource
ResourceCreationImpl::CreateAudio1_0(
42 PP_Resource config_id
,
43 PPB_Audio_Callback_1_0 audio_callback
,
45 return 0; // Not supported in-process.
48 PP_Resource
ResourceCreationImpl::CreateAudio(PP_Instance instance
,
49 PP_Resource config_id
,
50 PPB_Audio_Callback audio_callback
,
52 return 0; // Not supported in-process.
55 PP_Resource
ResourceCreationImpl::CreateAudioConfig(
57 PP_AudioSampleRate sample_rate
,
58 uint32_t sample_frame_count
) {
59 return ppapi::PPB_AudioConfig_Shared::Create(
60 ppapi::OBJECT_IS_IMPL
, instance
, sample_rate
, sample_frame_count
);
63 PP_Resource
ResourceCreationImpl::CreateAudioTrusted(PP_Instance instance
) {
64 return (new PPB_Audio_Impl(instance
))->GetReference();
67 PP_Resource
ResourceCreationImpl::CreateAudioInput(PP_Instance instance
) {
68 return 0; // Not supported in-process.
71 PP_Resource
ResourceCreationImpl::CreateCompositor(PP_Instance instance
) {
72 return 0; // Not supported in-process.
75 PP_Resource
ResourceCreationImpl::CreateBroker(PP_Instance instance
) {
76 return (new PPB_Broker_Impl(instance
))->GetReference();
79 PP_Resource
ResourceCreationImpl::CreateBuffer(PP_Instance instance
,
81 return PPB_Buffer_Impl::Create(instance
, size
);
84 PP_Resource
ResourceCreationImpl::CreateCameraDevicePrivate(
85 PP_Instance instance
) {
86 return 0; // Not supported in-process.
89 PP_Resource
ResourceCreationImpl::CreateFlashDRM(PP_Instance instance
) {
90 return 0; // Not supported in-process.
93 PP_Resource
ResourceCreationImpl::CreateFlashFontFile(
95 const PP_BrowserFont_Trusted_Description
* description
,
96 PP_PrivateFontCharset charset
) {
97 return 0; // Not supported in-process.
100 PP_Resource
ResourceCreationImpl::CreateFlashMenu(
101 PP_Instance instance
,
102 const PP_Flash_Menu
* menu_data
) {
103 return 0; // Not supported in-process.
106 PP_Resource
ResourceCreationImpl::CreateFlashMessageLoop(PP_Instance instance
) {
107 return PPB_Flash_MessageLoop_Impl::Create(instance
);
110 PP_Resource
ResourceCreationImpl::CreateGraphics3D(PP_Instance instance
,
111 PP_Resource share_context
,
112 const int32_t* attrib_list
) {
113 return PPB_Graphics3D_Impl::Create(instance
, share_context
, attrib_list
);
116 PP_Resource
ResourceCreationImpl::CreateGraphics3DRaw(
117 PP_Instance instance
,
118 PP_Resource share_context
,
119 const int32_t* attrib_list
,
120 gpu::Capabilities
* capabilities
,
121 base::SharedMemoryHandle
* shared_state
) {
122 return PPB_Graphics3D_Impl::CreateRaw(instance
, share_context
, attrib_list
,
123 capabilities
, shared_state
);
126 PP_Resource
ResourceCreationImpl::CreateHostResolver(PP_Instance instance
) {
127 return 0; // Not supported in-process.
130 PP_Resource
ResourceCreationImpl::CreateHostResolverPrivate(
131 PP_Instance instance
) {
132 return 0; // Not supported in-process.
135 PP_Resource
ResourceCreationImpl::CreateImageData(PP_Instance instance
,
136 PP_ImageDataFormat format
,
138 PP_Bool init_to_zero
) {
140 // If Win32K lockdown mitigations are enabled for Windows 8 and beyond,
141 // we use the SIMPLE image data type as the PLATFORM image data type
142 // calls GDI functions to create DIB sections etc which fail in Win32K
145 // Look into whether this causes a loss of functionality. From cursory
146 // testing things seem to work well.
147 if (IsWin32kRendererLockdownEnabled())
148 return CreateImageDataSimple(instance
, format
, size
, init_to_zero
);
150 return PPB_ImageData_Impl::Create(instance
,
151 ppapi::PPB_ImageData_Shared::PLATFORM
,
157 PP_Resource
ResourceCreationImpl::CreateImageDataSimple(
158 PP_Instance instance
,
159 PP_ImageDataFormat format
,
161 PP_Bool init_to_zero
) {
162 return PPB_ImageData_Impl::Create(instance
,
163 ppapi::PPB_ImageData_Shared::SIMPLE
,
169 PP_Resource
ResourceCreationImpl::CreateIMEInputEvent(
170 PP_Instance instance
,
171 PP_InputEvent_Type type
,
172 PP_TimeTicks time_stamp
,
174 uint32_t segment_number
,
175 const uint32_t* segment_offsets
,
176 int32_t target_segment
,
177 uint32_t selection_start
,
178 uint32_t selection_end
) {
179 return PPB_InputEvent_Shared::CreateIMEInputEvent(ppapi::OBJECT_IS_IMPL
,
191 PP_Resource
ResourceCreationImpl::CreateKeyboardInputEvent_1_0(
192 PP_Instance instance
,
193 PP_InputEvent_Type type
,
194 PP_TimeTicks time_stamp
,
197 struct PP_Var character_text
) {
198 PP_Var code
= StringVar::StringToPPVar("");
199 return PPB_InputEvent_Shared::CreateKeyboardInputEvent(ppapi::OBJECT_IS_IMPL
,
209 PP_Resource
ResourceCreationImpl::CreateKeyboardInputEvent_1_2(
210 PP_Instance instance
,
211 PP_InputEvent_Type type
,
212 PP_TimeTicks time_stamp
,
215 struct PP_Var character_text
,
216 struct PP_Var code
) {
217 return PPB_InputEvent_Shared::CreateKeyboardInputEvent(ppapi::OBJECT_IS_IMPL
,
227 PP_Resource
ResourceCreationImpl::CreateMediaStreamVideoTrack(
228 PP_Instance instance
) {
229 return 0; // Not supported in-process.
232 PP_Resource
ResourceCreationImpl::CreateMouseInputEvent(
233 PP_Instance instance
,
234 PP_InputEvent_Type type
,
235 PP_TimeTicks time_stamp
,
237 PP_InputEvent_MouseButton mouse_button
,
238 const PP_Point
* mouse_position
,
240 const PP_Point
* mouse_movement
) {
241 return PPB_InputEvent_Shared::CreateMouseInputEvent(ppapi::OBJECT_IS_IMPL
,
252 PP_Resource
ResourceCreationImpl::CreateNetAddressFromIPv4Address(
253 PP_Instance instance
,
254 const PP_NetAddress_IPv4
* ipv4_addr
) {
255 return 0; // Not supported in-process.
258 PP_Resource
ResourceCreationImpl::CreateNetAddressFromIPv6Address(
259 PP_Instance instance
,
260 const PP_NetAddress_IPv6
* ipv6_addr
) {
261 return 0; // Not supported in-process.
264 PP_Resource
ResourceCreationImpl::CreateNetAddressFromNetAddressPrivate(
265 PP_Instance instance
,
266 const PP_NetAddress_Private
& private_addr
) {
267 return 0; // Not supported in-process.
270 PP_Resource
ResourceCreationImpl::CreateNetworkMonitor(PP_Instance instance
) {
271 return 0; // Not supported in-process.
274 PP_Resource
ResourceCreationImpl::CreateOutputProtectionPrivate(
275 PP_Instance instance
) {
276 return 0; // Not supported in-process.
279 PP_Resource
ResourceCreationImpl::CreatePlatformVerificationPrivate(
280 PP_Instance instance
) {
281 return 0; // Not supported in-process.
284 PP_Resource
ResourceCreationImpl::CreateTCPServerSocketPrivate(
285 PP_Instance instance
) {
286 return 0; // Not supported in-process.
289 PP_Resource
ResourceCreationImpl::CreateTCPSocket1_0(PP_Instance instance
) {
290 return 0; // Not supported in-process.
293 PP_Resource
ResourceCreationImpl::CreateTCPSocket(PP_Instance instance
) {
294 return 0; // Not supported in-process.
297 PP_Resource
ResourceCreationImpl::CreateTCPSocketPrivate(PP_Instance instance
) {
298 return 0; // Not supported in-process.
301 PP_Resource
ResourceCreationImpl::CreateTouchInputEvent(PP_Instance instance
,
302 PP_InputEvent_Type type
,
303 PP_TimeTicks time_stamp
,
304 uint32_t modifiers
) {
305 return PPB_InputEvent_Shared::CreateTouchInputEvent(
306 ppapi::OBJECT_IS_IMPL
, instance
, type
, time_stamp
, modifiers
);
309 PP_Resource
ResourceCreationImpl::CreateUDPSocket(PP_Instance instance
) {
310 return 0; // Not supported in-process.
313 PP_Resource
ResourceCreationImpl::CreateUDPSocketPrivate(PP_Instance instance
) {
314 return 0; // Not supported in-process.
317 PP_Resource
ResourceCreationImpl::CreateVideoCapture(PP_Instance instance
) {
318 return 0; // Not supported in-process.
321 PP_Resource
ResourceCreationImpl::CreateVideoDecoder(PP_Instance instance
) {
322 return 0; // Not supported in-process.
325 PP_Resource
ResourceCreationImpl::CreateVideoDecoderDev(
326 PP_Instance instance
,
327 PP_Resource graphics3d_id
,
328 PP_VideoDecoder_Profile profile
) {
329 return PPB_VideoDecoder_Impl::Create(instance
, graphics3d_id
, profile
);
332 PP_Resource
ResourceCreationImpl::CreateVideoDestination(PP_Instance instance
) {
333 return 0; // Not supported in-process.
336 PP_Resource
ResourceCreationImpl::CreateVideoEncoder(PP_Instance instance
) {
337 return 0; // Not supported in-process.
340 PP_Resource
ResourceCreationImpl::CreateVideoSource(PP_Instance instance
) {
341 return 0; // Not supported in-process.
344 PP_Resource
ResourceCreationImpl::CreateWheelInputEvent(
345 PP_Instance instance
,
346 PP_TimeTicks time_stamp
,
348 const PP_FloatPoint
* wheel_delta
,
349 const PP_FloatPoint
* wheel_ticks
,
350 PP_Bool scroll_by_page
) {
351 return PPB_InputEvent_Shared::CreateWheelInputEvent(ppapi::OBJECT_IS_IMPL
,
360 PP_Resource
ResourceCreationImpl::CreateX509CertificatePrivate(
361 PP_Instance instance
) {
362 return 0; // Not supported in-process.
365 } // namespace content