Roll src/third_party/skia 2440fcd:4de8c3a
[chromium-blink-merge.git] / content / renderer / pepper / resource_creation_impl.cc
blob929f8ad7b315e043136cf79cccc7debc37e9eb42
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"
24 #if defined(OS_WIN)
25 #include "base/command_line.h"
26 #include "base/win/windows_version.h"
27 #endif
29 using ppapi::InputEventData;
30 using ppapi::PPB_InputEvent_Shared;
31 using ppapi::StringVar;
33 namespace content {
35 ResourceCreationImpl::ResourceCreationImpl(PepperPluginInstanceImpl* instance) {
38 ResourceCreationImpl::~ResourceCreationImpl() {}
40 PP_Resource ResourceCreationImpl::CreateAudio1_0(
41 PP_Instance instance,
42 PP_Resource config_id,
43 PPB_Audio_Callback_1_0 audio_callback,
44 void* user_data) {
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,
51 void* user_data) {
52 return 0; // Not supported in-process.
55 PP_Resource ResourceCreationImpl::CreateAudioConfig(
56 PP_Instance instance,
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::CreateAudioEncoder(PP_Instance instance) {
68 return 0; // Not supported in-process.
71 PP_Resource ResourceCreationImpl::CreateAudioInput(PP_Instance instance) {
72 return 0; // Not supported in-process.
75 PP_Resource ResourceCreationImpl::CreateCompositor(PP_Instance instance) {
76 return 0; // Not supported in-process.
79 PP_Resource ResourceCreationImpl::CreateBroker(PP_Instance instance) {
80 return (new PPB_Broker_Impl(instance))->GetReference();
83 PP_Resource ResourceCreationImpl::CreateBuffer(PP_Instance instance,
84 uint32_t size) {
85 return PPB_Buffer_Impl::Create(instance, size);
88 PP_Resource ResourceCreationImpl::CreateCameraDevicePrivate(
89 PP_Instance instance) {
90 return 0; // Not supported in-process.
93 PP_Resource ResourceCreationImpl::CreateFlashDRM(PP_Instance instance) {
94 return 0; // Not supported in-process.
97 PP_Resource ResourceCreationImpl::CreateFlashFontFile(
98 PP_Instance instance,
99 const PP_BrowserFont_Trusted_Description* description,
100 PP_PrivateFontCharset charset) {
101 return 0; // Not supported in-process.
104 PP_Resource ResourceCreationImpl::CreateFlashMenu(
105 PP_Instance instance,
106 const PP_Flash_Menu* menu_data) {
107 return 0; // Not supported in-process.
110 PP_Resource ResourceCreationImpl::CreateFlashMessageLoop(PP_Instance instance) {
111 return PPB_Flash_MessageLoop_Impl::Create(instance);
114 PP_Resource ResourceCreationImpl::CreateGraphics3D(PP_Instance instance,
115 PP_Resource share_context,
116 const int32_t* attrib_list) {
117 return PPB_Graphics3D_Impl::Create(instance, share_context, attrib_list);
120 PP_Resource ResourceCreationImpl::CreateGraphics3DRaw(
121 PP_Instance instance,
122 PP_Resource share_context,
123 const int32_t* attrib_list,
124 gpu::Capabilities* capabilities,
125 base::SharedMemoryHandle* shared_state,
126 uint64_t* command_buffer_id) {
127 return PPB_Graphics3D_Impl::CreateRaw(instance, share_context, attrib_list,
128 capabilities, shared_state,
129 command_buffer_id);
132 PP_Resource ResourceCreationImpl::CreateHostResolver(PP_Instance instance) {
133 return 0; // Not supported in-process.
136 PP_Resource ResourceCreationImpl::CreateHostResolverPrivate(
137 PP_Instance instance) {
138 return 0; // Not supported in-process.
141 PP_Resource ResourceCreationImpl::CreateImageData(PP_Instance instance,
142 PP_ImageDataFormat format,
143 const PP_Size* size,
144 PP_Bool init_to_zero) {
145 #if defined(OS_WIN)
146 // If Win32K lockdown mitigations are enabled for Windows 8 and beyond,
147 // we use the SIMPLE image data type as the PLATFORM image data type
148 // calls GDI functions to create DIB sections etc which fail in Win32K
149 // lockdown mode.
150 // TODO(ananta)
151 // Look into whether this causes a loss of functionality. From cursory
152 // testing things seem to work well.
153 if (IsWin32kRendererLockdownEnabled())
154 return CreateImageDataSimple(instance, format, size, init_to_zero);
155 #endif
156 return PPB_ImageData_Impl::Create(instance,
157 ppapi::PPB_ImageData_Shared::PLATFORM,
158 format,
159 *size,
160 init_to_zero);
163 PP_Resource ResourceCreationImpl::CreateImageDataSimple(
164 PP_Instance instance,
165 PP_ImageDataFormat format,
166 const PP_Size* size,
167 PP_Bool init_to_zero) {
168 return PPB_ImageData_Impl::Create(instance,
169 ppapi::PPB_ImageData_Shared::SIMPLE,
170 format,
171 *size,
172 init_to_zero);
175 PP_Resource ResourceCreationImpl::CreateIMEInputEvent(
176 PP_Instance instance,
177 PP_InputEvent_Type type,
178 PP_TimeTicks time_stamp,
179 struct PP_Var text,
180 uint32_t segment_number,
181 const uint32_t* segment_offsets,
182 int32_t target_segment,
183 uint32_t selection_start,
184 uint32_t selection_end) {
185 return PPB_InputEvent_Shared::CreateIMEInputEvent(ppapi::OBJECT_IS_IMPL,
186 instance,
187 type,
188 time_stamp,
189 text,
190 segment_number,
191 segment_offsets,
192 target_segment,
193 selection_start,
194 selection_end);
197 PP_Resource ResourceCreationImpl::CreateKeyboardInputEvent_1_0(
198 PP_Instance instance,
199 PP_InputEvent_Type type,
200 PP_TimeTicks time_stamp,
201 uint32_t modifiers,
202 uint32_t key_code,
203 struct PP_Var character_text) {
204 PP_Var code = StringVar::StringToPPVar("");
205 return PPB_InputEvent_Shared::CreateKeyboardInputEvent(ppapi::OBJECT_IS_IMPL,
206 instance,
207 type,
208 time_stamp,
209 modifiers,
210 key_code,
211 character_text,
212 code);
215 PP_Resource ResourceCreationImpl::CreateKeyboardInputEvent_1_2(
216 PP_Instance instance,
217 PP_InputEvent_Type type,
218 PP_TimeTicks time_stamp,
219 uint32_t modifiers,
220 uint32_t key_code,
221 struct PP_Var character_text,
222 struct PP_Var code) {
223 return PPB_InputEvent_Shared::CreateKeyboardInputEvent(ppapi::OBJECT_IS_IMPL,
224 instance,
225 type,
226 time_stamp,
227 modifiers,
228 key_code,
229 character_text,
230 code);
233 PP_Resource ResourceCreationImpl::CreateMediaStreamVideoTrack(
234 PP_Instance instance) {
235 return 0; // Not supported in-process.
238 PP_Resource ResourceCreationImpl::CreateMouseInputEvent(
239 PP_Instance instance,
240 PP_InputEvent_Type type,
241 PP_TimeTicks time_stamp,
242 uint32_t modifiers,
243 PP_InputEvent_MouseButton mouse_button,
244 const PP_Point* mouse_position,
245 int32_t click_count,
246 const PP_Point* mouse_movement) {
247 return PPB_InputEvent_Shared::CreateMouseInputEvent(ppapi::OBJECT_IS_IMPL,
248 instance,
249 type,
250 time_stamp,
251 modifiers,
252 mouse_button,
253 mouse_position,
254 click_count,
255 mouse_movement);
258 PP_Resource ResourceCreationImpl::CreateNetAddressFromIPv4Address(
259 PP_Instance instance,
260 const PP_NetAddress_IPv4* ipv4_addr) {
261 return 0; // Not supported in-process.
264 PP_Resource ResourceCreationImpl::CreateNetAddressFromIPv6Address(
265 PP_Instance instance,
266 const PP_NetAddress_IPv6* ipv6_addr) {
267 return 0; // Not supported in-process.
270 PP_Resource ResourceCreationImpl::CreateNetAddressFromNetAddressPrivate(
271 PP_Instance instance,
272 const PP_NetAddress_Private& private_addr) {
273 return 0; // Not supported in-process.
276 PP_Resource ResourceCreationImpl::CreateNetworkMonitor(PP_Instance instance) {
277 return 0; // Not supported in-process.
280 PP_Resource ResourceCreationImpl::CreateOutputProtectionPrivate(
281 PP_Instance instance) {
282 return 0; // Not supported in-process.
285 PP_Resource ResourceCreationImpl::CreatePlatformVerificationPrivate(
286 PP_Instance instance) {
287 return 0; // Not supported in-process.
290 PP_Resource ResourceCreationImpl::CreateTCPServerSocketPrivate(
291 PP_Instance instance) {
292 return 0; // Not supported in-process.
295 PP_Resource ResourceCreationImpl::CreateTCPSocket1_0(PP_Instance instance) {
296 return 0; // Not supported in-process.
299 PP_Resource ResourceCreationImpl::CreateTCPSocket(PP_Instance instance) {
300 return 0; // Not supported in-process.
303 PP_Resource ResourceCreationImpl::CreateTCPSocketPrivate(PP_Instance instance) {
304 return 0; // Not supported in-process.
307 PP_Resource ResourceCreationImpl::CreateTouchInputEvent(PP_Instance instance,
308 PP_InputEvent_Type type,
309 PP_TimeTicks time_stamp,
310 uint32_t modifiers) {
311 return PPB_InputEvent_Shared::CreateTouchInputEvent(
312 ppapi::OBJECT_IS_IMPL, instance, type, time_stamp, modifiers);
315 PP_Resource ResourceCreationImpl::CreateUDPSocket(PP_Instance instance) {
316 return 0; // Not supported in-process.
319 PP_Resource ResourceCreationImpl::CreateUDPSocketPrivate(PP_Instance instance) {
320 return 0; // Not supported in-process.
323 PP_Resource ResourceCreationImpl::CreateVideoCapture(PP_Instance instance) {
324 return 0; // Not supported in-process.
327 PP_Resource ResourceCreationImpl::CreateVideoDecoder(PP_Instance instance) {
328 return 0; // Not supported in-process.
331 PP_Resource ResourceCreationImpl::CreateVideoDecoderDev(
332 PP_Instance instance,
333 PP_Resource graphics3d_id,
334 PP_VideoDecoder_Profile profile) {
335 return PPB_VideoDecoder_Impl::Create(instance, graphics3d_id, profile);
338 PP_Resource ResourceCreationImpl::CreateVideoDestination(PP_Instance instance) {
339 return 0; // Not supported in-process.
342 PP_Resource ResourceCreationImpl::CreateVideoEncoder(PP_Instance instance) {
343 return 0; // Not supported in-process.
346 PP_Resource ResourceCreationImpl::CreateVideoSource(PP_Instance instance) {
347 return 0; // Not supported in-process.
350 PP_Resource ResourceCreationImpl::CreateWheelInputEvent(
351 PP_Instance instance,
352 PP_TimeTicks time_stamp,
353 uint32_t modifiers,
354 const PP_FloatPoint* wheel_delta,
355 const PP_FloatPoint* wheel_ticks,
356 PP_Bool scroll_by_page) {
357 return PPB_InputEvent_Shared::CreateWheelInputEvent(ppapi::OBJECT_IS_IMPL,
358 instance,
359 time_stamp,
360 modifiers,
361 wheel_delta,
362 wheel_ticks,
363 scroll_by_page);
366 PP_Resource ResourceCreationImpl::CreateX509CertificatePrivate(
367 PP_Instance instance) {
368 return 0; // Not supported in-process.
371 } // namespace content