| 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/plugin_host.h" | 5 #include "webkit/glue/plugins/plugin_host.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
| 10 #include "base/string_piece.h" | 10 #include "base/string_piece.h" |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 | 273 |
| 274 return !err; | 274 return !err; |
| 275 } | 275 } |
| 276 | 276 |
| 277 } // namespace NPAPI | 277 } // namespace NPAPI |
| 278 | 278 |
| 279 extern "C" { | 279 extern "C" { |
| 280 | 280 |
| 281 // Allocates memory from the host's memory space. | 281 // Allocates memory from the host's memory space. |
| 282 void* NPN_MemAlloc(uint32_t size) { | 282 void* NPN_MemAlloc(uint32_t size) { |
| 283 scoped_refptr<NPAPI::PluginHost> host = NPAPI::PluginHost::Singleton(); | 283 scoped_refptr<NPAPI::PluginHost> host(NPAPI::PluginHost::Singleton()); |
| 284 if (host != NULL) { | 284 if (host != NULL) { |
| 285 // Note: We must use the same allocator/deallocator | 285 // Note: We must use the same allocator/deallocator |
| 286 // that is used by the javascript library, as some of the | 286 // that is used by the javascript library, as some of the |
| 287 // JS APIs will pass memory to the plugin which the plugin | 287 // JS APIs will pass memory to the plugin which the plugin |
| 288 // will attempt to free. | 288 // will attempt to free. |
| 289 return malloc(size); | 289 return malloc(size); |
| 290 } | 290 } |
| 291 return NULL; | 291 return NULL; |
| 292 } | 292 } |
| 293 | 293 |
| 294 // Deallocates memory from the host's memory space | 294 // Deallocates memory from the host's memory space |
| 295 void NPN_MemFree(void* ptr) { | 295 void NPN_MemFree(void* ptr) { |
| 296 scoped_refptr<NPAPI::PluginHost> host = NPAPI::PluginHost::Singleton(); | 296 scoped_refptr<NPAPI::PluginHost> host(NPAPI::PluginHost::Singleton()); |
| 297 if (host != NULL) { | 297 if (host != NULL) { |
| 298 if (ptr != NULL && ptr != reinterpret_cast<void*>(-1)) | 298 if (ptr != NULL && ptr != reinterpret_cast<void*>(-1)) |
| 299 free(ptr); | 299 free(ptr); |
| 300 } | 300 } |
| 301 } | 301 } |
| 302 | 302 |
| 303 // Requests that the host free a specified amount of memory. | 303 // Requests that the host free a specified amount of memory. |
| 304 uint32_t NPN_MemFlush(uint32_t size) { | 304 uint32_t NPN_MemFlush(uint32_t size) { |
| 305 // This is not relevant on Windows; MAC specific | 305 // This is not relevant on Windows; MAC specific |
| 306 return size; | 306 return size; |
| 307 } | 307 } |
| 308 | 308 |
| 309 // This is for dynamic discovery of new plugins. | 309 // This is for dynamic discovery of new plugins. |
| 310 // Should force a re-scan of the plugins directory to load new ones. | 310 // Should force a re-scan of the plugins directory to load new ones. |
| 311 void NPN_ReloadPlugins(NPBool reloadPages) { | 311 void NPN_ReloadPlugins(NPBool reloadPages) { |
| 312 // TODO: implement me | 312 // TODO: implement me |
| 313 DVLOG(1) << "NPN_ReloadPlugin is not implemented yet."; | 313 DVLOG(1) << "NPN_ReloadPlugin is not implemented yet."; |
| 314 } | 314 } |
| 315 | 315 |
| 316 // Requests a range of bytes for a seekable stream. | 316 // Requests a range of bytes for a seekable stream. |
| 317 NPError NPN_RequestRead(NPStream* stream, NPByteRange* range_list) { | 317 NPError NPN_RequestRead(NPStream* stream, NPByteRange* range_list) { |
| 318 if (!stream || !range_list) | 318 if (!stream || !range_list) |
| 319 return NPERR_GENERIC_ERROR; | 319 return NPERR_GENERIC_ERROR; |
| 320 | 320 |
| 321 scoped_refptr<NPAPI::PluginInstance> plugin = | 321 scoped_refptr<NPAPI::PluginInstance> plugin( |
| 322 reinterpret_cast<NPAPI::PluginInstance*>(stream->ndata); | 322 reinterpret_cast<NPAPI::PluginInstance*>(stream->ndata)); |
| 323 if (!plugin.get()) | 323 if (!plugin.get()) |
| 324 return NPERR_GENERIC_ERROR; | 324 return NPERR_GENERIC_ERROR; |
| 325 | 325 |
| 326 plugin->RequestRead(stream, range_list); | 326 plugin->RequestRead(stream, range_list); |
| 327 return NPERR_NO_ERROR; | 327 return NPERR_NO_ERROR; |
| 328 } | 328 } |
| 329 | 329 |
| 330 // Generic form of GetURL for common code between GetURL and GetURLNotify. | 330 // Generic form of GetURL for common code between GetURL and GetURLNotify. |
| 331 static NPError GetURLNotify(NPP id, | 331 static NPError GetURLNotify(NPP id, |
| 332 const char* url, | 332 const char* url, |
| 333 const char* target, | 333 const char* target, |
| 334 bool notify, | 334 bool notify, |
| 335 void* notify_data) { | 335 void* notify_data) { |
| 336 if (!url) | 336 if (!url) |
| 337 return NPERR_INVALID_URL; | 337 return NPERR_INVALID_URL; |
| 338 | 338 |
| 339 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); | 339 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
| 340 if (!plugin.get()) { | 340 if (!plugin.get()) { |
| 341 NOTREACHED(); | 341 NOTREACHED(); |
| 342 return NPERR_GENERIC_ERROR; | 342 return NPERR_GENERIC_ERROR; |
| 343 } | 343 } |
| 344 | 344 |
| 345 plugin->RequestURL(url, "GET", target, NULL, 0, notify, notify_data); | 345 plugin->RequestURL(url, "GET", target, NULL, 0, notify, notify_data); |
| 346 return NPERR_NO_ERROR; | 346 return NPERR_NO_ERROR; |
| 347 } | 347 } |
| 348 | 348 |
| 349 // Requests creation of a new stream with the contents of the | 349 // Requests creation of a new stream with the contents of the |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 const char* url, | 394 const char* url, |
| 395 const char* target, | 395 const char* target, |
| 396 uint32_t len, | 396 uint32_t len, |
| 397 const char* buf, | 397 const char* buf, |
| 398 NPBool file, | 398 NPBool file, |
| 399 bool notify, | 399 bool notify, |
| 400 void* notify_data) { | 400 void* notify_data) { |
| 401 if (!url) | 401 if (!url) |
| 402 return NPERR_INVALID_URL; | 402 return NPERR_INVALID_URL; |
| 403 | 403 |
| 404 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); | 404 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
| 405 if (!plugin.get()) { | 405 if (!plugin.get()) { |
| 406 NOTREACHED(); | 406 NOTREACHED(); |
| 407 return NPERR_GENERIC_ERROR; | 407 return NPERR_GENERIC_ERROR; |
| 408 } | 408 } |
| 409 | 409 |
| 410 std::string post_file_contents; | 410 std::string post_file_contents; |
| 411 | 411 |
| 412 if (file) { | 412 if (file) { |
| 413 // Post data to be uploaded from a file. This can be handled in two | 413 // Post data to be uploaded from a file. This can be handled in two |
| 414 // ways. | 414 // ways. |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 NPError NPN_DestroyStream(NPP id, NPStream* stream, NPReason reason) { | 541 NPError NPN_DestroyStream(NPP id, NPStream* stream, NPReason reason) { |
| 542 // Destroys a stream (could be created by plugin or browser). | 542 // Destroys a stream (could be created by plugin or browser). |
| 543 // | 543 // |
| 544 // Reasons: | 544 // Reasons: |
| 545 // NPRES_DONE - normal completion | 545 // NPRES_DONE - normal completion |
| 546 // NPRES_USER_BREAK - user terminated | 546 // NPRES_USER_BREAK - user terminated |
| 547 // NPRES_NETWORK_ERROR - network error (all errors fit here?) | 547 // NPRES_NETWORK_ERROR - network error (all errors fit here?) |
| 548 // | 548 // |
| 549 // | 549 // |
| 550 | 550 |
| 551 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); | 551 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
| 552 if (plugin.get() == NULL) { | 552 if (plugin.get() == NULL) { |
| 553 NOTREACHED(); | 553 NOTREACHED(); |
| 554 return NPERR_GENERIC_ERROR; | 554 return NPERR_GENERIC_ERROR; |
| 555 } | 555 } |
| 556 | 556 |
| 557 return plugin->NPP_DestroyStream(stream, reason); | 557 return plugin->NPP_DestroyStream(stream, reason); |
| 558 } | 558 } |
| 559 | 559 |
| 560 const char* NPN_UserAgent(NPP id) { | 560 const char* NPN_UserAgent(NPP id) { |
| 561 #if defined(OS_WIN) | 561 #if defined(OS_WIN) |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 | 603 |
| 604 // Before a windowless plugin can refresh part of its drawing area, it must | 604 // Before a windowless plugin can refresh part of its drawing area, it must |
| 605 // first invalidate it. This function causes the NPP_HandleEvent method to | 605 // first invalidate it. This function causes the NPP_HandleEvent method to |
| 606 // pass an update event or a paint message to the plug-in. After calling | 606 // pass an update event or a paint message to the plug-in. After calling |
| 607 // this method, the plug-in recieves a paint message asynchronously. | 607 // this method, the plug-in recieves a paint message asynchronously. |
| 608 | 608 |
| 609 // The browser redraws invalid areas of the document and any windowless | 609 // The browser redraws invalid areas of the document and any windowless |
| 610 // plug-ins at regularly timed intervals. To force a paint message, the | 610 // plug-ins at regularly timed intervals. To force a paint message, the |
| 611 // plug-in can call NPN_ForceRedraw after calling this method. | 611 // plug-in can call NPN_ForceRedraw after calling this method. |
| 612 | 612 |
| 613 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); | 613 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
| 614 DCHECK(plugin.get() != NULL); | 614 DCHECK(plugin.get() != NULL); |
| 615 if (plugin.get() && plugin->webplugin()) { | 615 if (plugin.get() && plugin->webplugin()) { |
| 616 if (invalidRect) { | 616 if (invalidRect) { |
| 617 #if defined(OS_WIN) | 617 #if defined(OS_WIN) |
| 618 if (!plugin->windowless()) { | 618 if (!plugin->windowless()) { |
| 619 RECT rect = {0}; | 619 RECT rect = {0}; |
| 620 rect.left = invalidRect->left; | 620 rect.left = invalidRect->left; |
| 621 rect.right = invalidRect->right; | 621 rect.right = invalidRect->right; |
| 622 rect.top = invalidRect->top; | 622 rect.top = invalidRect->top; |
| 623 rect.bottom = invalidRect->bottom; | 623 rect.bottom = invalidRect->bottom; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 637 } | 637 } |
| 638 | 638 |
| 639 void NPN_InvalidateRegion(NPP id, NPRegion invalidRegion) { | 639 void NPN_InvalidateRegion(NPP id, NPRegion invalidRegion) { |
| 640 // Invalidates a specified drawing region prior to repainting | 640 // Invalidates a specified drawing region prior to repainting |
| 641 // or refreshing a window-less plugin. | 641 // or refreshing a window-less plugin. |
| 642 // | 642 // |
| 643 // Similar to NPN_InvalidateRect. | 643 // Similar to NPN_InvalidateRect. |
| 644 | 644 |
| 645 // TODO: this is overkill--add platform-specific region handling (at the | 645 // TODO: this is overkill--add platform-specific region handling (at the |
| 646 // very least, fetch the region's bounding box and pass it to InvalidateRect). | 646 // very least, fetch the region's bounding box and pass it to InvalidateRect). |
| 647 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); | 647 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
| 648 DCHECK(plugin.get() != NULL); | 648 DCHECK(plugin.get() != NULL); |
| 649 if (plugin.get() && plugin->webplugin()) | 649 if (plugin.get() && plugin->webplugin()) |
| 650 plugin->webplugin()->Invalidate(); | 650 plugin->webplugin()->Invalidate(); |
| 651 } | 651 } |
| 652 | 652 |
| 653 void NPN_ForceRedraw(NPP id) { | 653 void NPN_ForceRedraw(NPP id) { |
| 654 // Forces repaint for a windowless plug-in. | 654 // Forces repaint for a windowless plug-in. |
| 655 // | 655 // |
| 656 // We deliberately do not implement this; we don't want plugins forcing | 656 // We deliberately do not implement this; we don't want plugins forcing |
| 657 // synchronous paints. | 657 // synchronous paints. |
| 658 } | 658 } |
| 659 | 659 |
| 660 NPError NPN_GetValue(NPP id, NPNVariable variable, void* value) { | 660 NPError NPN_GetValue(NPP id, NPNVariable variable, void* value) { |
| 661 // Allows the plugin to query the browser for information | 661 // Allows the plugin to query the browser for information |
| 662 // | 662 // |
| 663 // Variables: | 663 // Variables: |
| 664 // NPNVxDisplay (unix only) | 664 // NPNVxDisplay (unix only) |
| 665 // NPNVxtAppContext (unix only) | 665 // NPNVxtAppContext (unix only) |
| 666 // NPNVnetscapeWindow (win only) - Gets the native window on which the | 666 // NPNVnetscapeWindow (win only) - Gets the native window on which the |
| 667 // plug-in drawing occurs, returns HWND | 667 // plug-in drawing occurs, returns HWND |
| 668 // NPNVjavascriptEnabledBool: tells whether Javascript is enabled | 668 // NPNVjavascriptEnabledBool: tells whether Javascript is enabled |
| 669 // NPNVasdEnabledBool: tells whether SmartUpdate is enabled | 669 // NPNVasdEnabledBool: tells whether SmartUpdate is enabled |
| 670 // NPNVOfflineBool: tells whether offline-mode is enabled | 670 // NPNVOfflineBool: tells whether offline-mode is enabled |
| 671 | 671 |
| 672 NPError rv = NPERR_GENERIC_ERROR; | 672 NPError rv = NPERR_GENERIC_ERROR; |
| 673 | 673 |
| 674 switch (static_cast<int>(variable)) { | 674 switch (static_cast<int>(variable)) { |
| 675 case NPNVWindowNPObject: { | 675 case NPNVWindowNPObject: { |
| 676 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); | 676 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
| 677 NPObject *np_object = plugin->webplugin()->GetWindowScriptNPObject(); | 677 NPObject *np_object = plugin->webplugin()->GetWindowScriptNPObject(); |
| 678 // Return value is expected to be retained, as | 678 // Return value is expected to be retained, as |
| 679 // described here: | 679 // described here: |
| 680 // <http://www.mozilla.org/projects/plugins/npruntime.html#browseraccess> | 680 // <http://www.mozilla.org/projects/plugins/npruntime.html#browseraccess> |
| 681 if (np_object) { | 681 if (np_object) { |
| 682 WebBindings::retainObject(np_object); | 682 WebBindings::retainObject(np_object); |
| 683 void **v = (void **)value; | 683 void **v = (void **)value; |
| 684 *v = np_object; | 684 *v = np_object; |
| 685 rv = NPERR_NO_ERROR; | 685 rv = NPERR_NO_ERROR; |
| 686 } else { | 686 } else { |
| 687 NOTREACHED(); | 687 NOTREACHED(); |
| 688 } | 688 } |
| 689 break; | 689 break; |
| 690 } | 690 } |
| 691 case NPNVPluginElementNPObject: { | 691 case NPNVPluginElementNPObject: { |
| 692 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); | 692 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
| 693 NPObject *np_object = plugin->webplugin()->GetPluginElement(); | 693 NPObject *np_object = plugin->webplugin()->GetPluginElement(); |
| 694 // Return value is expected to be retained, as | 694 // Return value is expected to be retained, as |
| 695 // described here: | 695 // described here: |
| 696 // <http://www.mozilla.org/projects/plugins/npruntime.html#browseraccess> | 696 // <http://www.mozilla.org/projects/plugins/npruntime.html#browseraccess> |
| 697 if (np_object) { | 697 if (np_object) { |
| 698 WebBindings::retainObject(np_object); | 698 WebBindings::retainObject(np_object); |
| 699 void** v = static_cast<void**>(value); | 699 void** v = static_cast<void**>(value); |
| 700 *v = np_object; | 700 *v = np_object; |
| 701 rv = NPERR_NO_ERROR; | 701 rv = NPERR_NO_ERROR; |
| 702 } else { | 702 } else { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 736 break; | 736 break; |
| 737 #endif | 737 #endif |
| 738 case NPNVSupportsWindowless: { | 738 case NPNVSupportsWindowless: { |
| 739 NPBool* supports_windowless = reinterpret_cast<NPBool*>(value); | 739 NPBool* supports_windowless = reinterpret_cast<NPBool*>(value); |
| 740 *supports_windowless = true; | 740 *supports_windowless = true; |
| 741 rv = NPERR_NO_ERROR; | 741 rv = NPERR_NO_ERROR; |
| 742 break; | 742 break; |
| 743 } | 743 } |
| 744 case NPNVprivateModeBool: { | 744 case NPNVprivateModeBool: { |
| 745 NPBool* private_mode = reinterpret_cast<NPBool*>(value); | 745 NPBool* private_mode = reinterpret_cast<NPBool*>(value); |
| 746 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); | 746 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
| 747 *private_mode = plugin->webplugin()->IsOffTheRecord(); | 747 *private_mode = plugin->webplugin()->IsOffTheRecord(); |
| 748 rv = NPERR_NO_ERROR; | 748 rv = NPERR_NO_ERROR; |
| 749 break; | 749 break; |
| 750 } | 750 } |
| 751 case default_plugin::kMissingPluginStatusStart + | 751 case default_plugin::kMissingPluginStatusStart + |
| 752 default_plugin::MISSING_PLUGIN_AVAILABLE: | 752 default_plugin::MISSING_PLUGIN_AVAILABLE: |
| 753 // fall through | 753 // fall through |
| 754 case default_plugin::kMissingPluginStatusStart + | 754 case default_plugin::kMissingPluginStatusStart + |
| 755 default_plugin::MISSING_PLUGIN_USER_STARTED_DOWNLOAD: { | 755 default_plugin::MISSING_PLUGIN_USER_STARTED_DOWNLOAD: { |
| 756 // This is a hack for the default plugin to send notification to | 756 // This is a hack for the default plugin to send notification to |
| 757 // renderer. Even though we check if the plugin is the default plugin, | 757 // renderer. Even though we check if the plugin is the default plugin, |
| 758 // we still need to worry about future standard change that may conflict | 758 // we still need to worry about future standard change that may conflict |
| 759 // with the variable definition, in order to avoid duplicate case clauses | 759 // with the variable definition, in order to avoid duplicate case clauses |
| 760 // in this big switch statement. | 760 // in this big switch statement. |
| 761 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); | 761 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
| 762 if (plugin->plugin_lib()->plugin_info().path.value() == | 762 if (plugin->plugin_lib()->plugin_info().path.value() == |
| 763 kDefaultPluginLibraryName) { | 763 kDefaultPluginLibraryName) { |
| 764 plugin->webplugin()->OnMissingPluginStatus( | 764 plugin->webplugin()->OnMissingPluginStatus( |
| 765 variable - default_plugin::kMissingPluginStatusStart); | 765 variable - default_plugin::kMissingPluginStatusStart); |
| 766 } | 766 } |
| 767 break; | 767 break; |
| 768 } | 768 } |
| 769 #if defined(OS_MACOSX) | 769 #if defined(OS_MACOSX) |
| 770 case NPNVpluginDrawingModel: { | 770 case NPNVpluginDrawingModel: { |
| 771 // return the drawing model that was negotiated when we initialized. | 771 // return the drawing model that was negotiated when we initialized. |
| 772 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); | 772 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
| 773 *reinterpret_cast<int*>(value) = plugin->drawing_model(); | 773 *reinterpret_cast<int*>(value) = plugin->drawing_model(); |
| 774 rv = NPERR_NO_ERROR; | 774 rv = NPERR_NO_ERROR; |
| 775 break; | 775 break; |
| 776 } | 776 } |
| 777 #ifndef NP_NO_QUICKDRAW | 777 #ifndef NP_NO_QUICKDRAW |
| 778 case NPNVsupportsQuickDrawBool: { | 778 case NPNVsupportsQuickDrawBool: { |
| 779 // We do not admit to supporting the QuickDraw drawing model. The logic | 779 // We do not admit to supporting the QuickDraw drawing model. The logic |
| 780 // here is that our QuickDraw plugin support is so rudimentary that we | 780 // here is that our QuickDraw plugin support is so rudimentary that we |
| 781 // only want to use it as a fallback to keep plugins from crashing: if a | 781 // only want to use it as a fallback to keep plugins from crashing: if a |
| 782 // plugin knows enough to ask, we want them to use CoreGraphics. | 782 // plugin knows enough to ask, we want them to use CoreGraphics. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 831 default: | 831 default: |
| 832 DVLOG(1) << "NPN_GetValue(" << variable << ") is not implemented yet."; | 832 DVLOG(1) << "NPN_GetValue(" << variable << ") is not implemented yet."; |
| 833 break; | 833 break; |
| 834 } | 834 } |
| 835 return rv; | 835 return rv; |
| 836 } | 836 } |
| 837 | 837 |
| 838 NPError NPN_SetValue(NPP id, NPPVariable variable, void* value) { | 838 NPError NPN_SetValue(NPP id, NPPVariable variable, void* value) { |
| 839 // Allows the plugin to set various modes | 839 // Allows the plugin to set various modes |
| 840 | 840 |
| 841 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); | 841 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
| 842 switch(variable) { | 842 switch(variable) { |
| 843 case NPPVpluginWindowBool: { | 843 case NPPVpluginWindowBool: { |
| 844 // Sets windowless mode for display of the plugin | 844 // Sets windowless mode for display of the plugin |
| 845 // Note: the documentation at | 845 // Note: the documentation at |
| 846 // http://developer.mozilla.org/en/docs/NPN_SetValue is wrong. When | 846 // http://developer.mozilla.org/en/docs/NPN_SetValue is wrong. When |
| 847 // value is NULL, the mode is set to true. This is the same way Mozilla | 847 // value is NULL, the mode is set to true. This is the same way Mozilla |
| 848 // works. | 848 // works. |
| 849 plugin->set_windowless(value == 0); | 849 plugin->set_windowless(value == 0); |
| 850 return NPERR_NO_ERROR; | 850 return NPERR_NO_ERROR; |
| 851 } | 851 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 916 return NULL; | 916 return NULL; |
| 917 } | 917 } |
| 918 | 918 |
| 919 void* NPN_GetJavaPeer(NPP) { | 919 void* NPN_GetJavaPeer(NPP) { |
| 920 // TODO: implement me | 920 // TODO: implement me |
| 921 DVLOG(1) << "NPN_GetJavaPeer is not implemented."; | 921 DVLOG(1) << "NPN_GetJavaPeer is not implemented."; |
| 922 return NULL; | 922 return NULL; |
| 923 } | 923 } |
| 924 | 924 |
| 925 void NPN_PushPopupsEnabledState(NPP id, NPBool enabled) { | 925 void NPN_PushPopupsEnabledState(NPP id, NPBool enabled) { |
| 926 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); | 926 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
| 927 if (plugin) | 927 if (plugin) |
| 928 plugin->PushPopupsEnabledState(enabled ? true : false); | 928 plugin->PushPopupsEnabledState(enabled ? true : false); |
| 929 } | 929 } |
| 930 | 930 |
| 931 void NPN_PopPopupsEnabledState(NPP id) { | 931 void NPN_PopPopupsEnabledState(NPP id) { |
| 932 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); | 932 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
| 933 if (plugin) | 933 if (plugin) |
| 934 plugin->PopPopupsEnabledState(); | 934 plugin->PopPopupsEnabledState(); |
| 935 } | 935 } |
| 936 | 936 |
| 937 void NPN_PluginThreadAsyncCall(NPP id, | 937 void NPN_PluginThreadAsyncCall(NPP id, |
| 938 void (*func)(void*), | 938 void (*func)(void*), |
| 939 void* user_data) { | 939 void* user_data) { |
| 940 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); | 940 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
| 941 if (plugin) | 941 if (plugin) |
| 942 plugin->PluginThreadAsyncCall(func, user_data); | 942 plugin->PluginThreadAsyncCall(func, user_data); |
| 943 } | 943 } |
| 944 | 944 |
| 945 NPError NPN_GetValueForURL(NPP id, | 945 NPError NPN_GetValueForURL(NPP id, |
| 946 NPNURLVariable variable, | 946 NPNURLVariable variable, |
| 947 const char* url, | 947 const char* url, |
| 948 char** value, | 948 char** value, |
| 949 uint32_t* len) { | 949 uint32_t* len) { |
| 950 if (!id) | 950 if (!id) |
| 951 return NPERR_INVALID_PARAM; | 951 return NPERR_INVALID_PARAM; |
| 952 | 952 |
| 953 if (!url || !*url || !len) | 953 if (!url || !*url || !len) |
| 954 return NPERR_INVALID_URL; | 954 return NPERR_INVALID_URL; |
| 955 | 955 |
| 956 *len = 0; | 956 *len = 0; |
| 957 std::string result; | 957 std::string result; |
| 958 | 958 |
| 959 switch (variable) { | 959 switch (variable) { |
| 960 case NPNURLVProxy: { | 960 case NPNURLVProxy: { |
| 961 result = "DIRECT"; | 961 result = "DIRECT"; |
| 962 if (!webkit_glue::FindProxyForUrl(GURL((std::string(url))), &result)) | 962 if (!webkit_glue::FindProxyForUrl(GURL((std::string(url))), &result)) |
| 963 return NPERR_GENERIC_ERROR; | 963 return NPERR_GENERIC_ERROR; |
| 964 | 964 |
| 965 break; | 965 break; |
| 966 } | 966 } |
| 967 case NPNURLVCookie: { | 967 case NPNURLVCookie: { |
| 968 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); | 968 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
| 969 if (!plugin) | 969 if (!plugin) |
| 970 return NPERR_GENERIC_ERROR; | 970 return NPERR_GENERIC_ERROR; |
| 971 | 971 |
| 972 webkit_glue::WebPlugin* webplugin = plugin->webplugin(); | 972 webkit_glue::WebPlugin* webplugin = plugin->webplugin(); |
| 973 if (!webplugin) | 973 if (!webplugin) |
| 974 return NPERR_GENERIC_ERROR; | 974 return NPERR_GENERIC_ERROR; |
| 975 | 975 |
| 976 // Bypass third-party cookie blocking by using the url as the | 976 // Bypass third-party cookie blocking by using the url as the |
| 977 // first_party_for_cookies. | 977 // first_party_for_cookies. |
| 978 GURL cookies_url((std::string(url))); | 978 GURL cookies_url((std::string(url))); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 998 const char* value, | 998 const char* value, |
| 999 uint32_t len) { | 999 uint32_t len) { |
| 1000 if (!id) | 1000 if (!id) |
| 1001 return NPERR_INVALID_PARAM; | 1001 return NPERR_INVALID_PARAM; |
| 1002 | 1002 |
| 1003 if (!url || !*url) | 1003 if (!url || !*url) |
| 1004 return NPERR_INVALID_URL; | 1004 return NPERR_INVALID_URL; |
| 1005 | 1005 |
| 1006 switch (variable) { | 1006 switch (variable) { |
| 1007 case NPNURLVCookie: { | 1007 case NPNURLVCookie: { |
| 1008 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); | 1008 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
| 1009 if (!plugin) | 1009 if (!plugin) |
| 1010 return NPERR_GENERIC_ERROR; | 1010 return NPERR_GENERIC_ERROR; |
| 1011 | 1011 |
| 1012 webkit_glue::WebPlugin* webplugin = plugin->webplugin(); | 1012 webkit_glue::WebPlugin* webplugin = plugin->webplugin(); |
| 1013 if (!webplugin) | 1013 if (!webplugin) |
| 1014 return NPERR_GENERIC_ERROR; | 1014 return NPERR_GENERIC_ERROR; |
| 1015 | 1015 |
| 1016 std::string cookie(value, len); | 1016 std::string cookie(value, len); |
| 1017 GURL cookies_url((std::string(url))); | 1017 GURL cookies_url((std::string(url))); |
| 1018 webplugin->SetCookie(cookies_url, cookies_url, cookie); | 1018 webplugin->SetCookie(cookies_url, cookies_url, cookie); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1044 return NPERR_INVALID_PARAM; | 1044 return NPERR_INVALID_PARAM; |
| 1045 | 1045 |
| 1046 // TODO: implement me (bug 23928) | 1046 // TODO: implement me (bug 23928) |
| 1047 return NPERR_GENERIC_ERROR; | 1047 return NPERR_GENERIC_ERROR; |
| 1048 } | 1048 } |
| 1049 | 1049 |
| 1050 uint32_t NPN_ScheduleTimer(NPP id, | 1050 uint32_t NPN_ScheduleTimer(NPP id, |
| 1051 uint32_t interval, | 1051 uint32_t interval, |
| 1052 NPBool repeat, | 1052 NPBool repeat, |
| 1053 void (*func)(NPP id, uint32_t timer_id)) { | 1053 void (*func)(NPP id, uint32_t timer_id)) { |
| 1054 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); | 1054 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
| 1055 if (!plugin) | 1055 if (!plugin) |
| 1056 return 0; | 1056 return 0; |
| 1057 | 1057 |
| 1058 return plugin->ScheduleTimer(interval, repeat, func); | 1058 return plugin->ScheduleTimer(interval, repeat, func); |
| 1059 } | 1059 } |
| 1060 | 1060 |
| 1061 void NPN_UnscheduleTimer(NPP id, uint32_t timer_id) { | 1061 void NPN_UnscheduleTimer(NPP id, uint32_t timer_id) { |
| 1062 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); | 1062 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
| 1063 if (plugin) | 1063 if (plugin) |
| 1064 plugin->UnscheduleTimer(timer_id); | 1064 plugin->UnscheduleTimer(timer_id); |
| 1065 } | 1065 } |
| 1066 | 1066 |
| 1067 NPError NPN_PopUpContextMenu(NPP id, NPMenu* menu) { | 1067 NPError NPN_PopUpContextMenu(NPP id, NPMenu* menu) { |
| 1068 if (!menu) | 1068 if (!menu) |
| 1069 return NPERR_INVALID_PARAM; | 1069 return NPERR_INVALID_PARAM; |
| 1070 | 1070 |
| 1071 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); | 1071 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
| 1072 if (plugin.get()) { | 1072 if (plugin.get()) { |
| 1073 return plugin->PopUpContextMenu(menu); | 1073 return plugin->PopUpContextMenu(menu); |
| 1074 } | 1074 } |
| 1075 NOTREACHED(); | 1075 NOTREACHED(); |
| 1076 return NPERR_GENERIC_ERROR; | 1076 return NPERR_GENERIC_ERROR; |
| 1077 } | 1077 } |
| 1078 | 1078 |
| 1079 NPBool NPN_ConvertPoint(NPP id, double sourceX, double sourceY, | 1079 NPBool NPN_ConvertPoint(NPP id, double sourceX, double sourceY, |
| 1080 NPCoordinateSpace sourceSpace, | 1080 NPCoordinateSpace sourceSpace, |
| 1081 double *destX, double *destY, | 1081 double *destX, double *destY, |
| 1082 NPCoordinateSpace destSpace) { | 1082 NPCoordinateSpace destSpace) { |
| 1083 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); | 1083 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id)); |
| 1084 if (plugin.get()) { | 1084 if (plugin.get()) { |
| 1085 return plugin->ConvertPoint(sourceX, sourceY, sourceSpace, | 1085 return plugin->ConvertPoint(sourceX, sourceY, sourceSpace, |
| 1086 destX, destY, destSpace); | 1086 destX, destY, destSpace); |
| 1087 } | 1087 } |
| 1088 NOTREACHED(); | 1088 NOTREACHED(); |
| 1089 return false; | 1089 return false; |
| 1090 } | 1090 } |
| 1091 | 1091 |
| 1092 } // extern "C" | 1092 } // extern "C" |
| OLD | NEW |