| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "webkit/plugins/ppapi/plugin_module.h" | 5 #include "webkit/plugins/ppapi/plugin_module.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "ppapi/c/dev/ppb_file_ref_dev.h" | 26 #include "ppapi/c/dev/ppb_file_ref_dev.h" |
| 27 #include "ppapi/c/dev/ppb_file_system_dev.h" | 27 #include "ppapi/c/dev/ppb_file_system_dev.h" |
| 28 #include "ppapi/c/dev/ppb_find_dev.h" | 28 #include "ppapi/c/dev/ppb_find_dev.h" |
| 29 #include "ppapi/c/dev/ppb_font_dev.h" | 29 #include "ppapi/c/dev/ppb_font_dev.h" |
| 30 #include "ppapi/c/dev/ppb_fullscreen_dev.h" | 30 #include "ppapi/c/dev/ppb_fullscreen_dev.h" |
| 31 #include "ppapi/c/dev/ppb_gles_chromium_texture_mapping_dev.h" | 31 #include "ppapi/c/dev/ppb_gles_chromium_texture_mapping_dev.h" |
| 32 #include "ppapi/c/dev/ppb_graphics_3d_dev.h" | 32 #include "ppapi/c/dev/ppb_graphics_3d_dev.h" |
| 33 #include "ppapi/c/dev/ppb_layer_compositor_dev.h" | 33 #include "ppapi/c/dev/ppb_layer_compositor_dev.h" |
| 34 #include "ppapi/c/dev/ppb_opengles_dev.h" | 34 #include "ppapi/c/dev/ppb_opengles_dev.h" |
| 35 #include "ppapi/c/dev/ppb_scrollbar_dev.h" | 35 #include "ppapi/c/dev/ppb_scrollbar_dev.h" |
| 36 #include "ppapi/c/dev/ppb_surface_3d_dev.h" |
| 36 #include "ppapi/c/dev/ppb_testing_dev.h" | 37 #include "ppapi/c/dev/ppb_testing_dev.h" |
| 37 #include "ppapi/c/dev/ppb_transport_dev.h" | 38 #include "ppapi/c/dev/ppb_transport_dev.h" |
| 38 #include "ppapi/c/dev/ppb_url_util_dev.h" | 39 #include "ppapi/c/dev/ppb_url_util_dev.h" |
| 39 #include "ppapi/c/dev/ppb_var_deprecated.h" | 40 #include "ppapi/c/dev/ppb_var_deprecated.h" |
| 40 #include "ppapi/c/dev/ppb_video_decoder_dev.h" | 41 #include "ppapi/c/dev/ppb_video_decoder_dev.h" |
| 41 #include "ppapi/c/dev/ppb_video_layer_dev.h" | 42 #include "ppapi/c/dev/ppb_video_layer_dev.h" |
| 42 #include "ppapi/c/dev/ppb_widget_dev.h" | 43 #include "ppapi/c/dev/ppb_widget_dev.h" |
| 43 #include "ppapi/c/dev/ppb_zoom_dev.h" | 44 #include "ppapi/c/dev/ppb_zoom_dev.h" |
| 44 #include "ppapi/c/pp_module.h" | 45 #include "ppapi/c/pp_module.h" |
| 45 #include "ppapi/c/pp_resource.h" | 46 #include "ppapi/c/pp_resource.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 62 #include "ppapi/c/private/ppb_flash_file.h" | 63 #include "ppapi/c/private/ppb_flash_file.h" |
| 63 #include "ppapi/c/private/ppb_instance_private.h" | 64 #include "ppapi/c/private/ppb_instance_private.h" |
| 64 #include "ppapi/c/private/ppb_pdf.h" | 65 #include "ppapi/c/private/ppb_pdf.h" |
| 65 #include "ppapi/c/private/ppb_proxy_private.h" | 66 #include "ppapi/c/private/ppb_proxy_private.h" |
| 66 #include "ppapi/c/private/ppb_uma_private.h" | 67 #include "ppapi/c/private/ppb_uma_private.h" |
| 67 #include "ppapi/c/trusted/ppb_audio_trusted.h" | 68 #include "ppapi/c/trusted/ppb_audio_trusted.h" |
| 68 #include "ppapi/c/trusted/ppb_broker_trusted.h" | 69 #include "ppapi/c/trusted/ppb_broker_trusted.h" |
| 69 #include "ppapi/c/trusted/ppb_buffer_trusted.h" | 70 #include "ppapi/c/trusted/ppb_buffer_trusted.h" |
| 70 #include "ppapi/c/trusted/ppb_image_data_trusted.h" | 71 #include "ppapi/c/trusted/ppb_image_data_trusted.h" |
| 71 #include "ppapi/c/trusted/ppb_url_loader_trusted.h" | 72 #include "ppapi/c/trusted/ppb_url_loader_trusted.h" |
| 73 #include "ppapi/thunk/enter.h" |
| 72 #include "ppapi/thunk/thunk.h" | 74 #include "ppapi/thunk/thunk.h" |
| 73 #include "webkit/plugins/ppapi/callbacks.h" | 75 #include "webkit/plugins/ppapi/callbacks.h" |
| 74 #include "webkit/plugins/ppapi/common.h" | 76 #include "webkit/plugins/ppapi/common.h" |
| 75 #include "webkit/plugins/ppapi/ppapi_interface_factory.h" | 77 #include "webkit/plugins/ppapi/ppapi_interface_factory.h" |
| 76 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 78 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| 77 #include "webkit/plugins/ppapi/ppb_console_impl.h" | 79 #include "webkit/plugins/ppapi/ppb_console_impl.h" |
| 78 #include "webkit/plugins/ppapi/ppb_crypto_impl.h" | 80 #include "webkit/plugins/ppapi/ppb_crypto_impl.h" |
| 79 #include "webkit/plugins/ppapi/ppb_directory_reader_impl.h" | 81 #include "webkit/plugins/ppapi/ppb_directory_reader_impl.h" |
| 80 #include "webkit/plugins/ppapi/ppb_flash_clipboard_impl.h" | 82 #include "webkit/plugins/ppapi/ppb_flash_clipboard_impl.h" |
| 81 #include "webkit/plugins/ppapi/ppb_flash_file_impl.h" | 83 #include "webkit/plugins/ppapi/ppb_flash_file_impl.h" |
| 82 #include "webkit/plugins/ppapi/ppb_flash_impl.h" | 84 #include "webkit/plugins/ppapi/ppb_flash_impl.h" |
| 83 #include "webkit/plugins/ppapi/ppb_flash_menu_impl.h" | 85 #include "webkit/plugins/ppapi/ppb_flash_menu_impl.h" |
| 84 #include "webkit/plugins/ppapi/ppb_flash_net_connector_impl.h" | 86 #include "webkit/plugins/ppapi/ppb_flash_net_connector_impl.h" |
| 85 #include "webkit/plugins/ppapi/ppb_font_impl.h" | 87 #include "webkit/plugins/ppapi/ppb_font_impl.h" |
| 86 #include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h" | 88 #include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h" |
| 87 #include "webkit/plugins/ppapi/ppb_image_data_impl.h" | 89 #include "webkit/plugins/ppapi/ppb_image_data_impl.h" |
| 88 #include "webkit/plugins/ppapi/ppb_layer_compositor_impl.h" | 90 #include "webkit/plugins/ppapi/ppb_layer_compositor_impl.h" |
| 91 #include "webkit/plugins/ppapi/ppb_opengles_impl.h" |
| 89 #include "webkit/plugins/ppapi/ppb_proxy_impl.h" | 92 #include "webkit/plugins/ppapi/ppb_proxy_impl.h" |
| 90 #include "webkit/plugins/ppapi/ppb_scrollbar_impl.h" | 93 #include "webkit/plugins/ppapi/ppb_scrollbar_impl.h" |
| 91 #include "webkit/plugins/ppapi/ppb_transport_impl.h" | |
| 92 #include "webkit/plugins/ppapi/ppb_uma_private_impl.h" | 94 #include "webkit/plugins/ppapi/ppb_uma_private_impl.h" |
| 93 #include "webkit/plugins/ppapi/ppb_url_util_impl.h" | 95 #include "webkit/plugins/ppapi/ppb_url_util_impl.h" |
| 94 #include "webkit/plugins/ppapi/ppb_video_decoder_impl.h" | 96 #include "webkit/plugins/ppapi/ppb_video_decoder_impl.h" |
| 95 #include "webkit/plugins/ppapi/ppb_video_layer_impl.h" | 97 #include "webkit/plugins/ppapi/ppb_video_layer_impl.h" |
| 96 #include "webkit/plugins/ppapi/ppb_widget_impl.h" | |
| 97 #include "webkit/plugins/ppapi/resource_tracker.h" | 98 #include "webkit/plugins/ppapi/resource_tracker.h" |
| 98 #include "webkit/plugins/ppapi/var.h" | 99 #include "webkit/plugins/ppapi/var.h" |
| 99 #include "webkit/plugins/ppapi/webkit_forwarding_impl.h" | 100 #include "webkit/plugins/ppapi/webkit_forwarding_impl.h" |
| 100 | 101 |
| 101 #ifdef ENABLE_GPU | 102 using ppapi::thunk::EnterResource; |
| 102 #include "webkit/plugins/ppapi/ppb_context_3d_impl.h" | 103 using ppapi::thunk::PPB_Graphics2D_API; |
| 103 #include "webkit/plugins/ppapi/ppb_gles_chromium_texture_mapping_impl.h" | |
| 104 #include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h" | |
| 105 #include "webkit/plugins/ppapi/ppb_opengles_impl.h" | |
| 106 #include "webkit/plugins/ppapi/ppb_surface_3d_impl.h" | |
| 107 #endif // ENABLE_GPU | |
| 108 | 104 |
| 109 namespace webkit { | 105 namespace webkit { |
| 110 namespace ppapi { | 106 namespace ppapi { |
| 111 | 107 |
| 112 namespace { | 108 namespace { |
| 113 | 109 |
| 114 // Maintains all currently loaded plugin libs for validating PP_Module | 110 // Maintains all currently loaded plugin libs for validating PP_Module |
| 115 // identifiers. | 111 // identifiers. |
| 116 typedef std::set<PluginModule*> PluginModuleSet; | 112 typedef std::set<PluginModule*> PluginModuleSet; |
| 117 | 113 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 &GetTickTime, | 177 &GetTickTime, |
| 182 &CallOnMainThread, | 178 &CallOnMainThread, |
| 183 &IsMainThread | 179 &IsMainThread |
| 184 }; | 180 }; |
| 185 | 181 |
| 186 // PPB_Testing ----------------------------------------------------------------- | 182 // PPB_Testing ----------------------------------------------------------------- |
| 187 | 183 |
| 188 PP_Bool ReadImageData(PP_Resource device_context_2d, | 184 PP_Bool ReadImageData(PP_Resource device_context_2d, |
| 189 PP_Resource image, | 185 PP_Resource image, |
| 190 const PP_Point* top_left) { | 186 const PP_Point* top_left) { |
| 191 scoped_refptr<PPB_Graphics2D_Impl> context( | 187 EnterResource<PPB_Graphics2D_API> enter(device_context_2d, true); |
| 192 Resource::GetAs<PPB_Graphics2D_Impl>(device_context_2d)); | 188 if (enter.failed()) |
| 193 if (!context.get()) | |
| 194 return PP_FALSE; | 189 return PP_FALSE; |
| 195 return BoolToPPBool(context->ReadImageData(image, top_left)); | 190 return BoolToPPBool(static_cast<PPB_Graphics2D_Impl*>(enter.object())-> |
| 191 ReadImageData(image, top_left)); |
| 196 } | 192 } |
| 197 | 193 |
| 198 void RunMessageLoop(PP_Instance instance) { | 194 void RunMessageLoop(PP_Instance instance) { |
| 199 bool old_state = MessageLoop::current()->NestableTasksAllowed(); | 195 bool old_state = MessageLoop::current()->NestableTasksAllowed(); |
| 200 MessageLoop::current()->SetNestableTasksAllowed(true); | 196 MessageLoop::current()->SetNestableTasksAllowed(true); |
| 201 MessageLoop::current()->Run(); | 197 MessageLoop::current()->Run(); |
| 202 MessageLoop::current()->SetNestableTasksAllowed(old_state); | 198 MessageLoop::current()->SetNestableTasksAllowed(old_state); |
| 203 } | 199 } |
| 204 | 200 |
| 205 void QuitMessageLoop(PP_Instance instance) { | 201 void QuitMessageLoop(PP_Instance instance) { |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 return PPB_URLUtil_Impl::GetInterface(); | 318 return PPB_URLUtil_Impl::GetInterface(); |
| 323 if (strcmp(name, PPB_VAR_DEPRECATED_INTERFACE) == 0) | 319 if (strcmp(name, PPB_VAR_DEPRECATED_INTERFACE) == 0) |
| 324 return Var::GetDeprecatedInterface(); | 320 return Var::GetDeprecatedInterface(); |
| 325 if (strcmp(name, PPB_VAR_INTERFACE) == 0) | 321 if (strcmp(name, PPB_VAR_INTERFACE) == 0) |
| 326 return Var::GetInterface(); | 322 return Var::GetInterface(); |
| 327 if (strcmp(name, PPB_VIDEODECODER_DEV_INTERFACE) == 0) | 323 if (strcmp(name, PPB_VIDEODECODER_DEV_INTERFACE) == 0) |
| 328 return ::ppapi::thunk::GetPPB_VideoDecoder_Thunk(); | 324 return ::ppapi::thunk::GetPPB_VideoDecoder_Thunk(); |
| 329 if (strcmp(name, PPB_VIDEOLAYER_DEV_INTERFACE) == 0) | 325 if (strcmp(name, PPB_VIDEOLAYER_DEV_INTERFACE) == 0) |
| 330 return ::ppapi::thunk::GetPPB_VideoLayer_Thunk(); | 326 return ::ppapi::thunk::GetPPB_VideoLayer_Thunk(); |
| 331 if (strcmp(name, PPB_WIDGET_DEV_INTERFACE) == 0) | 327 if (strcmp(name, PPB_WIDGET_DEV_INTERFACE) == 0) |
| 332 return PPB_Widget_Impl::GetInterface(); | 328 return ::ppapi::thunk::GetPPB_Widget_Thunk(); |
| 333 if (strcmp(name, PPB_ZOOM_DEV_INTERFACE) == 0) | 329 if (strcmp(name, PPB_ZOOM_DEV_INTERFACE) == 0) |
| 334 return PluginInstance::GetZoomInterface(); | 330 return PluginInstance::GetZoomInterface(); |
| 335 | 331 |
| 336 #ifdef ENABLE_GPU | 332 #ifdef ENABLE_GPU |
| 337 // This should really refer to switches::kDisable3DAPIs. | 333 // This should really refer to switches::kDisable3DAPIs. |
| 338 if (!CommandLine::ForCurrentProcess()->HasSwitch("disable-3d-apis")) { | 334 if (!CommandLine::ForCurrentProcess()->HasSwitch("disable-3d-apis")) { |
| 339 if (strcmp(name, PPB_GRAPHICS_3D_DEV_INTERFACE) == 0) | 335 if (strcmp(name, PPB_GRAPHICS_3D_DEV_INTERFACE) == 0) |
| 340 return PPB_Graphics3D_Impl::GetInterface(); | 336 return ::ppapi::thunk::GetPPB_Graphics3D_Thunk(); |
| 341 if (strcmp(name, PPB_CONTEXT_3D_DEV_INTERFACE) == 0) | 337 if (strcmp(name, PPB_CONTEXT_3D_DEV_INTERFACE) == 0) |
| 342 return PPB_Context3D_Impl::GetInterface(); | 338 return ::ppapi::thunk::GetPPB_Context3D_Thunk(); |
| 343 if (strcmp(name, PPB_CONTEXT_3D_TRUSTED_DEV_INTERFACE) == 0) | 339 if (strcmp(name, PPB_CONTEXT_3D_TRUSTED_DEV_INTERFACE) == 0) |
| 344 return PPB_Context3D_Impl::GetTrustedInterface(); | 340 return ::ppapi::thunk::GetPPB_Context3DTrusted_Thunk(); |
| 345 if (strcmp(name, PPB_GLES_CHROMIUM_TEXTURE_MAPPING_DEV_INTERFACE) == 0) | 341 if (strcmp(name, PPB_GLES_CHROMIUM_TEXTURE_MAPPING_DEV_INTERFACE) == 0) |
| 346 return PPB_GLESChromiumTextureMapping_Impl::GetInterface(); | 342 return ::ppapi::thunk::GetPPB_GLESChromiumTextureMapping_Thunk(); |
| 347 if (strcmp(name, PPB_OPENGLES2_DEV_INTERFACE) == 0) | 343 if (strcmp(name, PPB_OPENGLES2_DEV_INTERFACE) == 0) |
| 348 return PPB_OpenGLES_Impl::GetInterface(); | 344 return PPB_OpenGLES_Impl::GetInterface(); |
| 349 if (strcmp(name, PPB_SURFACE_3D_DEV_INTERFACE) == 0) | 345 if (strcmp(name, PPB_SURFACE_3D_DEV_INTERFACE) == 0) |
| 350 return PPB_Surface3D_Impl::GetInterface(); | 346 return ::ppapi::thunk::GetPPB_Surface3D_Thunk(); |
| 351 if (strcmp(name, PPB_LAYER_COMPOSITOR_DEV_INTERFACE) == 0) | 347 if (strcmp(name, PPB_LAYER_COMPOSITOR_DEV_INTERFACE) == 0) |
| 352 return PPB_LayerCompositor_Impl::GetInterface(); | 348 return ::ppapi::thunk::GetPPB_LayerCompositor_Thunk(); |
| 353 } | 349 } |
| 354 #endif // ENABLE_GPU | 350 #endif // ENABLE_GPU |
| 355 | 351 |
| 356 #ifdef ENABLE_FLAPPER_HACKS | 352 #ifdef ENABLE_FLAPPER_HACKS |
| 357 if (strcmp(name, PPB_FLASH_NETCONNECTOR_INTERFACE) == 0) | 353 if (strcmp(name, PPB_FLASH_NETCONNECTOR_INTERFACE) == 0) |
| 358 return ::ppapi::thunk::GetPPB_Flash_NetConnector_Thunk(); | 354 return ::ppapi::thunk::GetPPB_Flash_NetConnector_Thunk(); |
| 359 #endif // ENABLE_FLAPPER_HACKS | 355 #endif // ENABLE_FLAPPER_HACKS |
| 360 | 356 |
| 361 #if defined(ENABLE_P2P_APIS) | 357 #if defined(ENABLE_P2P_APIS) |
| 362 if (strcmp(name, PPB_TRANSPORT_DEV_INTERFACE) == 0) | 358 if (strcmp(name, PPB_TRANSPORT_DEV_INTERFACE) == 0) |
| 363 return PPB_Transport_Impl::GetInterface(); | 359 return ::ppapi::thunk::GetPPB_Transport_Thunk(); |
| 364 #endif | 360 #endif |
| 365 | 361 |
| 366 // Only support the testing interface when the command line switch is | 362 // Only support the testing interface when the command line switch is |
| 367 // specified. This allows us to prevent people from (ab)using this interface | 363 // specified. This allows us to prevent people from (ab)using this interface |
| 368 // in production code. | 364 // in production code. |
| 369 if (strcmp(name, PPB_TESTING_DEV_INTERFACE) == 0) { | 365 if (strcmp(name, PPB_TESTING_DEV_INTERFACE) == 0) { |
| 370 if (CommandLine::ForCurrentProcess()->HasSwitch("enable-pepper-testing")) | 366 if (CommandLine::ForCurrentProcess()->HasSwitch("enable-pepper-testing")) |
| 371 return &testing_interface; | 367 return &testing_interface; |
| 372 } | 368 } |
| 373 return NULL; | 369 return NULL; |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 int retval = entry_points_.initialize_module(pp_module(), &GetInterface); | 588 int retval = entry_points_.initialize_module(pp_module(), &GetInterface); |
| 593 if (retval != 0) { | 589 if (retval != 0) { |
| 594 LOG(WARNING) << "PPP_InitializeModule returned failure " << retval; | 590 LOG(WARNING) << "PPP_InitializeModule returned failure " << retval; |
| 595 return false; | 591 return false; |
| 596 } | 592 } |
| 597 return true; | 593 return true; |
| 598 } | 594 } |
| 599 | 595 |
| 600 } // namespace ppapi | 596 } // namespace ppapi |
| 601 } // namespace webkit | 597 } // namespace webkit |
| OLD | NEW |