OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/renderer/pepper_plugin_delegate_impl.h" | 5 #include "content/renderer/pepper_plugin_delegate_impl.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <queue> | 8 #include <queue> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 #include "content/renderer/webplugin_delegate_proxy.h" | 47 #include "content/renderer/webplugin_delegate_proxy.h" |
48 #include "ipc/ipc_channel_handle.h" | 48 #include "ipc/ipc_channel_handle.h" |
49 #include "media/audio/audio_manager_base.h" | 49 #include "media/audio/audio_manager_base.h" |
50 #include "media/video/capture/video_capture_proxy.h" | 50 #include "media/video/capture/video_capture_proxy.h" |
51 #include "ppapi/c/dev/pp_video_dev.h" | 51 #include "ppapi/c/dev/pp_video_dev.h" |
52 #include "ppapi/c/pp_errors.h" | 52 #include "ppapi/c/pp_errors.h" |
53 #include "ppapi/c/private/ppb_flash.h" | 53 #include "ppapi/c/private/ppb_flash.h" |
54 #include "ppapi/c/private/ppb_flash_net_connector.h" | 54 #include "ppapi/c/private/ppb_flash_net_connector.h" |
55 #include "ppapi/proxy/host_dispatcher.h" | 55 #include "ppapi/proxy/host_dispatcher.h" |
56 #include "ppapi/proxy/ppapi_messages.h" | 56 #include "ppapi/proxy/ppapi_messages.h" |
| 57 #include "ppapi/shared_impl/platform_file.h" |
57 #include "ppapi/shared_impl/ppapi_preferences.h" | 58 #include "ppapi/shared_impl/ppapi_preferences.h" |
58 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" | 59 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" |
59 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserComplet
ion.h" | 60 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserComplet
ion.h" |
60 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams.
h" | 61 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams.
h" |
61 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 62 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
62 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" | 63 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" |
63 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" | 64 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" |
64 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 65 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
65 #include "ui/gfx/size.h" | 66 #include "ui/gfx/size.h" |
66 #include "ui/gfx/surface/transport_dib.h" | 67 #include "ui/gfx/surface/transport_dib.h" |
67 #include "webkit/fileapi/file_system_callback_dispatcher.h" | 68 #include "webkit/fileapi/file_system_callback_dispatcher.h" |
68 #include "webkit/glue/context_menu.h" | 69 #include "webkit/glue/context_menu.h" |
69 #include "webkit/plugins/npapi/webplugin.h" | 70 #include "webkit/plugins/npapi/webplugin.h" |
70 #include "webkit/plugins/ppapi/file_path.h" | 71 #include "webkit/plugins/ppapi/file_path.h" |
71 #include "webkit/plugins/ppapi/ppb_file_io_impl.h" | 72 #include "webkit/plugins/ppapi/ppb_file_io_impl.h" |
72 #include "webkit/plugins/ppapi/plugin_module.h" | 73 #include "webkit/plugins/ppapi/plugin_module.h" |
73 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 74 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
74 #include "webkit/plugins/ppapi/ppb_broker_impl.h" | 75 #include "webkit/plugins/ppapi/ppb_broker_impl.h" |
75 #include "webkit/plugins/ppapi/ppb_flash_impl.h" | 76 #include "webkit/plugins/ppapi/ppb_flash_impl.h" |
76 #include "webkit/plugins/ppapi/ppb_flash_net_connector_impl.h" | 77 #include "webkit/plugins/ppapi/ppb_flash_net_connector_impl.h" |
77 #include "webkit/plugins/ppapi/resource_helper.h" | 78 #include "webkit/plugins/ppapi/resource_helper.h" |
78 #include "webkit/plugins/webplugininfo.h" | 79 #include "webkit/plugins/webplugininfo.h" |
79 | 80 |
80 using WebKit::WebView; | 81 using WebKit::WebView; |
81 | 82 |
82 namespace { | 83 namespace { |
83 | 84 |
84 int32_t PlatformFileToInt(base::PlatformFile handle) { | |
85 #if defined(OS_WIN) | |
86 return static_cast<int32_t>(reinterpret_cast<intptr_t>(handle)); | |
87 #elif defined(OS_POSIX) | |
88 return handle; | |
89 #else | |
90 #error Not implemented. | |
91 #endif | |
92 } | |
93 | |
94 base::SyncSocket::Handle DuplicateHandle(base::SyncSocket::Handle handle) { | 85 base::SyncSocket::Handle DuplicateHandle(base::SyncSocket::Handle handle) { |
95 base::SyncSocket::Handle out_handle = base::kInvalidPlatformFileValue; | 86 base::SyncSocket::Handle out_handle = base::kInvalidPlatformFileValue; |
96 #if defined(OS_WIN) | 87 #if defined(OS_WIN) |
97 DWORD options = DUPLICATE_SAME_ACCESS; | 88 DWORD options = DUPLICATE_SAME_ACCESS; |
98 if (!::DuplicateHandle(::GetCurrentProcess(), | 89 if (!::DuplicateHandle(::GetCurrentProcess(), |
99 handle, | 90 handle, |
100 ::GetCurrentProcess(), | 91 ::GetCurrentProcess(), |
101 &out_handle, | 92 &out_handle, |
102 0, | 93 0, |
103 FALSE, | 94 FALSE, |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 plugin_module_->SetBroker(this); | 706 plugin_module_->SetBroker(this); |
716 } | 707 } |
717 | 708 |
718 PpapiBrokerImpl::~PpapiBrokerImpl() { | 709 PpapiBrokerImpl::~PpapiBrokerImpl() { |
719 // Report failure to all clients that had pending operations. | 710 // Report failure to all clients that had pending operations. |
720 for (ClientMap::iterator i = pending_connects_.begin(); | 711 for (ClientMap::iterator i = pending_connects_.begin(); |
721 i != pending_connects_.end(); ++i) { | 712 i != pending_connects_.end(); ++i) { |
722 base::WeakPtr<webkit::ppapi::PPB_Broker_Impl>& weak_ptr = i->second; | 713 base::WeakPtr<webkit::ppapi::PPB_Broker_Impl>& weak_ptr = i->second; |
723 if (weak_ptr) { | 714 if (weak_ptr) { |
724 weak_ptr->BrokerConnected( | 715 weak_ptr->BrokerConnected( |
725 PlatformFileToInt(base::kInvalidPlatformFileValue), PP_ERROR_ABORTED); | 716 ppapi::PlatformFileToInt(base::kInvalidPlatformFileValue), |
| 717 PP_ERROR_ABORTED); |
726 } | 718 } |
727 } | 719 } |
728 pending_connects_.clear(); | 720 pending_connects_.clear(); |
729 | 721 |
730 plugin_module_->SetBroker(NULL); | 722 plugin_module_->SetBroker(NULL); |
731 plugin_module_ = NULL; | 723 plugin_module_ = NULL; |
732 } | 724 } |
733 | 725 |
734 // If the channel is not ready, queue the connection. | 726 // If the channel is not ready, queue the connection. |
735 void PpapiBrokerImpl::Connect(webkit::ppapi::PPB_Broker_Impl* client) { | 727 void PpapiBrokerImpl::Connect(webkit::ppapi::PPB_Broker_Impl* client) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 if (weak_ptr) | 794 if (weak_ptr) |
803 ConnectPluginToBroker(weak_ptr); | 795 ConnectPluginToBroker(weak_ptr); |
804 } | 796 } |
805 } else { | 797 } else { |
806 // Report failure to all clients. | 798 // Report failure to all clients. |
807 for (ClientMap::iterator i = pending_connects_.begin(); | 799 for (ClientMap::iterator i = pending_connects_.begin(); |
808 i != pending_connects_.end(); ++i) { | 800 i != pending_connects_.end(); ++i) { |
809 base::WeakPtr<webkit::ppapi::PPB_Broker_Impl>& weak_ptr = i->second; | 801 base::WeakPtr<webkit::ppapi::PPB_Broker_Impl>& weak_ptr = i->second; |
810 if (weak_ptr) { | 802 if (weak_ptr) { |
811 weak_ptr->BrokerConnected( | 803 weak_ptr->BrokerConnected( |
812 PlatformFileToInt(base::kInvalidPlatformFileValue), | 804 ppapi::PlatformFileToInt(base::kInvalidPlatformFileValue), |
813 PP_ERROR_FAILED); | 805 PP_ERROR_FAILED); |
814 } | 806 } |
815 } | 807 } |
816 } | 808 } |
817 pending_connects_.clear(); | 809 pending_connects_.clear(); |
818 } | 810 } |
819 | 811 |
820 void PpapiBrokerImpl::ConnectPluginToBroker( | 812 void PpapiBrokerImpl::ConnectPluginToBroker( |
821 webkit::ppapi::PPB_Broker_Impl* client) { | 813 webkit::ppapi::PPB_Broker_Impl* client) { |
822 base::SyncSocket::Handle plugin_handle = base::kInvalidPlatformFileValue; | 814 base::SyncSocket::Handle plugin_handle = base::kInvalidPlatformFileValue; |
(...skipping 15 matching lines...) Expand all Loading... |
838 plugin_handle = DuplicateHandle(plugin_socket->handle()); | 830 plugin_handle = DuplicateHandle(plugin_socket->handle()); |
839 } else { | 831 } else { |
840 result = PP_ERROR_FAILED; | 832 result = PP_ERROR_FAILED; |
841 } | 833 } |
842 | 834 |
843 // TOOD(ddorwin): Change the IPC to asynchronous: Queue an object containing | 835 // TOOD(ddorwin): Change the IPC to asynchronous: Queue an object containing |
844 // client and plugin_socket.release(), then return. | 836 // client and plugin_socket.release(), then return. |
845 // That message handler will then call client->BrokerConnected() with the | 837 // That message handler will then call client->BrokerConnected() with the |
846 // saved pipe handle. | 838 // saved pipe handle. |
847 // Temporarily, just call back. | 839 // Temporarily, just call back. |
848 client->BrokerConnected(PlatformFileToInt(plugin_handle), result); | 840 client->BrokerConnected(ppapi::PlatformFileToInt(plugin_handle), result); |
849 } | 841 } |
850 | 842 |
851 PepperPluginDelegateImpl::PepperPluginDelegateImpl(RenderViewImpl* render_view) | 843 PepperPluginDelegateImpl::PepperPluginDelegateImpl(RenderViewImpl* render_view) |
852 : render_view_(render_view), | 844 : render_view_(render_view), |
853 has_saved_context_menu_action_(false), | 845 has_saved_context_menu_action_(false), |
854 saved_context_menu_action_(0), | 846 saved_context_menu_action_(0), |
855 focused_plugin_(NULL), | 847 focused_plugin_(NULL), |
856 mouse_lock_owner_(NULL), | 848 mouse_lock_owner_(NULL), |
857 mouse_locked_(false), | 849 mouse_locked_(false), |
858 pending_lock_request_(false), | 850 pending_lock_request_(false), |
(...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1939 if (!context) | 1931 if (!context) |
1940 return NULL; | 1932 return NULL; |
1941 if (!context->makeContextCurrent() || context->isContextLost()) | 1933 if (!context->makeContextCurrent() || context->isContextLost()) |
1942 return NULL; | 1934 return NULL; |
1943 | 1935 |
1944 RendererGLContext* parent_context = context->context(); | 1936 RendererGLContext* parent_context = context->context(); |
1945 if (!parent_context) | 1937 if (!parent_context) |
1946 return NULL; | 1938 return NULL; |
1947 return parent_context; | 1939 return parent_context; |
1948 } | 1940 } |
OLD | NEW |