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

Side by Side Diff: webkit/glue/plugins/pepper_plugin_module.cc

Issue 3255003: Pull new PPAPI, rename non-P0 interfaces to Dev, rename DeviceContext2D to Gr... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 3 months 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
« no previous file with comments | « webkit/glue/plugins/pepper_plugin_module.h ('k') | webkit/glue/plugins/pepper_private.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/glue/plugins/pepper_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 "third_party/ppapi/c/dev/ppb_buffer_dev.h"
15 #include "third_party/ppapi/c/dev/ppb_char_set_dev.h" 16 #include "third_party/ppapi/c/dev/ppb_char_set_dev.h"
17 #include "third_party/ppapi/c/dev/ppb_directory_reader_dev.h"
18 #include "third_party/ppapi/c/dev/ppb_file_io_dev.h"
19 #include "third_party/ppapi/c/dev/ppb_file_io_trusted_dev.h"
20 #include "third_party/ppapi/c/dev/ppb_file_system_dev.h"
21 #include "third_party/ppapi/c/dev/ppb_find_dev.h"
22 #include "third_party/ppapi/c/dev/ppb_font_dev.h"
23 #include "third_party/ppapi/c/dev/ppb_graphics_3d_dev.h"
24 #include "third_party/ppapi/c/dev/ppb_opengles_dev.h"
25 #include "third_party/ppapi/c/dev/ppb_scrollbar_dev.h"
26 #include "third_party/ppapi/c/dev/ppb_testing_dev.h"
27 #include "third_party/ppapi/c/dev/ppb_url_loader_dev.h"
28 #include "third_party/ppapi/c/dev/ppb_url_request_info_dev.h"
29 #include "third_party/ppapi/c/dev/ppb_url_response_info_dev.h"
30 #include "third_party/ppapi/c/dev/ppb_url_util_dev.h"
16 #include "third_party/ppapi/c/dev/ppb_video_decoder_dev.h" 31 #include "third_party/ppapi/c/dev/ppb_video_decoder_dev.h"
17 #include "third_party/ppapi/c/ppb_buffer.h" 32 #include "third_party/ppapi/c/dev/ppb_widget_dev.h"
18 #include "third_party/ppapi/c/ppb_core.h"
19 #include "third_party/ppapi/c/ppb_device_context_2d.h"
20 #include "third_party/ppapi/c/ppb_file_io.h"
21 #include "third_party/ppapi/c/ppb_file_io_trusted.h"
22 #include "third_party/ppapi/c/ppb_file_system.h"
23 #include "third_party/ppapi/c/ppb_find.h"
24 #include "third_party/ppapi/c/ppb_font.h"
25 #include "third_party/ppapi/c/ppb_image_data.h"
26 #include "third_party/ppapi/c/ppb_instance.h"
27 #include "third_party/ppapi/c/ppb_opengles.h"
28 #include "third_party/ppapi/c/ppb_scrollbar.h"
29 #include "third_party/ppapi/c/ppb_testing.h"
30 #include "third_party/ppapi/c/ppb_url_loader.h"
31 #include "third_party/ppapi/c/ppb_url_request_info.h"
32 #include "third_party/ppapi/c/ppb_url_response_info.h"
33 #include "third_party/ppapi/c/ppb_url_util.h"
34 #include "third_party/ppapi/c/ppb_var.h"
35 #include "third_party/ppapi/c/ppb_widget.h"
36 #include "third_party/ppapi/c/ppp.h"
37 #include "third_party/ppapi/c/ppp_instance.h"
38 #include "third_party/ppapi/c/pp_module.h" 33 #include "third_party/ppapi/c/pp_module.h"
39 #include "third_party/ppapi/c/pp_resource.h" 34 #include "third_party/ppapi/c/pp_resource.h"
40 #include "third_party/ppapi/c/pp_var.h" 35 #include "third_party/ppapi/c/pp_var.h"
36 #include "third_party/ppapi/c/ppb_core.h"
37 #include "third_party/ppapi/c/ppb_graphics_2d.h"
38 #include "third_party/ppapi/c/ppb_image_data.h"
39 #include "third_party/ppapi/c/ppb_instance.h"
40 #include "third_party/ppapi/c/ppb_var.h"
41 #include "third_party/ppapi/c/ppp.h"
42 #include "third_party/ppapi/c/ppp_instance.h"
41 #include "webkit/glue/plugins/pepper_audio.h" 43 #include "webkit/glue/plugins/pepper_audio.h"
42 #include "webkit/glue/plugins/pepper_buffer.h" 44 #include "webkit/glue/plugins/pepper_buffer.h"
43 #include "webkit/glue/plugins/pepper_char_set.h" 45 #include "webkit/glue/plugins/pepper_char_set.h"
44 #include "webkit/glue/plugins/pepper_device_context_2d.h"
45 #include "webkit/glue/plugins/pepper_directory_reader.h" 46 #include "webkit/glue/plugins/pepper_directory_reader.h"
46 #include "webkit/glue/plugins/pepper_file_chooser.h" 47 #include "webkit/glue/plugins/pepper_file_chooser.h"
47 #include "webkit/glue/plugins/pepper_file_io.h" 48 #include "webkit/glue/plugins/pepper_file_io.h"
48 #include "webkit/glue/plugins/pepper_file_ref.h" 49 #include "webkit/glue/plugins/pepper_file_ref.h"
49 #include "webkit/glue/plugins/pepper_file_system.h" 50 #include "webkit/glue/plugins/pepper_file_system.h"
50 #include "webkit/glue/plugins/pepper_font.h" 51 #include "webkit/glue/plugins/pepper_font.h"
52 #include "webkit/glue/plugins/pepper_graphics_2d.h"
51 #include "webkit/glue/plugins/pepper_image_data.h" 53 #include "webkit/glue/plugins/pepper_image_data.h"
52 #include "webkit/glue/plugins/pepper_plugin_instance.h" 54 #include "webkit/glue/plugins/pepper_plugin_instance.h"
53 #include "webkit/glue/plugins/pepper_private.h" 55 #include "webkit/glue/plugins/pepper_private.h"
54 #include "webkit/glue/plugins/pepper_resource_tracker.h" 56 #include "webkit/glue/plugins/pepper_resource_tracker.h"
55 #include "webkit/glue/plugins/pepper_scrollbar.h" 57 #include "webkit/glue/plugins/pepper_scrollbar.h"
56 #include "webkit/glue/plugins/pepper_url_loader.h" 58 #include "webkit/glue/plugins/pepper_url_loader.h"
57 #include "webkit/glue/plugins/pepper_url_request_info.h" 59 #include "webkit/glue/plugins/pepper_url_request_info.h"
58 #include "webkit/glue/plugins/pepper_url_response_info.h" 60 #include "webkit/glue/plugins/pepper_url_response_info.h"
59 #include "webkit/glue/plugins/pepper_url_util.h" 61 #include "webkit/glue/plugins/pepper_url_util.h"
60 #include "webkit/glue/plugins/pepper_var.h" 62 #include "webkit/glue/plugins/pepper_var.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 &GetTime, 134 &GetTime,
133 &CallOnMainThread, 135 &CallOnMainThread,
134 &IsMainThread 136 &IsMainThread
135 }; 137 };
136 138
137 // PPB_Testing ----------------------------------------------------------------- 139 // PPB_Testing -----------------------------------------------------------------
138 140
139 bool ReadImageData(PP_Resource device_context_2d, 141 bool ReadImageData(PP_Resource device_context_2d,
140 PP_Resource image, 142 PP_Resource image,
141 const PP_Point* top_left) { 143 const PP_Point* top_left) {
142 scoped_refptr<DeviceContext2D> context( 144 scoped_refptr<Graphics2D> context(
143 Resource::GetAs<DeviceContext2D>(device_context_2d)); 145 Resource::GetAs<Graphics2D>(device_context_2d));
144 if (!context.get()) 146 if (!context.get())
145 return false; 147 return false;
146 return context->ReadImageData(image, top_left); 148 return context->ReadImageData(image, top_left);
147 } 149 }
148 150
149 void RunMessageLoop() { 151 void RunMessageLoop() {
150 bool old_state = MessageLoop::current()->NestableTasksAllowed(); 152 bool old_state = MessageLoop::current()->NestableTasksAllowed();
151 MessageLoop::current()->SetNestableTasksAllowed(true); 153 MessageLoop::current()->SetNestableTasksAllowed(true);
152 MessageLoop::current()->Run(); 154 MessageLoop::current()->Run();
153 MessageLoop::current()->SetNestableTasksAllowed(old_state); 155 MessageLoop::current()->SetNestableTasksAllowed(old_state);
154 } 156 }
155 157
156 void QuitMessageLoop() { 158 void QuitMessageLoop() {
157 MessageLoop::current()->Quit(); 159 MessageLoop::current()->Quit();
158 } 160 }
159 161
160 const PPB_Testing testing_interface = { 162 const PPB_Testing_Dev testing_interface = {
161 &ReadImageData, 163 &ReadImageData,
162 &RunMessageLoop, 164 &RunMessageLoop,
163 &QuitMessageLoop, 165 &QuitMessageLoop,
164 }; 166 };
165 167
166 // GetInterface ---------------------------------------------------------------- 168 // GetInterface ----------------------------------------------------------------
167 169
168 const void* GetInterface(const char* name) { 170 const void* GetInterface(const char* name) {
169 if (strcmp(name, PPB_CORE_INTERFACE) == 0) 171 if (strcmp(name, PPB_CORE_INTERFACE) == 0)
170 return &core_interface; 172 return &core_interface;
171 if (strcmp(name, PPB_VAR_INTERFACE) == 0) 173 if (strcmp(name, PPB_VAR_INTERFACE) == 0)
172 return GetVarInterface(); 174 return GetVarInterface();
173 if (strcmp(name, PPB_INSTANCE_INTERFACE) == 0) 175 if (strcmp(name, PPB_INSTANCE_INTERFACE) == 0)
174 return PluginInstance::GetInterface(); 176 return PluginInstance::GetInterface();
175 if (strcmp(name, PPB_IMAGEDATA_INTERFACE) == 0) 177 if (strcmp(name, PPB_IMAGEDATA_INTERFACE) == 0)
176 return ImageData::GetInterface(); 178 return ImageData::GetInterface();
177 if (strcmp(name, PPB_AUDIO_CONFIG_DEV_INTERFACE) == 0) 179 if (strcmp(name, PPB_AUDIO_CONFIG_DEV_INTERFACE) == 0)
178 return AudioConfig::GetInterface(); 180 return AudioConfig::GetInterface();
179 if (strcmp(name, PPB_AUDIO_DEV_INTERFACE) == 0) 181 if (strcmp(name, PPB_AUDIO_DEV_INTERFACE) == 0)
180 return Audio::GetInterface(); 182 return Audio::GetInterface();
181 if (strcmp(name, PPB_AUDIO_TRUSTED_DEV_INTERFACE) == 0) 183 if (strcmp(name, PPB_AUDIO_TRUSTED_DEV_INTERFACE) == 0)
182 return Audio::GetTrustedInterface(); 184 return Audio::GetTrustedInterface();
183 if (strcmp(name, PPB_DEVICECONTEXT2D_INTERFACE) == 0) 185 if (strcmp(name, PPB_GRAPHICS_2D_INTERFACE) == 0)
184 return DeviceContext2D::GetInterface(); 186 return Graphics2D::GetInterface();
185 #ifdef ENABLE_GPU 187 #ifdef ENABLE_GPU
186 if (strcmp(name, PPB_GRAPHICS_3D_INTERFACE) == 0) 188 if (strcmp(name, PPB_GRAPHICS_3D_DEV_INTERFACE) == 0)
187 return Graphics3D::GetInterface(); 189 return Graphics3D::GetInterface();
188 if (strcmp(name, PPB_OPENGLES_INTERFACE) == 0) 190 if (strcmp(name, PPB_OPENGLES_DEV_INTERFACE) == 0)
189 return Graphics3D::GetOpenGLESInterface(); 191 return Graphics3D::GetOpenGLESInterface();
190 #endif // ENABLE_GPU 192 #endif // ENABLE_GPU
191 if (strcmp(name, PPB_URLLOADER_INTERFACE) == 0) 193 if (strcmp(name, PPB_URLLOADER_DEV_INTERFACE) == 0)
192 return URLLoader::GetInterface(); 194 return URLLoader::GetInterface();
193 if (strcmp(name, PPB_URLREQUESTINFO_INTERFACE) == 0) 195 if (strcmp(name, PPB_URLREQUESTINFO_DEV_INTERFACE) == 0)
194 return URLRequestInfo::GetInterface(); 196 return URLRequestInfo::GetInterface();
195 if (strcmp(name, PPB_URLRESPONSEINFO_INTERFACE) == 0) 197 if (strcmp(name, PPB_URLRESPONSEINFO_DEV_INTERFACE) == 0)
196 return URLResponseInfo::GetInterface(); 198 return URLResponseInfo::GetInterface();
197 if (strcmp(name, PPB_BUFFER_INTERFACE) == 0) 199 if (strcmp(name, PPB_BUFFER_DEV_INTERFACE) == 0)
198 return Buffer::GetInterface(); 200 return Buffer::GetInterface();
199 if (strcmp(name, PPB_FILEREF_INTERFACE) == 0) 201 if (strcmp(name, PPB_FILEREF_DEV_INTERFACE) == 0)
200 return FileRef::GetInterface(); 202 return FileRef::GetInterface();
201 if (strcmp(name, PPB_FILEIO_INTERFACE) == 0) 203 if (strcmp(name, PPB_FILEIO_DEV_INTERFACE) == 0)
202 return FileIO::GetInterface(); 204 return FileIO::GetInterface();
203 if (strcmp(name, PPB_FILEIOTRUSTED_INTERFACE) == 0) 205 if (strcmp(name, PPB_FILEIOTRUSTED_DEV_INTERFACE) == 0)
204 return FileIO::GetTrustedInterface(); 206 return FileIO::GetTrustedInterface();
205 if (strcmp(name, PPB_FILESYSTEM_INTERFACE) == 0) 207 if (strcmp(name, PPB_FILESYSTEM_DEV_INTERFACE) == 0)
206 return FileSystem::GetInterface(); 208 return FileSystem::GetInterface();
207 if (strcmp(name, PPB_DIRECTORYREADER_INTERFACE) == 0) 209 if (strcmp(name, PPB_DIRECTORYREADER_DEV_INTERFACE) == 0)
208 return DirectoryReader::GetInterface(); 210 return DirectoryReader::GetInterface();
209 if (strcmp(name, PPB_WIDGET_INTERFACE) == 0) 211 if (strcmp(name, PPB_WIDGET_DEV_INTERFACE) == 0)
210 return Widget::GetInterface(); 212 return Widget::GetInterface();
211 if (strcmp(name, PPB_SCROLLBAR_INTERFACE) == 0) 213 if (strcmp(name, PPB_SCROLLBAR_DEV_INTERFACE) == 0)
212 return Scrollbar::GetInterface(); 214 return Scrollbar::GetInterface();
213 if (strcmp(name, PPB_FONT_INTERFACE) == 0) 215 if (strcmp(name, PPB_FONT_DEV_INTERFACE) == 0)
214 return Font::GetInterface(); 216 return Font::GetInterface();
215 if (strcmp(name, PPB_FIND_INTERFACE) == 0) 217 if (strcmp(name, PPB_FIND_DEV_INTERFACE) == 0)
216 return PluginInstance::GetFindInterface(); 218 return PluginInstance::GetFindInterface();
217 if (strcmp(name, PPB_URLUTIL_INTERFACE) == 0) 219 if (strcmp(name, PPB_URLUTIL_DEV_INTERFACE) == 0)
218 return GetUrlUtilInterface(); 220 return UrlUtil::GetInterface();
219 if (strcmp(name, PPB_PRIVATE_INTERFACE) == 0) 221 if (strcmp(name, PPB_PRIVATE_INTERFACE) == 0)
220 return Private::GetInterface(); 222 return Private::GetInterface();
221 if (strcmp(name, PPB_FILECHOOSER_INTERFACE) == 0) 223 if (strcmp(name, PPB_FILECHOOSER_DEV_INTERFACE) == 0)
222 return FileChooser::GetInterface(); 224 return FileChooser::GetInterface();
223 if (strcmp(name, PPB_VIDEODECODER_DEV_INTERFACE) == 0) 225 if (strcmp(name, PPB_VIDEODECODER_DEV_INTERFACE) == 0)
224 return VideoDecoder::GetInterface(); 226 return VideoDecoder::GetInterface();
225 if (strcmp(name, PPB_CHAR_SET_DEV_INTERFACE) == 0) 227 if (strcmp(name, PPB_CHAR_SET_DEV_INTERFACE) == 0)
226 return CharSet::GetInterface(); 228 return CharSet::GetInterface();
227 229
228 // Only support the testing interface when the command line switch is 230 // Only support the testing interface when the command line switch is
229 // specified. This allows us to prevent people from (ab)using this interface 231 // specified. This allows us to prevent people from (ab)using this interface
230 // in production code. 232 // in production code.
231 if (strcmp(name, PPB_TESTING_INTERFACE) == 0) { 233 if (strcmp(name, PPB_TESTING_DEV_INTERFACE) == 0) {
232 if (CommandLine::ForCurrentProcess()->HasSwitch("enable-pepper-testing")) 234 if (CommandLine::ForCurrentProcess()->HasSwitch("enable-pepper-testing"))
233 return &testing_interface; 235 return &testing_interface;
234 } 236 }
235 return NULL; 237 return NULL;
236 } 238 }
237 239
238 } // namespace 240 } // namespace
239 241
240 PluginModule::PluginModule() 242 PluginModule::PluginModule()
241 : initialized_(false), 243 : initialized_(false),
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 393
392 void PluginModule::InstanceCreated(PluginInstance* instance) { 394 void PluginModule::InstanceCreated(PluginInstance* instance) {
393 instances_.insert(instance); 395 instances_.insert(instance);
394 } 396 }
395 397
396 void PluginModule::InstanceDeleted(PluginInstance* instance) { 398 void PluginModule::InstanceDeleted(PluginInstance* instance) {
397 instances_.erase(instance); 399 instances_.erase(instance);
398 } 400 }
399 401
400 } // namespace pepper 402 } // namespace pepper
OLDNEW
« no previous file with comments | « webkit/glue/plugins/pepper_plugin_module.h ('k') | webkit/glue/plugins/pepper_private.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698