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