Re-subimission of https://codereview.chromium.org/1041213003/
[chromium-blink-merge.git] / content / renderer / pepper / resource_creation_impl.cc
blob94c7137512783bbd976e0faa5f756668b4f304e6
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"
25 #if defined(OS_WIN)
26 #include "base/command_line.h"
27 #include "base/win/windows_version.h"
28 #endif
30 using ppapi::InputEventData;
31 using ppapi::PPB_InputEvent_Shared;
32 using ppapi::StringVar;
34 namespace content {
36 ResourceCreationImpl::ResourceCreationImpl(PepperPluginInstanceImpl* instance) {
39 ResourceCreationImpl::~ResourceCreationImpl() {}
41 PP_Resource ResourceCreationImpl::CreateAudio1_0(
42 PP_Instance instance,
43 PP_Resource config_id,
44 PPB_Audio_Callback_1_0 audio_callback,
45 void* user_data) {
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,
52 void* user_data) {
53 return 0; // Not supported in-process.
56 PP_Resource ResourceCreationImpl::CreateAudioConfig(
57 PP_Instance instance,
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,
81 uint32_t size) {
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(
95 PP_Instance instance,
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,
138 const PP_Size* size,
139 PP_Bool init_to_zero) {
140 #if defined(OS_WIN)
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
144 // lockdown mode.
145 // TODO(ananta)
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);
150 #endif
151 return PPB_ImageData_Impl::Create(instance,
152 ppapi::PPB_ImageData_Shared::PLATFORM,
153 format,
154 *size,
155 init_to_zero);
158 PP_Resource ResourceCreationImpl::CreateImageDataSimple(
159 PP_Instance instance,
160 PP_ImageDataFormat format,
161 const PP_Size* size,
162 PP_Bool init_to_zero) {
163 return PPB_ImageData_Impl::Create(instance,
164 ppapi::PPB_ImageData_Shared::SIMPLE,
165 format,
166 *size,
167 init_to_zero);
170 PP_Resource ResourceCreationImpl::CreateIMEInputEvent(
171 PP_Instance instance,
172 PP_InputEvent_Type type,
173 PP_TimeTicks time_stamp,
174 struct PP_Var text,
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,
181 instance,
182 type,
183 time_stamp,
184 text,
185 segment_number,
186 segment_offsets,
187 target_segment,
188 selection_start,
189 selection_end);
192 PP_Resource ResourceCreationImpl::CreateKeyboardInputEvent_1_0(
193 PP_Instance instance,
194 PP_InputEvent_Type type,
195 PP_TimeTicks time_stamp,
196 uint32_t modifiers,
197 uint32_t key_code,
198 struct PP_Var character_text) {
199 PP_Var code = StringVar::StringToPPVar("");
200 return PPB_InputEvent_Shared::CreateKeyboardInputEvent(ppapi::OBJECT_IS_IMPL,
201 instance,
202 type,
203 time_stamp,
204 modifiers,
205 key_code,
206 character_text,
207 code);
210 PP_Resource ResourceCreationImpl::CreateKeyboardInputEvent_1_2(
211 PP_Instance instance,
212 PP_InputEvent_Type type,
213 PP_TimeTicks time_stamp,
214 uint32_t modifiers,
215 uint32_t key_code,
216 struct PP_Var character_text,
217 struct PP_Var code) {
218 return PPB_InputEvent_Shared::CreateKeyboardInputEvent(ppapi::OBJECT_IS_IMPL,
219 instance,
220 type,
221 time_stamp,
222 modifiers,
223 key_code,
224 character_text,
225 code);
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,
237 uint32_t modifiers,
238 PP_InputEvent_MouseButton mouse_button,
239 const PP_Point* mouse_position,
240 int32_t click_count,
241 const PP_Point* mouse_movement) {
242 return PPB_InputEvent_Shared::CreateMouseInputEvent(ppapi::OBJECT_IS_IMPL,
243 instance,
244 type,
245 time_stamp,
246 modifiers,
247 mouse_button,
248 mouse_position,
249 click_count,
250 mouse_movement);
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,
286 PP_Bool vertical) {
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,
357 uint32_t modifiers,
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,
362 instance,
363 time_stamp,
364 modifiers,
365 wheel_delta,
366 wheel_ticks,
367 scroll_by_page);
370 PP_Resource ResourceCreationImpl::CreateX509CertificatePrivate(
371 PP_Instance instance) {
372 return 0; // Not supported in-process.
375 } // namespace content