| 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/npapi_extension_thunk.h" | 5 #include "webkit/plugins/npapi/npapi_extension_thunk.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "third_party/npapi/bindings/npapi_extensions.h" | 10 #include "third_party/npapi/bindings/npapi_extensions.h" |
| 11 #include "webkit/glue/plugins/plugin_instance.h" | 11 #include "webkit/plugins/npapi/plugin_instance.h" |
| 12 #include "webkit/glue/plugins/webplugin.h" | 12 #include "webkit/plugins/npapi/webplugin.h" |
| 13 #include "webkit/glue/plugins/webplugin_delegate.h" | 13 #include "webkit/plugins/npapi/webplugin_delegate.h" |
| 14 #include "webkit/glue/webkit_glue.h" | 14 #include "webkit/glue/webkit_glue.h" |
| 15 | 15 |
| 16 namespace webkit { |
| 17 namespace npapi { |
| 18 |
| 16 // FindInstance() | 19 // FindInstance() |
| 17 // Finds a PluginInstance from an NPP. | 20 // Finds a PluginInstance from an NPP. |
| 18 // The caller must take a reference if needed. | 21 // The caller must take a reference if needed. |
| 19 static NPAPI::PluginInstance* FindInstance(NPP id) { | 22 static PluginInstance* FindInstance(NPP id) { |
| 20 if (id == NULL) { | 23 if (id == NULL) { |
| 21 NOTREACHED(); | 24 NOTREACHED(); |
| 22 return NULL; | 25 return NULL; |
| 23 } | 26 } |
| 24 return static_cast<NPAPI::PluginInstance*>(id->ndata); | 27 return static_cast<PluginInstance*>(id->ndata); |
| 25 } | 28 } |
| 26 | 29 |
| 27 // 2D device API --------------------------------------------------------------- | 30 // 2D device API --------------------------------------------------------------- |
| 28 | 31 |
| 29 static NPError Device2DQueryCapability(NPP id, int32_t capability, | 32 static NPError Device2DQueryCapability(NPP id, int32_t capability, |
| 30 int32_t* value) { | 33 int32_t* value) { |
| 31 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); | 34 scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
| 32 if (plugin) { | 35 if (plugin) { |
| 33 plugin->webplugin()->delegate()->Device2DQueryCapability(capability, value); | 36 plugin->webplugin()->delegate()->Device2DQueryCapability(capability, value); |
| 34 return NPERR_NO_ERROR; | 37 return NPERR_NO_ERROR; |
| 35 } else { | 38 } else { |
| 36 return NPERR_GENERIC_ERROR; | 39 return NPERR_GENERIC_ERROR; |
| 37 } | 40 } |
| 38 } | 41 } |
| 39 | 42 |
| 40 static NPError Device2DQueryConfig(NPP id, | 43 static NPError Device2DQueryConfig(NPP id, |
| 41 const NPDeviceConfig* request, | 44 const NPDeviceConfig* request, |
| 42 NPDeviceConfig* obtain) { | 45 NPDeviceConfig* obtain) { |
| 43 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); | 46 scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
| 44 if (plugin) { | 47 if (plugin) { |
| 45 return plugin->webplugin()->delegate()->Device2DQueryConfig( | 48 return plugin->webplugin()->delegate()->Device2DQueryConfig( |
| 46 static_cast<const NPDeviceContext2DConfig*>(request), | 49 static_cast<const NPDeviceContext2DConfig*>(request), |
| 47 static_cast<NPDeviceContext2DConfig*>(obtain)); | 50 static_cast<NPDeviceContext2DConfig*>(obtain)); |
| 48 } | 51 } |
| 49 return NPERR_GENERIC_ERROR; | 52 return NPERR_GENERIC_ERROR; |
| 50 } | 53 } |
| 51 | 54 |
| 52 static NPError Device2DInitializeContext(NPP id, | 55 static NPError Device2DInitializeContext(NPP id, |
| 53 const NPDeviceConfig* config, | 56 const NPDeviceConfig* config, |
| 54 NPDeviceContext* context) { | 57 NPDeviceContext* context) { |
| 55 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); | 58 scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
| 56 if (plugin) { | 59 if (plugin) { |
| 57 return plugin->webplugin()->delegate()->Device2DInitializeContext( | 60 return plugin->webplugin()->delegate()->Device2DInitializeContext( |
| 58 static_cast<const NPDeviceContext2DConfig*>(config), | 61 static_cast<const NPDeviceContext2DConfig*>(config), |
| 59 static_cast<NPDeviceContext2D*>(context)); | 62 static_cast<NPDeviceContext2D*>(context)); |
| 60 } | 63 } |
| 61 return NPERR_GENERIC_ERROR; | 64 return NPERR_GENERIC_ERROR; |
| 62 } | 65 } |
| 63 | 66 |
| 64 static NPError Device2DSetStateContext(NPP id, | 67 static NPError Device2DSetStateContext(NPP id, |
| 65 NPDeviceContext* context, | 68 NPDeviceContext* context, |
| 66 int32_t state, | 69 int32_t state, |
| 67 intptr_t value) { | 70 intptr_t value) { |
| 68 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); | 71 scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
| 69 if (plugin) { | 72 if (plugin) { |
| 70 return plugin->webplugin()->delegate()->Device2DSetStateContext( | 73 return plugin->webplugin()->delegate()->Device2DSetStateContext( |
| 71 static_cast<NPDeviceContext2D*>(context), state, value); | 74 static_cast<NPDeviceContext2D*>(context), state, value); |
| 72 } | 75 } |
| 73 return NPERR_GENERIC_ERROR; | 76 return NPERR_GENERIC_ERROR; |
| 74 } | 77 } |
| 75 | 78 |
| 76 static NPError Device2DGetStateContext(NPP id, | 79 static NPError Device2DGetStateContext(NPP id, |
| 77 NPDeviceContext* context, | 80 NPDeviceContext* context, |
| 78 int32_t state, | 81 int32_t state, |
| 79 intptr_t* value) { | 82 intptr_t* value) { |
| 80 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); | 83 scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
| 81 if (plugin) { | 84 if (plugin) { |
| 82 return plugin->webplugin()->delegate()->Device2DGetStateContext( | 85 return plugin->webplugin()->delegate()->Device2DGetStateContext( |
| 83 static_cast<NPDeviceContext2D*>(context), state, value); | 86 static_cast<NPDeviceContext2D*>(context), state, value); |
| 84 } | 87 } |
| 85 return NPERR_GENERIC_ERROR; | 88 return NPERR_GENERIC_ERROR; |
| 86 } | 89 } |
| 87 | 90 |
| 88 static NPError Device2DFlushContext(NPP id, | 91 static NPError Device2DFlushContext(NPP id, |
| 89 NPDeviceContext* context, | 92 NPDeviceContext* context, |
| 90 NPDeviceFlushContextCallbackPtr callback, | 93 NPDeviceFlushContextCallbackPtr callback, |
| 91 void* user_data) { | 94 void* user_data) { |
| 92 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); | 95 scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
| 93 if (plugin) { | 96 if (plugin) { |
| 94 NPError err = plugin->webplugin()->delegate()->Device2DFlushContext( | 97 NPError err = plugin->webplugin()->delegate()->Device2DFlushContext( |
| 95 id, static_cast<NPDeviceContext2D*>(context), callback, user_data); | 98 id, static_cast<NPDeviceContext2D*>(context), callback, user_data); |
| 96 | 99 |
| 97 // Invoke the callback to inform the caller the work was done. | 100 // Invoke the callback to inform the caller the work was done. |
| 98 // TODO(brettw) this is probably not how we want this to work, this should | 101 // TODO(brettw) this is probably not how we want this to work, this should |
| 99 // happen when the frame is painted so the plugin knows when it can draw | 102 // happen when the frame is painted so the plugin knows when it can draw |
| 100 // the next frame. | 103 // the next frame. |
| 101 if (callback != NULL) | 104 if (callback != NULL) |
| 102 (*callback)(id, context, err, user_data); | 105 (*callback)(id, context, err, user_data); |
| 103 | 106 |
| 104 // Return any errors. | 107 // Return any errors. |
| 105 return err; | 108 return err; |
| 106 } | 109 } |
| 107 return NPERR_GENERIC_ERROR; | 110 return NPERR_GENERIC_ERROR; |
| 108 } | 111 } |
| 109 | 112 |
| 110 static NPError Device2DDestroyContext(NPP id, | 113 static NPError Device2DDestroyContext(NPP id, |
| 111 NPDeviceContext* context) { | 114 NPDeviceContext* context) { |
| 112 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); | 115 scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
| 113 if (plugin) { | 116 if (plugin) { |
| 114 return plugin->webplugin()->delegate()->Device2DDestroyContext( | 117 return plugin->webplugin()->delegate()->Device2DDestroyContext( |
| 115 static_cast<NPDeviceContext2D*>(context)); | 118 static_cast<NPDeviceContext2D*>(context)); |
| 116 } | 119 } |
| 117 return NPERR_GENERIC_ERROR; | 120 return NPERR_GENERIC_ERROR; |
| 118 } | 121 } |
| 119 | 122 |
| 120 static NPError Device2DCreateBuffer(NPP id, | 123 static NPError Device2DCreateBuffer(NPP id, |
| 121 NPDeviceContext* context, | 124 NPDeviceContext* context, |
| 122 size_t size, | 125 size_t size, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 134 NPDeviceContext* context, | 137 NPDeviceContext* context, |
| 135 int32_t buffer_id, | 138 int32_t buffer_id, |
| 136 NPDeviceBuffer* buffer) { | 139 NPDeviceBuffer* buffer) { |
| 137 return NPERR_GENERIC_ERROR; | 140 return NPERR_GENERIC_ERROR; |
| 138 } | 141 } |
| 139 | 142 |
| 140 // 3D device API --------------------------------------------------------------- | 143 // 3D device API --------------------------------------------------------------- |
| 141 | 144 |
| 142 static NPError Device3DQueryCapability(NPP id, int32_t capability, | 145 static NPError Device3DQueryCapability(NPP id, int32_t capability, |
| 143 int32_t* value) { | 146 int32_t* value) { |
| 144 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); | 147 scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
| 145 if (plugin) { | 148 if (plugin) { |
| 146 plugin->webplugin()->delegate()->Device3DQueryCapability(capability, value); | 149 plugin->webplugin()->delegate()->Device3DQueryCapability(capability, value); |
| 147 return NPERR_NO_ERROR; | 150 return NPERR_NO_ERROR; |
| 148 } else { | 151 } else { |
| 149 return NPERR_GENERIC_ERROR; | 152 return NPERR_GENERIC_ERROR; |
| 150 } | 153 } |
| 151 } | 154 } |
| 152 | 155 |
| 153 static NPError Device3DQueryConfig(NPP id, | 156 static NPError Device3DQueryConfig(NPP id, |
| 154 const NPDeviceConfig* request, | 157 const NPDeviceConfig* request, |
| 155 NPDeviceConfig* obtain) { | 158 NPDeviceConfig* obtain) { |
| 156 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); | 159 scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
| 157 if (plugin) { | 160 if (plugin) { |
| 158 return plugin->webplugin()->delegate()->Device3DQueryConfig( | 161 return plugin->webplugin()->delegate()->Device3DQueryConfig( |
| 159 static_cast<const NPDeviceContext3DConfig*>(request), | 162 static_cast<const NPDeviceContext3DConfig*>(request), |
| 160 static_cast<NPDeviceContext3DConfig*>(obtain)); | 163 static_cast<NPDeviceContext3DConfig*>(obtain)); |
| 161 } | 164 } |
| 162 return NPERR_GENERIC_ERROR; | 165 return NPERR_GENERIC_ERROR; |
| 163 } | 166 } |
| 164 | 167 |
| 165 static NPError Device3DInitializeContext(NPP id, | 168 static NPError Device3DInitializeContext(NPP id, |
| 166 const NPDeviceConfig* config, | 169 const NPDeviceConfig* config, |
| 167 NPDeviceContext* context) { | 170 NPDeviceContext* context) { |
| 168 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); | 171 scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
| 169 if (plugin) { | 172 if (plugin) { |
| 170 return plugin->webplugin()->delegate()->Device3DInitializeContext( | 173 return plugin->webplugin()->delegate()->Device3DInitializeContext( |
| 171 static_cast<const NPDeviceContext3DConfig*>(config), | 174 static_cast<const NPDeviceContext3DConfig*>(config), |
| 172 static_cast<NPDeviceContext3D*>(context)); | 175 static_cast<NPDeviceContext3D*>(context)); |
| 173 } | 176 } |
| 174 return NPERR_GENERIC_ERROR; | 177 return NPERR_GENERIC_ERROR; |
| 175 } | 178 } |
| 176 | 179 |
| 177 static NPError Device3DSetStateContext(NPP id, | 180 static NPError Device3DSetStateContext(NPP id, |
| 178 NPDeviceContext* context, | 181 NPDeviceContext* context, |
| 179 int32_t state, | 182 int32_t state, |
| 180 intptr_t value) { | 183 intptr_t value) { |
| 181 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); | 184 scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
| 182 if (plugin) { | 185 if (plugin) { |
| 183 return plugin->webplugin()->delegate()->Device3DSetStateContext( | 186 return plugin->webplugin()->delegate()->Device3DSetStateContext( |
| 184 static_cast<NPDeviceContext3D*>(context), state, value); | 187 static_cast<NPDeviceContext3D*>(context), state, value); |
| 185 } | 188 } |
| 186 return NPERR_GENERIC_ERROR; | 189 return NPERR_GENERIC_ERROR; |
| 187 } | 190 } |
| 188 | 191 |
| 189 static NPError Device3DGetStateContext(NPP id, | 192 static NPError Device3DGetStateContext(NPP id, |
| 190 NPDeviceContext* context, | 193 NPDeviceContext* context, |
| 191 int32_t state, | 194 int32_t state, |
| 192 intptr_t* value) { | 195 intptr_t* value) { |
| 193 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); | 196 scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
| 194 if (plugin) { | 197 if (plugin) { |
| 195 return plugin->webplugin()->delegate()->Device3DGetStateContext( | 198 return plugin->webplugin()->delegate()->Device3DGetStateContext( |
| 196 static_cast<NPDeviceContext3D*>(context), state, value); | 199 static_cast<NPDeviceContext3D*>(context), state, value); |
| 197 } | 200 } |
| 198 return NPERR_GENERIC_ERROR; | 201 return NPERR_GENERIC_ERROR; |
| 199 } | 202 } |
| 200 | 203 |
| 201 static NPError Device3DFlushContext(NPP id, | 204 static NPError Device3DFlushContext(NPP id, |
| 202 NPDeviceContext* context, | 205 NPDeviceContext* context, |
| 203 NPDeviceFlushContextCallbackPtr callback, | 206 NPDeviceFlushContextCallbackPtr callback, |
| 204 void* user_data) { | 207 void* user_data) { |
| 205 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); | 208 scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
| 206 if (plugin) { | 209 if (plugin) { |
| 207 return plugin->webplugin()->delegate()->Device3DFlushContext( | 210 return plugin->webplugin()->delegate()->Device3DFlushContext( |
| 208 id, static_cast<NPDeviceContext3D*>(context), callback, user_data); | 211 id, static_cast<NPDeviceContext3D*>(context), callback, user_data); |
| 209 } | 212 } |
| 210 return NPERR_GENERIC_ERROR; | 213 return NPERR_GENERIC_ERROR; |
| 211 } | 214 } |
| 212 | 215 |
| 213 static NPError Device3DDestroyContext(NPP id, | 216 static NPError Device3DDestroyContext(NPP id, |
| 214 NPDeviceContext* context) { | 217 NPDeviceContext* context) { |
| 215 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); | 218 scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
| 216 if (plugin) { | 219 if (plugin) { |
| 217 return plugin->webplugin()->delegate()->Device3DDestroyContext( | 220 return plugin->webplugin()->delegate()->Device3DDestroyContext( |
| 218 static_cast<NPDeviceContext3D*>(context)); | 221 static_cast<NPDeviceContext3D*>(context)); |
| 219 } | 222 } |
| 220 return NPERR_GENERIC_ERROR; | 223 return NPERR_GENERIC_ERROR; |
| 221 } | 224 } |
| 222 | 225 |
| 223 static NPError Device3DCreateBuffer(NPP id, | 226 static NPError Device3DCreateBuffer(NPP id, |
| 224 NPDeviceContext* context, | 227 NPDeviceContext* context, |
| 225 size_t size, | 228 size_t size, |
| 226 int32_t* buffer_id) { | 229 int32_t* buffer_id) { |
| 227 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); | 230 scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
| 228 if (plugin) { | 231 if (plugin) { |
| 229 return plugin->webplugin()->delegate()->Device3DCreateBuffer( | 232 return plugin->webplugin()->delegate()->Device3DCreateBuffer( |
| 230 static_cast<NPDeviceContext3D*>(context), size, buffer_id); | 233 static_cast<NPDeviceContext3D*>(context), size, buffer_id); |
| 231 } | 234 } |
| 232 return NPERR_GENERIC_ERROR; | 235 return NPERR_GENERIC_ERROR; |
| 233 } | 236 } |
| 234 | 237 |
| 235 static NPError Device3DDestroyBuffer(NPP id, | 238 static NPError Device3DDestroyBuffer(NPP id, |
| 236 NPDeviceContext* context, | 239 NPDeviceContext* context, |
| 237 int32_t buffer_id) { | 240 int32_t buffer_id) { |
| 238 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); | 241 scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
| 239 if (plugin) { | 242 if (plugin) { |
| 240 return plugin->webplugin()->delegate()->Device3DDestroyBuffer( | 243 return plugin->webplugin()->delegate()->Device3DDestroyBuffer( |
| 241 static_cast<NPDeviceContext3D*>(context), buffer_id); | 244 static_cast<NPDeviceContext3D*>(context), buffer_id); |
| 242 } | 245 } |
| 243 return NPERR_GENERIC_ERROR; | 246 return NPERR_GENERIC_ERROR; |
| 244 } | 247 } |
| 245 | 248 |
| 246 static NPError Device3DMapBuffer(NPP id, | 249 static NPError Device3DMapBuffer(NPP id, |
| 247 NPDeviceContext* context, | 250 NPDeviceContext* context, |
| 248 int32_t buffer_id, | 251 int32_t buffer_id, |
| 249 NPDeviceBuffer* buffer) { | 252 NPDeviceBuffer* buffer) { |
| 250 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); | 253 scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
| 251 if (plugin) { | 254 if (plugin) { |
| 252 return plugin->webplugin()->delegate()->Device3DMapBuffer( | 255 return plugin->webplugin()->delegate()->Device3DMapBuffer( |
| 253 static_cast<NPDeviceContext3D*>(context), buffer_id, buffer); | 256 static_cast<NPDeviceContext3D*>(context), buffer_id, buffer); |
| 254 } | 257 } |
| 255 return NPERR_GENERIC_ERROR; | 258 return NPERR_GENERIC_ERROR; |
| 256 } | 259 } |
| 257 | 260 |
| 258 // Experimental 3D device API -------------------------------------------------- | 261 // Experimental 3D device API -------------------------------------------------- |
| 259 | 262 |
| 260 static NPError Device3DGetNumConfigs(NPP id, int32_t* num_configs) { | 263 static NPError Device3DGetNumConfigs(NPP id, int32_t* num_configs) { |
| 261 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); | 264 scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
| 262 if (plugin) { | 265 if (plugin) { |
| 263 return plugin->webplugin()->delegate()->Device3DGetNumConfigs(num_configs); | 266 return plugin->webplugin()->delegate()->Device3DGetNumConfigs(num_configs); |
| 264 } | 267 } |
| 265 return NPERR_GENERIC_ERROR; | 268 return NPERR_GENERIC_ERROR; |
| 266 } | 269 } |
| 267 | 270 |
| 268 static NPError Device3DGetConfigAttribs(NPP id, | 271 static NPError Device3DGetConfigAttribs(NPP id, |
| 269 int32_t config, | 272 int32_t config, |
| 270 int32_t* attrib_list) { | 273 int32_t* attrib_list) { |
| 271 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); | 274 scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
| 272 if (plugin) { | 275 if (plugin) { |
| 273 return plugin->webplugin()->delegate()->Device3DGetConfigAttribs( | 276 return plugin->webplugin()->delegate()->Device3DGetConfigAttribs( |
| 274 config, | 277 config, |
| 275 attrib_list); | 278 attrib_list); |
| 276 } | 279 } |
| 277 return NPERR_GENERIC_ERROR; | 280 return NPERR_GENERIC_ERROR; |
| 278 } | 281 } |
| 279 | 282 |
| 280 static NPError Device3DCreateContext(NPP id, | 283 static NPError Device3DCreateContext(NPP id, |
| 281 int32_t config, | 284 int32_t config, |
| 282 const int32_t* attrib_list, | 285 const int32_t* attrib_list, |
| 283 NPDeviceContext** context) { | 286 NPDeviceContext** context) { |
| 284 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); | 287 scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
| 285 if (plugin) { | 288 if (plugin) { |
| 286 return plugin->webplugin()->delegate()->Device3DCreateContext( | 289 return plugin->webplugin()->delegate()->Device3DCreateContext( |
| 287 config, | 290 config, |
| 288 attrib_list, | 291 attrib_list, |
| 289 reinterpret_cast<NPDeviceContext3D**>(context)); | 292 reinterpret_cast<NPDeviceContext3D**>(context)); |
| 290 } | 293 } |
| 291 return NPERR_GENERIC_ERROR; | 294 return NPERR_GENERIC_ERROR; |
| 292 } | 295 } |
| 293 | 296 |
| 294 static NPError Device3DSynchronizeContext( | 297 static NPError Device3DSynchronizeContext( |
| 295 NPP id, | 298 NPP id, |
| 296 NPDeviceContext* context, | 299 NPDeviceContext* context, |
| 297 NPDeviceSynchronizationMode mode, | 300 NPDeviceSynchronizationMode mode, |
| 298 const int32_t* input_attrib_list, | 301 const int32_t* input_attrib_list, |
| 299 int32_t* output_attrib_list, | 302 int32_t* output_attrib_list, |
| 300 NPDeviceSynchronizeContextCallbackPtr callback, | 303 NPDeviceSynchronizeContextCallbackPtr callback, |
| 301 void* callback_data) { | 304 void* callback_data) { |
| 302 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); | 305 scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
| 303 if (plugin) { | 306 if (plugin) { |
| 304 return plugin->webplugin()->delegate()->Device3DSynchronizeContext( | 307 return plugin->webplugin()->delegate()->Device3DSynchronizeContext( |
| 305 id, | 308 id, |
| 306 static_cast<NPDeviceContext3D*>(context), | 309 static_cast<NPDeviceContext3D*>(context), |
| 307 mode, | 310 mode, |
| 308 input_attrib_list, | 311 input_attrib_list, |
| 309 output_attrib_list, | 312 output_attrib_list, |
| 310 callback, | 313 callback, |
| 311 callback_data); | 314 callback_data); |
| 312 } | 315 } |
| 313 return NPERR_GENERIC_ERROR; | 316 return NPERR_GENERIC_ERROR; |
| 314 } | 317 } |
| 315 | 318 |
| 316 static NPError Device3DRegisterCallback( | 319 static NPError Device3DRegisterCallback( |
| 317 NPP id, | 320 NPP id, |
| 318 NPDeviceContext* context, | 321 NPDeviceContext* context, |
| 319 int32_t callback_type, | 322 int32_t callback_type, |
| 320 NPDeviceGenericCallbackPtr callback, | 323 NPDeviceGenericCallbackPtr callback, |
| 321 void* callback_data) { | 324 void* callback_data) { |
| 322 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); | 325 scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
| 323 if (plugin) { | 326 if (plugin) { |
| 324 return plugin->webplugin()->delegate()->Device3DRegisterCallback( | 327 return plugin->webplugin()->delegate()->Device3DRegisterCallback( |
| 325 id, | 328 id, |
| 326 static_cast<NPDeviceContext3D*>(context), | 329 static_cast<NPDeviceContext3D*>(context), |
| 327 callback_type, | 330 callback_type, |
| 328 callback, | 331 callback, |
| 329 callback_data); | 332 callback_data); |
| 330 } | 333 } |
| 331 return NPERR_GENERIC_ERROR; | 334 return NPERR_GENERIC_ERROR; |
| 332 } | 335 } |
| 333 | 336 |
| 334 // Audio device API ------------------------------------------------------------ | 337 // Audio device API ------------------------------------------------------------ |
| 335 | 338 |
| 336 static NPError DeviceAudioQueryCapability(NPP id, int32_t capability, | 339 static NPError DeviceAudioQueryCapability(NPP id, int32_t capability, |
| 337 int32_t* value) { | 340 int32_t* value) { |
| 338 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); | 341 scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
| 339 if (plugin) { | 342 if (plugin) { |
| 340 plugin->webplugin()->delegate()->DeviceAudioQueryCapability(capability, | 343 plugin->webplugin()->delegate()->DeviceAudioQueryCapability(capability, |
| 341 value); | 344 value); |
| 342 return NPERR_NO_ERROR; | 345 return NPERR_NO_ERROR; |
| 343 } else { | 346 } else { |
| 344 return NPERR_GENERIC_ERROR; | 347 return NPERR_GENERIC_ERROR; |
| 345 } | 348 } |
| 346 } | 349 } |
| 347 | 350 |
| 348 static NPError DeviceAudioQueryConfig(NPP id, | 351 static NPError DeviceAudioQueryConfig(NPP id, |
| 349 const NPDeviceConfig* request, | 352 const NPDeviceConfig* request, |
| 350 NPDeviceConfig* obtain) { | 353 NPDeviceConfig* obtain) { |
| 351 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); | 354 scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
| 352 if (plugin) { | 355 if (plugin) { |
| 353 return plugin->webplugin()->delegate()->DeviceAudioQueryConfig( | 356 return plugin->webplugin()->delegate()->DeviceAudioQueryConfig( |
| 354 static_cast<const NPDeviceContextAudioConfig*>(request), | 357 static_cast<const NPDeviceContextAudioConfig*>(request), |
| 355 static_cast<NPDeviceContextAudioConfig*>(obtain)); | 358 static_cast<NPDeviceContextAudioConfig*>(obtain)); |
| 356 } | 359 } |
| 357 return NPERR_GENERIC_ERROR; | 360 return NPERR_GENERIC_ERROR; |
| 358 } | 361 } |
| 359 | 362 |
| 360 static NPError DeviceAudioInitializeContext(NPP id, | 363 static NPError DeviceAudioInitializeContext(NPP id, |
| 361 const NPDeviceConfig* config, | 364 const NPDeviceConfig* config, |
| 362 NPDeviceContext* context) { | 365 NPDeviceContext* context) { |
| 363 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); | 366 scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
| 364 if (plugin) { | 367 if (plugin) { |
| 365 return plugin->webplugin()->delegate()->DeviceAudioInitializeContext( | 368 return plugin->webplugin()->delegate()->DeviceAudioInitializeContext( |
| 366 static_cast<const NPDeviceContextAudioConfig*>(config), | 369 static_cast<const NPDeviceContextAudioConfig*>(config), |
| 367 static_cast<NPDeviceContextAudio*>(context)); | 370 static_cast<NPDeviceContextAudio*>(context)); |
| 368 } | 371 } |
| 369 return NPERR_GENERIC_ERROR; | 372 return NPERR_GENERIC_ERROR; |
| 370 } | 373 } |
| 371 | 374 |
| 372 static NPError DeviceAudioSetStateContext(NPP id, | 375 static NPError DeviceAudioSetStateContext(NPP id, |
| 373 NPDeviceContext* context, | 376 NPDeviceContext* context, |
| 374 int32_t state, | 377 int32_t state, |
| 375 intptr_t value) { | 378 intptr_t value) { |
| 376 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); | 379 scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
| 377 if (plugin) { | 380 if (plugin) { |
| 378 return plugin->webplugin()->delegate()->DeviceAudioSetStateContext( | 381 return plugin->webplugin()->delegate()->DeviceAudioSetStateContext( |
| 379 static_cast<NPDeviceContextAudio*>(context), state, value); | 382 static_cast<NPDeviceContextAudio*>(context), state, value); |
| 380 } | 383 } |
| 381 return NPERR_GENERIC_ERROR; | 384 return NPERR_GENERIC_ERROR; |
| 382 } | 385 } |
| 383 | 386 |
| 384 static NPError DeviceAudioGetStateContext(NPP id, | 387 static NPError DeviceAudioGetStateContext(NPP id, |
| 385 NPDeviceContext* context, | 388 NPDeviceContext* context, |
| 386 int32_t state, | 389 int32_t state, |
| 387 intptr_t* value) { | 390 intptr_t* value) { |
| 388 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); | 391 scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
| 389 return plugin->webplugin()->delegate()->DeviceAudioGetStateContext( | 392 return plugin->webplugin()->delegate()->DeviceAudioGetStateContext( |
| 390 static_cast<NPDeviceContextAudio*>(context), state, value); | 393 static_cast<NPDeviceContextAudio*>(context), state, value); |
| 391 } | 394 } |
| 392 | 395 |
| 393 static NPError DeviceAudioFlushContext(NPP id, | 396 static NPError DeviceAudioFlushContext(NPP id, |
| 394 NPDeviceContext* context, | 397 NPDeviceContext* context, |
| 395 NPDeviceFlushContextCallbackPtr callback, | 398 NPDeviceFlushContextCallbackPtr callback, |
| 396 void* user_data) { | 399 void* user_data) { |
| 397 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); | 400 scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
| 398 return plugin->webplugin()->delegate()->DeviceAudioFlushContext( | 401 return plugin->webplugin()->delegate()->DeviceAudioFlushContext( |
| 399 id, static_cast<NPDeviceContextAudio*>(context), callback, user_data); | 402 id, static_cast<NPDeviceContextAudio*>(context), callback, user_data); |
| 400 } | 403 } |
| 401 | 404 |
| 402 static NPError DeviceAudioDestroyContext(NPP id, | 405 static NPError DeviceAudioDestroyContext(NPP id, |
| 403 NPDeviceContext* context) { | 406 NPDeviceContext* context) { |
| 404 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); | 407 scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
| 405 return plugin->webplugin()->delegate()->DeviceAudioDestroyContext( | 408 return plugin->webplugin()->delegate()->DeviceAudioDestroyContext( |
| 406 static_cast<NPDeviceContextAudio*>(context)); | 409 static_cast<NPDeviceContextAudio*>(context)); |
| 407 } | 410 } |
| 408 // ----------------------------------------------------------------------------- | 411 // ----------------------------------------------------------------------------- |
| 409 | 412 |
| 410 static NPDevice* AcquireDevice(NPP id, NPDeviceID device_id) { | 413 static NPDevice* AcquireDevice(NPP id, NPDeviceID device_id) { |
| 411 static NPDevice device_2d = { | 414 static NPDevice device_2d = { |
| 412 Device2DQueryCapability, | 415 Device2DQueryCapability, |
| 413 Device2DQueryConfig, | 416 Device2DQueryConfig, |
| 414 Device2DInitializeContext, | 417 Device2DInitializeContext, |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 default: | 473 default: |
| 471 return NULL; | 474 return NULL; |
| 472 } | 475 } |
| 473 } | 476 } |
| 474 | 477 |
| 475 static NPError ChooseFile(NPP id, | 478 static NPError ChooseFile(NPP id, |
| 476 const char* mime_types, | 479 const char* mime_types, |
| 477 NPChooseFileMode mode, | 480 NPChooseFileMode mode, |
| 478 NPChooseFileCallback callback, | 481 NPChooseFileCallback callback, |
| 479 void* user_data) { | 482 void* user_data) { |
| 480 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); | 483 scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
| 481 if (!plugin) | 484 if (!plugin) |
| 482 return NPERR_GENERIC_ERROR; | 485 return NPERR_GENERIC_ERROR; |
| 483 | 486 |
| 484 if (!plugin->webplugin()->delegate()->ChooseFile(mime_types, | 487 if (!plugin->webplugin()->delegate()->ChooseFile(mime_types, |
| 485 static_cast<int>(mode), | 488 static_cast<int>(mode), |
| 486 callback, user_data)) | 489 callback, user_data)) |
| 487 return NPERR_GENERIC_ERROR; | 490 return NPERR_GENERIC_ERROR; |
| 488 | 491 |
| 489 return NPERR_NO_ERROR; | 492 return NPERR_NO_ERROR; |
| 490 } | 493 } |
| 491 | 494 |
| 492 static void NumberOfFindResultsChanged(NPP id, int total, bool final_result) { | 495 static void NumberOfFindResultsChanged(NPP id, int total, bool final_result) { |
| 493 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); | 496 scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
| 494 if (plugin) { | 497 if (plugin) { |
| 495 plugin->webplugin()->delegate()->NumberOfFindResultsChanged( | 498 plugin->webplugin()->delegate()->NumberOfFindResultsChanged( |
| 496 total, final_result); | 499 total, final_result); |
| 497 } | 500 } |
| 498 } | 501 } |
| 499 | 502 |
| 500 static void SelectedFindResultChanged(NPP id, int index) { | 503 static void SelectedFindResultChanged(NPP id, int index) { |
| 501 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); | 504 scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
| 502 if (plugin) | 505 if (plugin) |
| 503 plugin->webplugin()->delegate()->SelectedFindResultChanged(index); | 506 plugin->webplugin()->delegate()->SelectedFindResultChanged(index); |
| 504 } | 507 } |
| 505 | 508 |
| 506 static NPWidgetExtensions* GetWidgetExtensions(NPP id) { | 509 static NPWidgetExtensions* GetWidgetExtensions(NPP id) { |
| 507 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); | 510 scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
| 508 if (!plugin) | 511 if (!plugin) |
| 509 return NULL; | 512 return NULL; |
| 510 | 513 |
| 511 return plugin->webplugin()->delegate()->GetWidgetExtensions(); | 514 return plugin->webplugin()->delegate()->GetWidgetExtensions(); |
| 512 } | 515 } |
| 513 | 516 |
| 514 static NPError NPSetCursor(NPP id, NPCursorType type) { | 517 static NPError NPSetCursor(NPP id, NPCursorType type) { |
| 515 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); | 518 scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
| 516 if (!plugin) | 519 if (!plugin) |
| 517 return NPERR_GENERIC_ERROR; | 520 return NPERR_GENERIC_ERROR; |
| 518 | 521 |
| 519 return plugin->webplugin()->delegate()->SetCursor(type) ? | 522 return plugin->webplugin()->delegate()->SetCursor(type) ? |
| 520 NPERR_NO_ERROR : NPERR_GENERIC_ERROR; | 523 NPERR_NO_ERROR : NPERR_GENERIC_ERROR; |
| 521 } | 524 } |
| 522 | 525 |
| 523 static NPFontExtensions* GetFontExtensions(NPP id) { | 526 static NPFontExtensions* GetFontExtensions(NPP id) { |
| 524 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); | 527 scoped_refptr<PluginInstance> plugin(FindInstance(id)); |
| 525 if (!plugin) | 528 if (!plugin) |
| 526 return NULL; | 529 return NULL; |
| 527 | 530 |
| 528 return plugin->webplugin()->delegate()->GetFontExtensions(); | 531 return plugin->webplugin()->delegate()->GetFontExtensions(); |
| 529 } | 532 } |
| 530 | 533 |
| 531 namespace NPAPI { | |
| 532 | |
| 533 NPError GetPepperExtensionsFunctions(void* value) { | 534 NPError GetPepperExtensionsFunctions(void* value) { |
| 534 static const NPNExtensions kExtensions = { | 535 static const NPNExtensions kExtensions = { |
| 535 &AcquireDevice, | 536 &AcquireDevice, |
| 536 &NumberOfFindResultsChanged, | 537 &NumberOfFindResultsChanged, |
| 537 &SelectedFindResultChanged, | 538 &SelectedFindResultChanged, |
| 538 &ChooseFile, | 539 &ChooseFile, |
| 539 &GetWidgetExtensions, | 540 &GetWidgetExtensions, |
| 540 &NPSetCursor, | 541 &NPSetCursor, |
| 541 &GetFontExtensions, | 542 &GetFontExtensions, |
| 542 }; | 543 }; |
| 543 | 544 |
| 544 // Return a pointer to the canonical function table. | 545 // Return a pointer to the canonical function table. |
| 545 NPNExtensions* extensions = const_cast<NPNExtensions*>(&kExtensions); | 546 NPNExtensions* extensions = const_cast<NPNExtensions*>(&kExtensions); |
| 546 NPNExtensions** exts = reinterpret_cast<NPNExtensions**>(value); | 547 NPNExtensions** exts = reinterpret_cast<NPNExtensions**>(value); |
| 547 *exts = extensions; | 548 *exts = extensions; |
| 548 return NPERR_NO_ERROR; | 549 return NPERR_NO_ERROR; |
| 549 } | 550 } |
| 550 | 551 |
| 551 } // namespace NPAPI | 552 } // namespace npapi |
| 553 } // namespace webkit |
| OLD | NEW |