OLD | NEW |
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/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
12 #include "base/time.h" | 12 #include "base/time.h" |
13 #include "third_party/ppapi/c/ppb_core.h" | 13 #include "third_party/ppapi/c/ppb_core.h" |
14 #include "third_party/ppapi/c/ppb_device_context_2d.h" | 14 #include "third_party/ppapi/c/ppb_device_context_2d.h" |
15 #include "third_party/ppapi/c/ppb_image_data.h" | 15 #include "third_party/ppapi/c/ppb_image_data.h" |
16 #include "third_party/ppapi/c/ppb_instance.h" | 16 #include "third_party/ppapi/c/ppb_instance.h" |
| 17 #include "third_party/ppapi/c/ppb_testing.h" |
17 #include "third_party/ppapi/c/ppb_var.h" | 18 #include "third_party/ppapi/c/ppb_var.h" |
18 #include "third_party/ppapi/c/ppp.h" | 19 #include "third_party/ppapi/c/ppp.h" |
19 #include "third_party/ppapi/c/ppp_instance.h" | 20 #include "third_party/ppapi/c/ppp_instance.h" |
20 #include "third_party/ppapi/c/pp_module.h" | 21 #include "third_party/ppapi/c/pp_module.h" |
21 #include "third_party/ppapi/c/pp_resource.h" | 22 #include "third_party/ppapi/c/pp_resource.h" |
22 #include "third_party/ppapi/c/pp_var.h" | 23 #include "third_party/ppapi/c/pp_var.h" |
23 #include "webkit/glue/plugins/pepper_device_context_2d.h" | 24 #include "webkit/glue/plugins/pepper_device_context_2d.h" |
24 #include "webkit/glue/plugins/pepper_image_data.h" | 25 #include "webkit/glue/plugins/pepper_image_data.h" |
25 #include "webkit/glue/plugins/pepper_plugin_instance.h" | 26 #include "webkit/glue/plugins/pepper_plugin_instance.h" |
26 #include "webkit/glue/plugins/pepper_resource_tracker.h" | 27 #include "webkit/glue/plugins/pepper_resource_tracker.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 90 |
90 const PPB_Core core_interface = { | 91 const PPB_Core core_interface = { |
91 &AddRefResource, | 92 &AddRefResource, |
92 &ReleaseResource, | 93 &ReleaseResource, |
93 &MemAlloc, | 94 &MemAlloc, |
94 &MemFree, | 95 &MemFree, |
95 &GetTime, | 96 &GetTime, |
96 &CallOnMainThread | 97 &CallOnMainThread |
97 }; | 98 }; |
98 | 99 |
| 100 // PPB_Testing ----------------------------------------------------------------- |
| 101 |
| 102 bool ReadImageData(PP_Resource device_context_2d, |
| 103 PP_Resource image, |
| 104 int32_t x, int32_t y) { |
| 105 scoped_refptr<DeviceContext2D> context( |
| 106 ResourceTracker::Get()->GetAsDeviceContext2D(device_context_2d)); |
| 107 if (!context.get()) |
| 108 return false; |
| 109 return context->ReadImageData(image, x, y); |
| 110 } |
| 111 |
| 112 const PPB_Testing testing_interface = { |
| 113 &ReadImageData |
| 114 }; |
| 115 |
99 // GetInterface ---------------------------------------------------------------- | 116 // GetInterface ---------------------------------------------------------------- |
100 | 117 |
101 const void* GetInterface(const char* name) { | 118 const void* GetInterface(const char* name) { |
102 if (strcmp(name, PPB_CORE_INTERFACE) == 0) | 119 if (strcmp(name, PPB_CORE_INTERFACE) == 0) |
103 return &core_interface; | 120 return &core_interface; |
104 if (strcmp(name, PPB_VAR_INTERFACE) == 0) | 121 if (strcmp(name, PPB_VAR_INTERFACE) == 0) |
105 return GetVarInterface(); | 122 return GetVarInterface(); |
106 if (strcmp(name, PPB_INSTANCE_INTERFACE) == 0) | 123 if (strcmp(name, PPB_INSTANCE_INTERFACE) == 0) |
107 return PluginInstance::GetInterface(); | 124 return PluginInstance::GetInterface(); |
108 if (strcmp(name, PPB_IMAGEDATA_INTERFACE) == 0) | 125 if (strcmp(name, PPB_IMAGEDATA_INTERFACE) == 0) |
109 return ImageData::GetInterface(); | 126 return ImageData::GetInterface(); |
110 if (strcmp(name, PPB_DEVICECONTEXT2D_INTERFACE) == 0) | 127 if (strcmp(name, PPB_DEVICECONTEXT2D_INTERFACE) == 0) |
111 return DeviceContext2D::GetInterface(); | 128 return DeviceContext2D::GetInterface(); |
| 129 if (strcmp(name, PPB_TESTING_INTERFACE) == 0) |
| 130 return &testing_interface; |
112 return NULL; | 131 return NULL; |
113 } | 132 } |
114 | 133 |
115 } // namespace | 134 } // namespace |
116 | 135 |
117 PluginModule::PluginModule(const FilePath& filename) | 136 PluginModule::PluginModule(const FilePath& filename) |
118 : filename_(filename), | 137 : filename_(filename), |
119 initialized_(false), | 138 initialized_(false), |
120 library_(0), | 139 library_(0), |
121 ppp_get_interface_(NULL) { | 140 ppp_get_interface_(NULL) { |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 | 246 |
228 void PluginModule::InstanceCreated(PluginInstance* instance) { | 247 void PluginModule::InstanceCreated(PluginInstance* instance) { |
229 instances_.insert(instance); | 248 instances_.insert(instance); |
230 } | 249 } |
231 | 250 |
232 void PluginModule::InstanceDeleted(PluginInstance* instance) { | 251 void PluginModule::InstanceDeleted(PluginInstance* instance) { |
233 instances_.erase(instance); | 252 instances_.erase(instance); |
234 } | 253 } |
235 | 254 |
236 } // namespace pepper | 255 } // namespace pepper |
OLD | NEW |