[ServiceWorker] Implement WebServiceWorkerContextClient::openWindow().
[chromium-blink-merge.git] / content / renderer / pepper / resource_creation_impl.cc
blobb5eaa51d9cc5eafcf26b20f07c1ac870d513f42d
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::CreateFlashDRM(PP_Instance instance) {
86 return 0; // Not supported in-process.
89 PP_Resource ResourceCreationImpl::CreateFlashFontFile(
90 PP_Instance instance,
91 const PP_BrowserFont_Trusted_Description* description,
92 PP_PrivateFontCharset charset) {
93 return 0; // Not supported in-process.
96 PP_Resource ResourceCreationImpl::CreateFlashMenu(
97 PP_Instance instance,
98 const PP_Flash_Menu* menu_data) {
99 return 0; // Not supported in-process.
102 PP_Resource ResourceCreationImpl::CreateFlashMessageLoop(PP_Instance instance) {
103 return PPB_Flash_MessageLoop_Impl::Create(instance);
106 PP_Resource ResourceCreationImpl::CreateGraphics3D(PP_Instance instance,
107 PP_Resource share_context,
108 const int32_t* attrib_list) {
109 return PPB_Graphics3D_Impl::Create(instance, share_context, attrib_list);
112 PP_Resource ResourceCreationImpl::CreateGraphics3DRaw(
113 PP_Instance instance,
114 PP_Resource share_context,
115 const int32_t* attrib_list,
116 gpu::Capabilities* capabilities,
117 base::SharedMemoryHandle* shared_state) {
118 return PPB_Graphics3D_Impl::CreateRaw(instance, share_context, attrib_list,
119 capabilities, shared_state);
122 PP_Resource ResourceCreationImpl::CreateHostResolver(PP_Instance instance) {
123 return 0; // Not supported in-process.
126 PP_Resource ResourceCreationImpl::CreateHostResolverPrivate(
127 PP_Instance instance) {
128 return 0; // Not supported in-process.
131 PP_Resource ResourceCreationImpl::CreateImageData(PP_Instance instance,
132 PP_ImageDataFormat format,
133 const PP_Size* size,
134 PP_Bool init_to_zero) {
135 #if defined(OS_WIN)
136 // If Win32K lockdown mitigations are enabled for Windows 8 and beyond,
137 // we use the SIMPLE image data type as the PLATFORM image data type
138 // calls GDI functions to create DIB sections etc which fail in Win32K
139 // lockdown mode.
140 // TODO(ananta)
141 // Look into whether this causes a loss of functionality. From cursory
142 // testing things seem to work well.
143 if (IsWin32kRendererLockdownEnabled())
144 return CreateImageDataSimple(instance, format, size, init_to_zero);
145 #endif
146 return PPB_ImageData_Impl::Create(instance,
147 ppapi::PPB_ImageData_Shared::PLATFORM,
148 format,
149 *size,
150 init_to_zero);
153 PP_Resource ResourceCreationImpl::CreateImageDataSimple(
154 PP_Instance instance,
155 PP_ImageDataFormat format,
156 const PP_Size* size,
157 PP_Bool init_to_zero) {
158 return PPB_ImageData_Impl::Create(instance,
159 ppapi::PPB_ImageData_Shared::SIMPLE,
160 format,
161 *size,
162 init_to_zero);
165 PP_Resource ResourceCreationImpl::CreateIMEInputEvent(
166 PP_Instance instance,
167 PP_InputEvent_Type type,
168 PP_TimeTicks time_stamp,
169 struct PP_Var text,
170 uint32_t segment_number,
171 const uint32_t* segment_offsets,
172 int32_t target_segment,
173 uint32_t selection_start,
174 uint32_t selection_end) {
175 return PPB_InputEvent_Shared::CreateIMEInputEvent(ppapi::OBJECT_IS_IMPL,
176 instance,
177 type,
178 time_stamp,
179 text,
180 segment_number,
181 segment_offsets,
182 target_segment,
183 selection_start,
184 selection_end);
187 PP_Resource ResourceCreationImpl::CreateKeyboardInputEvent_1_0(
188 PP_Instance instance,
189 PP_InputEvent_Type type,
190 PP_TimeTicks time_stamp,
191 uint32_t modifiers,
192 uint32_t key_code,
193 struct PP_Var character_text) {
194 PP_Var code = StringVar::StringToPPVar("");
195 return PPB_InputEvent_Shared::CreateKeyboardInputEvent(ppapi::OBJECT_IS_IMPL,
196 instance,
197 type,
198 time_stamp,
199 modifiers,
200 key_code,
201 character_text,
202 code);
205 PP_Resource ResourceCreationImpl::CreateKeyboardInputEvent_1_2(
206 PP_Instance instance,
207 PP_InputEvent_Type type,
208 PP_TimeTicks time_stamp,
209 uint32_t modifiers,
210 uint32_t key_code,
211 struct PP_Var character_text,
212 struct PP_Var code) {
213 return PPB_InputEvent_Shared::CreateKeyboardInputEvent(ppapi::OBJECT_IS_IMPL,
214 instance,
215 type,
216 time_stamp,
217 modifiers,
218 key_code,
219 character_text,
220 code);
223 PP_Resource ResourceCreationImpl::CreateMediaStreamVideoTrack(
224 PP_Instance instance) {
225 return 0; // Not supported in-process.
228 PP_Resource ResourceCreationImpl::CreateMouseInputEvent(
229 PP_Instance instance,
230 PP_InputEvent_Type type,
231 PP_TimeTicks time_stamp,
232 uint32_t modifiers,
233 PP_InputEvent_MouseButton mouse_button,
234 const PP_Point* mouse_position,
235 int32_t click_count,
236 const PP_Point* mouse_movement) {
237 return PPB_InputEvent_Shared::CreateMouseInputEvent(ppapi::OBJECT_IS_IMPL,
238 instance,
239 type,
240 time_stamp,
241 modifiers,
242 mouse_button,
243 mouse_position,
244 click_count,
245 mouse_movement);
248 PP_Resource ResourceCreationImpl::CreateNetAddressFromIPv4Address(
249 PP_Instance instance,
250 const PP_NetAddress_IPv4* ipv4_addr) {
251 return 0; // Not supported in-process.
254 PP_Resource ResourceCreationImpl::CreateNetAddressFromIPv6Address(
255 PP_Instance instance,
256 const PP_NetAddress_IPv6* ipv6_addr) {
257 return 0; // Not supported in-process.
260 PP_Resource ResourceCreationImpl::CreateNetAddressFromNetAddressPrivate(
261 PP_Instance instance,
262 const PP_NetAddress_Private& private_addr) {
263 return 0; // Not supported in-process.
266 PP_Resource ResourceCreationImpl::CreateNetworkMonitor(PP_Instance instance) {
267 return 0; // Not supported in-process.
270 PP_Resource ResourceCreationImpl::CreateOutputProtectionPrivate(
271 PP_Instance instance) {
272 return 0; // Not supported in-process.
275 PP_Resource ResourceCreationImpl::CreatePlatformVerificationPrivate(
276 PP_Instance instance) {
277 return 0; // Not supported in-process.
280 PP_Resource ResourceCreationImpl::CreateScrollbar(PP_Instance instance,
281 PP_Bool vertical) {
282 return PPB_Scrollbar_Impl::Create(instance, PP_ToBool(vertical));
285 PP_Resource ResourceCreationImpl::CreateTalk(PP_Instance /* instance */) {
286 return 0; // Not supported in-process.
289 PP_Resource ResourceCreationImpl::CreateTCPServerSocketPrivate(
290 PP_Instance instance) {
291 return 0; // Not supported in-process.
294 PP_Resource ResourceCreationImpl::CreateTCPSocket1_0(PP_Instance instance) {
295 return 0; // Not supported in-process.
298 PP_Resource ResourceCreationImpl::CreateTCPSocket(PP_Instance instance) {
299 return 0; // Not supported in-process.
302 PP_Resource ResourceCreationImpl::CreateTCPSocketPrivate(PP_Instance instance) {
303 return 0; // Not supported in-process.
306 PP_Resource ResourceCreationImpl::CreateTouchInputEvent(PP_Instance instance,
307 PP_InputEvent_Type type,
308 PP_TimeTicks time_stamp,
309 uint32_t modifiers) {
310 return PPB_InputEvent_Shared::CreateTouchInputEvent(
311 ppapi::OBJECT_IS_IMPL, instance, type, time_stamp, modifiers);
314 PP_Resource ResourceCreationImpl::CreateUDPSocket(PP_Instance instance) {
315 return 0; // Not supported in-process.
318 PP_Resource ResourceCreationImpl::CreateUDPSocketPrivate(PP_Instance instance) {
319 return 0; // Not supported in-process.
322 PP_Resource ResourceCreationImpl::CreateVideoCapture(PP_Instance instance) {
323 return 0; // Not supported in-process.
326 PP_Resource ResourceCreationImpl::CreateVideoDecoder(PP_Instance instance) {
327 return 0; // Not supported in-process.
330 PP_Resource ResourceCreationImpl::CreateVideoDecoderDev(
331 PP_Instance instance,
332 PP_Resource graphics3d_id,
333 PP_VideoDecoder_Profile profile) {
334 return PPB_VideoDecoder_Impl::Create(instance, graphics3d_id, profile);
337 PP_Resource ResourceCreationImpl::CreateVideoDestination(PP_Instance instance) {
338 return 0; // Not supported in-process.
341 PP_Resource ResourceCreationImpl::CreateVideoSource(PP_Instance instance) {
342 return 0; // Not supported in-process.
345 PP_Resource ResourceCreationImpl::CreateWheelInputEvent(
346 PP_Instance instance,
347 PP_TimeTicks time_stamp,
348 uint32_t modifiers,
349 const PP_FloatPoint* wheel_delta,
350 const PP_FloatPoint* wheel_ticks,
351 PP_Bool scroll_by_page) {
352 return PPB_InputEvent_Shared::CreateWheelInputEvent(ppapi::OBJECT_IS_IMPL,
353 instance,
354 time_stamp,
355 modifiers,
356 wheel_delta,
357 wheel_ticks,
358 scroll_by_page);
361 PP_Resource ResourceCreationImpl::CreateX509CertificatePrivate(
362 PP_Instance instance) {
363 return 0; // Not supported in-process.
366 } // namespace content