Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(378)

Side by Side Diff: webkit/plugins/ppapi/plugin_module.cc

Issue 5828003: Move the Pepper implementation from webkit/glue/plugins/pepper_* to... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/glue/plugins/pepper_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"
11 #include "base/message_loop_proxy.h" 11 #include "base/message_loop_proxy.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/scoped_ptr.h" 13 #include "base/scoped_ptr.h"
14 #include "base/time.h" 14 #include "base/time.h"
15 #include "ppapi/c/dev/ppb_buffer_dev.h" 15 #include "ppapi/c/dev/ppb_buffer_dev.h"
(...skipping 25 matching lines...) Expand all
41 #include "ppapi/c/ppb_image_data.h" 41 #include "ppapi/c/ppb_image_data.h"
42 #include "ppapi/c/ppb_instance.h" 42 #include "ppapi/c/ppb_instance.h"
43 #include "ppapi/c/ppb_url_loader.h" 43 #include "ppapi/c/ppb_url_loader.h"
44 #include "ppapi/c/ppb_url_request_info.h" 44 #include "ppapi/c/ppb_url_request_info.h"
45 #include "ppapi/c/ppb_url_response_info.h" 45 #include "ppapi/c/ppb_url_response_info.h"
46 #include "ppapi/c/ppb_var.h" 46 #include "ppapi/c/ppb_var.h"
47 #include "ppapi/c/ppp.h" 47 #include "ppapi/c/ppp.h"
48 #include "ppapi/c/ppp_instance.h" 48 #include "ppapi/c/ppp_instance.h"
49 #include "ppapi/c/trusted/ppb_image_data_trusted.h" 49 #include "ppapi/c/trusted/ppb_image_data_trusted.h"
50 #include "ppapi/c/trusted/ppb_url_loader_trusted.h" 50 #include "ppapi/c/trusted/ppb_url_loader_trusted.h"
51 #include "webkit/glue/plugins/pepper_audio.h" 51 #include "webkit/plugins/ppapi/common.h"
52 #include "webkit/glue/plugins/pepper_buffer.h" 52 #include "webkit/plugins/ppapi/plugin_instance.h"
53 #include "webkit/glue/plugins/pepper_common.h" 53 #include "webkit/plugins/ppapi/plugin_object.h"
54 #include "webkit/glue/plugins/pepper_char_set.h" 54 #include "webkit/plugins/ppapi/ppb_audio_impl.h"
55 #include "webkit/glue/plugins/pepper_class.h" 55 #include "webkit/plugins/ppapi/ppb_buffer_impl.h"
56 #include "webkit/glue/plugins/pepper_cursor_control.h" 56 #include "webkit/plugins/ppapi/ppb_char_set_impl.h"
57 #include "webkit/glue/plugins/pepper_directory_reader.h" 57 #include "webkit/plugins/ppapi/ppb_cursor_control_impl.h"
58 #include "webkit/glue/plugins/pepper_file_chooser.h" 58 #include "webkit/plugins/ppapi/ppb_directory_reader_impl.h"
59 #include "webkit/glue/plugins/pepper_file_io.h" 59 #include "webkit/plugins/ppapi/ppb_file_chooser_impl.h"
60 #include "webkit/glue/plugins/pepper_file_ref.h" 60 #include "webkit/plugins/ppapi/ppb_file_io_impl.h"
61 #include "webkit/glue/plugins/pepper_file_system.h" 61 #include "webkit/plugins/ppapi/ppb_file_ref_impl.h"
62 #include "webkit/glue/plugins/pepper_font.h" 62 #include "webkit/plugins/ppapi/ppb_file_system_impl.h"
63 #include "webkit/glue/plugins/pepper_graphics_2d.h" 63 #include "webkit/plugins/ppapi/ppb_flash.h"
64 #include "webkit/glue/plugins/pepper_image_data.h" 64 #include "webkit/plugins/ppapi/ppb_flash_impl.h"
65 #include "webkit/glue/plugins/pepper_plugin_instance.h" 65 #include "webkit/plugins/ppapi/ppb_font_impl.h"
66 #include "webkit/glue/plugins/pepper_plugin_object.h" 66 #include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h"
67 #include "webkit/glue/plugins/pepper_private.h" 67 #include "webkit/plugins/ppapi/ppb_image_data_impl.h"
68 #include "webkit/glue/plugins/pepper_private2.h" 68 #include "webkit/plugins/ppapi/ppb_pdf.h"
69 #include "webkit/glue/plugins/pepper_resource_tracker.h" 69 #include "webkit/plugins/ppapi/ppb_pdf_impl.h"
70 #include "webkit/glue/plugins/pepper_scrollbar.h" 70 #include "webkit/plugins/ppapi/ppb_scrollbar_impl.h"
71 #include "webkit/glue/plugins/pepper_transport.h" 71 #include "webkit/plugins/ppapi/ppb_transport_impl.h"
72 #include "webkit/glue/plugins/pepper_url_loader.h" 72 #include "webkit/plugins/ppapi/ppb_url_loader_impl.h"
73 #include "webkit/glue/plugins/pepper_url_request_info.h" 73 #include "webkit/plugins/ppapi/ppb_url_request_info_impl.h"
74 #include "webkit/glue/plugins/pepper_url_response_info.h" 74 #include "webkit/plugins/ppapi/ppb_url_response_info_impl.h"
75 #include "webkit/glue/plugins/pepper_url_util.h" 75 #include "webkit/plugins/ppapi/ppb_url_util_impl.h"
76 #include "webkit/glue/plugins/pepper_var.h" 76 #include "webkit/plugins/ppapi/ppb_video_decoder_impl.h"
77 #include "webkit/glue/plugins/pepper_video_decoder.h" 77 #include "webkit/plugins/ppapi/ppb_widget_impl.h"
78 #include "webkit/glue/plugins/pepper_widget.h" 78 #include "webkit/plugins/ppapi/resource_tracker.h"
79 #include "webkit/glue/plugins/ppb_private.h" 79 #include "webkit/plugins/ppapi/var.h"
80 #include "webkit/glue/plugins/ppb_private2.h" 80 #include "webkit/plugins/ppapi/var_object_class.h"
81 81
82 #ifdef ENABLE_GPU 82 #ifdef ENABLE_GPU
83 #include "webkit/glue/plugins/pepper_graphics_3d.h" 83 #include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h"
84 #endif // ENABLE_GPU 84 #endif // ENABLE_GPU
85 85
86 namespace pepper { 86 namespace webkit {
87 namespace plugins {
88 namespace ppapi {
87 89
88 namespace { 90 namespace {
89 91
90 // Maintains all currently loaded plugin libs for validating PP_Module 92 // Maintains all currently loaded plugin libs for validating PP_Module
91 // identifiers. 93 // identifiers.
92 typedef std::set<PluginModule*> PluginModuleSet; 94 typedef std::set<PluginModule*> PluginModuleSet;
93 95
94 PluginModuleSet* GetLivePluginSet() { 96 PluginModuleSet* GetLivePluginSet() {
95 static PluginModuleSet live_plugin_libs; 97 static PluginModuleSet live_plugin_libs;
96 return &live_plugin_libs; 98 return &live_plugin_libs;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 &MemFree, 157 &MemFree,
156 &GetTime, 158 &GetTime,
157 &GetTickTime, 159 &GetTickTime,
158 &CallOnMainThread, 160 &CallOnMainThread,
159 &IsMainThread 161 &IsMainThread
160 }; 162 };
161 163
162 // PPB_Testing ----------------------------------------------------------------- 164 // PPB_Testing -----------------------------------------------------------------
163 165
164 PP_Bool ReadImageData(PP_Resource device_context_2d, 166 PP_Bool ReadImageData(PP_Resource device_context_2d,
165 PP_Resource image, 167 PP_Resource image,
166 const PP_Point* top_left) { 168 const PP_Point* top_left) {
167 scoped_refptr<Graphics2D> context( 169 scoped_refptr<PPB_Graphics2D_Impl> context(
168 Resource::GetAs<Graphics2D>(device_context_2d)); 170 Resource::GetAs<PPB_Graphics2D_Impl>(device_context_2d));
169 if (!context.get()) 171 if (!context.get())
170 return PP_FALSE; 172 return PP_FALSE;
171 return BoolToPPBool(context->ReadImageData(image, top_left)); 173 return BoolToPPBool(context->ReadImageData(image, top_left));
172 } 174 }
173 175
174 void RunMessageLoop() { 176 void RunMessageLoop() {
175 bool old_state = MessageLoop::current()->NestableTasksAllowed(); 177 bool old_state = MessageLoop::current()->NestableTasksAllowed();
176 MessageLoop::current()->SetNestableTasksAllowed(true); 178 MessageLoop::current()->SetNestableTasksAllowed(true);
177 MessageLoop::current()->Run(); 179 MessageLoop::current()->Run();
178 MessageLoop::current()->SetNestableTasksAllowed(old_state); 180 MessageLoop::current()->SetNestableTasksAllowed(old_state);
(...skipping 13 matching lines...) Expand all
192 const PPB_Testing_Dev testing_interface = { 194 const PPB_Testing_Dev testing_interface = {
193 &ReadImageData, 195 &ReadImageData,
194 &RunMessageLoop, 196 &RunMessageLoop,
195 &QuitMessageLoop, 197 &QuitMessageLoop,
196 &GetLiveObjectCount 198 &GetLiveObjectCount
197 }; 199 };
198 200
199 // GetInterface ---------------------------------------------------------------- 201 // GetInterface ----------------------------------------------------------------
200 202
201 const void* GetInterface(const char* name) { 203 const void* GetInterface(const char* name) {
204 // Please keep alphabetized by interface macro name with "special" stuff at
205 // the bottom.
206 if (strcmp(name, PPB_AUDIO_CONFIG_DEV_INTERFACE) == 0)
207 return PPB_AudioConfig_Impl::GetInterface();
208 if (strcmp(name, PPB_AUDIO_DEV_INTERFACE) == 0)
209 return PPB_Audio_Impl::GetInterface();
210 if (strcmp(name, PPB_AUDIO_TRUSTED_DEV_INTERFACE) == 0)
211 return PPB_Audio_Impl::GetTrustedInterface();
212 if (strcmp(name, PPB_BUFFER_DEV_INTERFACE) == 0)
213 return PPB_Buffer_Impl::GetInterface();
214 if (strcmp(name, PPB_CHAR_SET_DEV_INTERFACE) == 0)
215 return PPB_CharSet_Impl::GetInterface();
216 if (strcmp(name, PPB_CLASS_INTERFACE) == 0)
217 return VarObjectClass::GetInterface();
202 if (strcmp(name, PPB_CORE_INTERFACE) == 0) 218 if (strcmp(name, PPB_CORE_INTERFACE) == 0)
203 return &core_interface; 219 return &core_interface;
220 if (strcmp(name, PPB_CURSOR_CONTROL_DEV_INTERFACE) == 0)
221 return GetCursorControlInterface();
222 if (strcmp(name, PPB_DIRECTORYREADER_DEV_INTERFACE) == 0)
223 return PPB_DirectoryReader_Impl::GetInterface();
224 if (strcmp(name, PPB_FILECHOOSER_DEV_INTERFACE) == 0)
225 return PPB_FileChooser_Impl::GetInterface();
226 if (strcmp(name, PPB_FILEIO_DEV_INTERFACE) == 0)
227 return PPB_FileIO_Impl::GetInterface();
228 if (strcmp(name, PPB_FILEIOTRUSTED_DEV_INTERFACE) == 0)
229 return PPB_FileIO_Impl::GetTrustedInterface();
230 if (strcmp(name, PPB_FILEREF_DEV_INTERFACE) == 0)
231 return PPB_FileRef_Impl::GetInterface();
232 if (strcmp(name, PPB_FILESYSTEM_DEV_INTERFACE) == 0)
233 return PPB_FileSystem_Impl::GetInterface();
234 if (strcmp(name, PPB_FIND_DEV_INTERFACE) == 0)
235 return PluginInstance::GetFindInterface();
236 if (strcmp(name, PPB_FLASH_INTERFACE) == 0)
237 return PPB_Flash_Impl::GetInterface();
238 if (strcmp(name, PPB_FONT_DEV_INTERFACE) == 0)
239 return PPB_Font_Impl::GetInterface();
240 if (strcmp(name, PPB_FULLSCREEN_DEV_INTERFACE) == 0)
241 return PluginInstance::GetFullscreenInterface();
242 if (strcmp(name, PPB_GRAPHICS_2D_INTERFACE) == 0)
243 return PPB_Graphics2D_Impl::GetInterface();
244 if (strcmp(name, PPB_IMAGEDATA_INTERFACE) == 0)
245 return PPB_ImageData_Impl::GetInterface();
246 if (strcmp(name, PPB_IMAGEDATA_TRUSTED_INTERFACE) == 0)
247 return PPB_ImageData_Impl::GetTrustedInterface();
248 if (strcmp(name, PPB_INSTANCE_INTERFACE) == 0)
249 return PluginInstance::GetInterface();
250 if (strcmp(name, PPB_PDF_INTERFACE) == 0)
251 return PPB_Pdf_Impl::GetInterface();
252 if (strcmp(name, PPB_SCROLLBAR_DEV_INTERFACE) == 0)
253 return PPB_Scrollbar_Impl::GetInterface();
254 if (strcmp(name, PPB_TRANSPORT_DEV_INTERFACE) == 0)
255 return PPB_Transport_Impl::GetInterface();
256 if (strcmp(name, PPB_URLLOADER_INTERFACE) == 0)
257 return PPB_URLLoader_Impl::GetInterface();
258 if (strcmp(name, PPB_URLLOADERTRUSTED_INTERFACE) == 0)
259 return PPB_URLLoader_Impl::GetTrustedInterface();
260 if (strcmp(name, PPB_URLREQUESTINFO_INTERFACE) == 0)
261 return PPB_URLRequestInfo_Impl::GetInterface();
262 if (strcmp(name, PPB_URLRESPONSEINFO_INTERFACE) == 0)
263 return PPB_URLResponseInfo_Impl::GetInterface();
264 if (strcmp(name, PPB_URLUTIL_DEV_INTERFACE) == 0)
265 return PPB_UrlUtil_Impl::GetInterface();
204 if (strcmp(name, PPB_VAR_DEPRECATED_INTERFACE) == 0) 266 if (strcmp(name, PPB_VAR_DEPRECATED_INTERFACE) == 0)
205 return Var::GetDeprecatedInterface(); 267 return Var::GetDeprecatedInterface();
206 if (strcmp(name, PPB_VAR_INTERFACE) == 0) 268 if (strcmp(name, PPB_VAR_INTERFACE) == 0)
207 return Var::GetInterface(); 269 return Var::GetInterface();
208 if (strcmp(name, PPB_INSTANCE_INTERFACE) == 0) 270 if (strcmp(name, PPB_VIDEODECODER_DEV_INTERFACE) == 0)
209 return PluginInstance::GetInterface(); 271 return PPB_VideoDecoder_Impl::GetInterface();
210 if (strcmp(name, PPB_IMAGEDATA_INTERFACE) == 0) 272 if (strcmp(name, PPB_WIDGET_DEV_INTERFACE) == 0)
211 return ImageData::GetInterface(); 273 return PPB_Widget_Impl::GetInterface();
212 if (strcmp(name, PPB_IMAGEDATA_TRUSTED_INTERFACE) == 0) 274 if (strcmp(name, PPB_ZOOM_DEV_INTERFACE) == 0)
213 return ImageData::GetTrustedInterface(); 275 return PluginInstance::GetZoomInterface();
214 if (strcmp(name, PPB_AUDIO_CONFIG_DEV_INTERFACE) == 0) 276
215 return AudioConfig::GetInterface();
216 if (strcmp(name, PPB_AUDIO_DEV_INTERFACE) == 0)
217 return Audio::GetInterface();
218 if (strcmp(name, PPB_AUDIO_TRUSTED_DEV_INTERFACE) == 0)
219 return Audio::GetTrustedInterface();
220 if (strcmp(name, PPB_GRAPHICS_2D_INTERFACE) == 0)
221 return Graphics2D::GetInterface();
222 #ifdef ENABLE_GPU 277 #ifdef ENABLE_GPU
223 if (strcmp(name, PPB_GRAPHICS_3D_DEV_INTERFACE) == 0) 278 if (strcmp(name, PPB_GRAPHICS_3D_DEV_INTERFACE) == 0)
224 return Graphics3D::GetInterface(); 279 return PPB_Graphics3D_Impl::GetInterface();
225 if (strcmp(name, PPB_OPENGLES_DEV_INTERFACE) == 0) 280 if (strcmp(name, PPB_OPENGLES_DEV_INTERFACE) == 0)
226 return Graphics3D::GetOpenGLESInterface(); 281 return PPB_Graphics3D_Impl::GetOpenGLESInterface();
227 #endif // ENABLE_GPU 282 #endif // ENABLE_GPU
228 if (strcmp(name, PPB_TRANSPORT_DEV_INTERFACE) == 0)
229 return Transport::GetInterface();
230 if (strcmp(name, PPB_URLLOADER_INTERFACE) == 0)
231 return URLLoader::GetInterface();
232 if (strcmp(name, PPB_URLLOADERTRUSTED_INTERFACE) == 0)
233 return URLLoader::GetTrustedInterface();
234 if (strcmp(name, PPB_URLREQUESTINFO_INTERFACE) == 0)
235 return URLRequestInfo::GetInterface();
236 if (strcmp(name, PPB_URLRESPONSEINFO_INTERFACE) == 0)
237 return URLResponseInfo::GetInterface();
238 if (strcmp(name, PPB_BUFFER_DEV_INTERFACE) == 0)
239 return Buffer::GetInterface();
240 if (strcmp(name, PPB_FILEREF_DEV_INTERFACE) == 0)
241 return FileRef::GetInterface();
242 if (strcmp(name, PPB_FILEIO_DEV_INTERFACE) == 0)
243 return FileIO::GetInterface();
244 if (strcmp(name, PPB_FILEIOTRUSTED_DEV_INTERFACE) == 0)
245 return FileIO::GetTrustedInterface();
246 if (strcmp(name, PPB_FILESYSTEM_DEV_INTERFACE) == 0)
247 return FileSystem::GetInterface();
248 if (strcmp(name, PPB_DIRECTORYREADER_DEV_INTERFACE) == 0)
249 return DirectoryReader::GetInterface();
250 if (strcmp(name, PPB_WIDGET_DEV_INTERFACE) == 0)
251 return Widget::GetInterface();
252 if (strcmp(name, PPB_SCROLLBAR_DEV_INTERFACE) == 0)
253 return Scrollbar::GetInterface();
254 if (strcmp(name, PPB_FONT_DEV_INTERFACE) == 0)
255 return Font::GetInterface();
256 if (strcmp(name, PPB_FIND_DEV_INTERFACE) == 0)
257 return PluginInstance::GetFindInterface();
258 if (strcmp(name, PPB_FULLSCREEN_DEV_INTERFACE) == 0)
259 return PluginInstance::GetFullscreenInterface();
260 if (strcmp(name, PPB_URLUTIL_DEV_INTERFACE) == 0)
261 return UrlUtil::GetInterface();
262 if (strcmp(name, PPB_PRIVATE_INTERFACE) == 0)
263 return Private::GetInterface();
264 if (strcmp(name, PPB_PRIVATE2_INTERFACE) == 0)
265 return Private2::GetInterface();
266 if (strcmp(name, PPB_FILECHOOSER_DEV_INTERFACE) == 0)
267 return FileChooser::GetInterface();
268 if (strcmp(name, PPB_VIDEODECODER_DEV_INTERFACE) == 0)
269 return VideoDecoder::GetInterface();
270 if (strcmp(name, PPB_CHAR_SET_DEV_INTERFACE) == 0)
271 return CharSet::GetInterface();
272 if (strcmp(name, PPB_CURSOR_CONTROL_DEV_INTERFACE) == 0)
273 return GetCursorControlInterface();
274 if (strcmp(name, PPB_ZOOM_DEV_INTERFACE) == 0)
275 return PluginInstance::GetZoomInterface();
276 if (strcmp(name, PPB_CLASS_INTERFACE) == 0)
277 return VarObjectClass::GetInterface();
278 283
279 // Only support the testing interface when the command line switch is 284 // Only support the testing interface when the command line switch is
280 // specified. This allows us to prevent people from (ab)using this interface 285 // specified. This allows us to prevent people from (ab)using this interface
281 // in production code. 286 // in production code.
282 if (strcmp(name, PPB_TESTING_DEV_INTERFACE) == 0) { 287 if (strcmp(name, PPB_TESTING_DEV_INTERFACE) == 0) {
283 if (CommandLine::ForCurrentProcess()->HasSwitch("enable-pepper-testing")) 288 if (CommandLine::ForCurrentProcess()->HasSwitch("enable-pepper-testing"))
284 return &testing_interface; 289 return &testing_interface;
285 } 290 }
286 return NULL; 291 return NULL;
287 } 292 }
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 bool PluginModule::InitializeModule() { 487 bool PluginModule::InitializeModule() {
483 DCHECK(!out_of_process_proxy_.get()) << "Don't call for proxied modules."; 488 DCHECK(!out_of_process_proxy_.get()) << "Don't call for proxied modules.";
484 int retval = entry_points_.initialize_module(pp_module(), &GetInterface); 489 int retval = entry_points_.initialize_module(pp_module(), &GetInterface);
485 if (retval != 0) { 490 if (retval != 0) {
486 LOG(WARNING) << "PPP_InitializeModule returned failure " << retval; 491 LOG(WARNING) << "PPP_InitializeModule returned failure " << retval;
487 return false; 492 return false;
488 } 493 }
489 return true; 494 return true;
490 } 495 }
491 496
492 } // namespace pepper 497 } // namespace ppapi
498 } // namespace plugins
499 } // namespace webkit
500
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698