Chromium Code Reviews| 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 "chrome/renderer/pepper_plugin_delegate_impl.h" | 5 #include "chrome/renderer/pepper_plugin_delegate_impl.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "app/surface/transport_dib.h" | 9 #include "app/surface/transport_dib.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 #include "chrome/renderer/gpu_channel_host.h" | 28 #include "chrome/renderer/gpu_channel_host.h" |
| 29 #include "chrome/renderer/pepper_platform_context_3d_impl.h" | 29 #include "chrome/renderer/pepper_platform_context_3d_impl.h" |
| 30 #include "chrome/renderer/render_thread.h" | 30 #include "chrome/renderer/render_thread.h" |
| 31 #include "chrome/renderer/render_view.h" | 31 #include "chrome/renderer/render_view.h" |
| 32 #include "chrome/renderer/webgraphicscontext3d_command_buffer_impl.h" | 32 #include "chrome/renderer/webgraphicscontext3d_command_buffer_impl.h" |
| 33 #include "chrome/renderer/webplugin_delegate_proxy.h" | 33 #include "chrome/renderer/webplugin_delegate_proxy.h" |
| 34 #include "gfx/size.h" | 34 #include "gfx/size.h" |
| 35 #include "grit/locale_settings.h" | 35 #include "grit/locale_settings.h" |
| 36 #include "ipc/ipc_channel_handle.h" | 36 #include "ipc/ipc_channel_handle.h" |
| 37 #include "ppapi/c/dev/pp_video_dev.h" | 37 #include "ppapi/c/dev/pp_video_dev.h" |
| 38 #include "ppapi/c/pp_errors.h" | |
| 38 #include "ppapi/c/private/ppb_flash.h" | 39 #include "ppapi/c/private/ppb_flash.h" |
| 39 #include "ppapi/proxy/host_dispatcher.h" | 40 #include "ppapi/proxy/host_dispatcher.h" |
| 40 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserComplet ion.h" | 41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserComplet ion.h" |
| 41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams. h" | 42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams. h" |
| 42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" | 43 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" |
| 43 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 44 #include "ui/base/l10n/l10n_util.h" | 45 #include "ui/base/l10n/l10n_util.h" |
| 45 #include "webkit/fileapi/file_system_callback_dispatcher.h" | 46 #include "webkit/fileapi/file_system_callback_dispatcher.h" |
| 47 #include "webkit/glue/context_menu.h" | |
| 46 #include "webkit/plugins/npapi/webplugin.h" | 48 #include "webkit/plugins/npapi/webplugin.h" |
| 47 #include "webkit/plugins/ppapi/ppb_file_io_impl.h" | 49 #include "webkit/plugins/ppapi/ppb_file_io_impl.h" |
| 48 #include "webkit/plugins/ppapi/plugin_module.h" | 50 #include "webkit/plugins/ppapi/plugin_module.h" |
| 49 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 51 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| 50 #include "webkit/plugins/ppapi/ppb_flash_impl.h" | 52 #include "webkit/plugins/ppapi/ppb_flash_impl.h" |
| 51 | 53 |
| 52 #if defined(OS_MACOSX) | 54 #if defined(OS_MACOSX) |
| 53 #include "chrome/renderer/render_thread.h" | 55 #include "chrome/renderer/render_thread.h" |
| 54 #endif | 56 #endif |
| 55 | 57 |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 369 dispatcher_.reset(); | 371 dispatcher_.reset(); |
| 370 return false; | 372 return false; |
| 371 } | 373 } |
| 372 return true; | 374 return true; |
| 373 } | 375 } |
| 374 | 376 |
| 375 } // namespace | 377 } // namespace |
| 376 | 378 |
| 377 PepperPluginDelegateImpl::PepperPluginDelegateImpl(RenderView* render_view) | 379 PepperPluginDelegateImpl::PepperPluginDelegateImpl(RenderView* render_view) |
| 378 : render_view_(render_view), | 380 : render_view_(render_view), |
| 381 has_saved_context_menu_action_(false), | |
| 382 saved_context_menu_action_(0), | |
| 379 id_generator_(0) { | 383 id_generator_(0) { |
| 380 } | 384 } |
| 381 | 385 |
| 382 PepperPluginDelegateImpl::~PepperPluginDelegateImpl() { | 386 PepperPluginDelegateImpl::~PepperPluginDelegateImpl() { |
| 383 } | 387 } |
| 384 | 388 |
| 385 scoped_refptr<webkit::ppapi::PluginModule> | 389 scoped_refptr<webkit::ppapi::PluginModule> |
| 386 PepperPluginDelegateImpl::CreatePepperPlugin(const FilePath& path) { | 390 PepperPluginDelegateImpl::CreatePepperPlugin(const FilePath& path) { |
| 387 // See if a module has already been loaded for this plugin. | 391 // See if a module has already been loaded for this plugin. |
| 388 scoped_refptr<webkit::ppapi::PluginModule> module = | 392 scoped_refptr<webkit::ppapi::PluginModule> module = |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 811 webkit::ppapi::PPB_Flash_NetConnector_Impl* connector, | 815 webkit::ppapi::PPB_Flash_NetConnector_Impl* connector, |
| 812 const char* host, | 816 const char* host, |
| 813 uint16_t port) { | 817 uint16_t port) { |
| 814 int request_id = pending_connect_tcps_.Add( | 818 int request_id = pending_connect_tcps_.Add( |
| 815 new scoped_refptr<webkit::ppapi::PPB_Flash_NetConnector_Impl>(connector)); | 819 new scoped_refptr<webkit::ppapi::PPB_Flash_NetConnector_Impl>(connector)); |
| 816 IPC::Message* msg = | 820 IPC::Message* msg = |
| 817 new PepperMsg_ConnectTcp(render_view_->routing_id(), | 821 new PepperMsg_ConnectTcp(render_view_->routing_id(), |
| 818 request_id, | 822 request_id, |
| 819 std::string(host), | 823 std::string(host), |
| 820 port); | 824 port); |
| 821 if (!render_view_->Send(msg)) | 825 if (!render_view_->Send(msg)) { |
| 826 pending_connect_tcps_.Remove(request_id); | |
| 822 return PP_ERROR_FAILED; | 827 return PP_ERROR_FAILED; |
| 828 } | |
| 823 | 829 |
| 824 return PP_ERROR_WOULDBLOCK; | 830 return PP_ERROR_WOULDBLOCK; |
| 825 } | 831 } |
| 826 | 832 |
| 827 int32_t PepperPluginDelegateImpl::ConnectTcpAddress( | 833 int32_t PepperPluginDelegateImpl::ConnectTcpAddress( |
| 828 webkit::ppapi::PPB_Flash_NetConnector_Impl* connector, | 834 webkit::ppapi::PPB_Flash_NetConnector_Impl* connector, |
| 829 const struct PP_Flash_NetAddress* addr) { | 835 const struct PP_Flash_NetAddress* addr) { |
| 830 int request_id = pending_connect_tcps_.Add( | 836 int request_id = pending_connect_tcps_.Add( |
| 831 new scoped_refptr<webkit::ppapi::PPB_Flash_NetConnector_Impl>(connector)); | 837 new scoped_refptr<webkit::ppapi::PPB_Flash_NetConnector_Impl>(connector)); |
| 832 IPC::Message* msg = | 838 IPC::Message* msg = |
| 833 new PepperMsg_ConnectTcpAddress(render_view_->routing_id(), | 839 new PepperMsg_ConnectTcpAddress(render_view_->routing_id(), |
| 834 request_id, | 840 request_id, |
| 835 *addr); | 841 *addr); |
| 836 if (!render_view_->Send(msg)) | 842 if (!render_view_->Send(msg)) { |
| 843 pending_connect_tcps_.Remove(request_id); | |
| 837 return PP_ERROR_FAILED; | 844 return PP_ERROR_FAILED; |
| 845 } | |
| 838 | 846 |
| 839 return PP_ERROR_WOULDBLOCK; | 847 return PP_ERROR_WOULDBLOCK; |
| 840 } | 848 } |
| 841 | 849 |
| 842 void PepperPluginDelegateImpl::OnConnectTcpACK( | 850 void PepperPluginDelegateImpl::OnConnectTcpACK( |
| 843 int request_id, | 851 int request_id, |
| 844 base::PlatformFile socket, | 852 base::PlatformFile socket, |
| 845 const PP_Flash_NetAddress& local_addr, | 853 const PP_Flash_NetAddress& local_addr, |
| 846 const PP_Flash_NetAddress& remote_addr) { | 854 const PP_Flash_NetAddress& remote_addr) { |
| 847 scoped_refptr<webkit::ppapi::PPB_Flash_NetConnector_Impl> connector = | 855 scoped_refptr<webkit::ppapi::PPB_Flash_NetConnector_Impl> connector = |
| 848 *pending_connect_tcps_.Lookup(request_id); | 856 *pending_connect_tcps_.Lookup(request_id); |
| 849 pending_connect_tcps_.Remove(request_id); | 857 pending_connect_tcps_.Remove(request_id); |
| 850 | 858 |
| 851 connector->CompleteConnectTcp(socket, local_addr, remote_addr); | 859 connector->CompleteConnectTcp(socket, local_addr, remote_addr); |
| 852 } | 860 } |
| 853 | 861 |
| 862 int32_t PepperPluginDelegateImpl::ShowContextMenu( | |
| 863 webkit::ppapi::PPB_Flash_Menu_Impl* menu, | |
| 864 const gfx::Point& position) { | |
| 865 int request_id = pending_context_menus_.Add( | |
| 866 new scoped_refptr<webkit::ppapi::PPB_Flash_Menu_Impl>(menu)); | |
| 867 | |
| 868 ContextMenuParams params; | |
| 869 params.x = position.x(); | |
| 870 params.y = position.y(); | |
| 871 params.custom_context.is_pepper_menu = true; | |
| 872 params.custom_context.request_id = request_id; | |
| 873 params.custom_items = menu->menu_data(); | |
| 874 | |
| 875 IPC::Message* msg = new ViewHostMsg_ContextMenu(render_view_->routing_id(), | |
| 876 params); | |
| 877 if (!render_view_->Send(msg)) { | |
| 878 pending_context_menus_.Remove(request_id); | |
| 879 return PP_ERROR_FAILED; | |
| 880 } | |
| 881 | |
| 882 return PP_ERROR_WOULDBLOCK; | |
| 883 } | |
| 884 | |
| 885 void PepperPluginDelegateImpl::OnContextMenuClosed( | |
| 886 const webkit_glue::CustomContextMenuContext& custom_context) { | |
| 887 int request_id = custom_context.request_id; | |
| 888 scoped_refptr<webkit::ppapi::PPB_Flash_Menu_Impl> menu = | |
| 889 *pending_context_menus_.Lookup(request_id); | |
| 890 if (!menu) { | |
| 891 NOTREACHED() << "CompleteShowContextMenu() called twice for the same menu."; | |
| 892 return; | |
| 893 } | |
| 894 pending_context_menus_.Remove(request_id); | |
| 895 | |
| 896 // TODO(viettrungluu): "user cancel" for everything else is not right.... | |
|
brettw
2011/01/31 18:19:49
What do you mean by "everything else" here? What c
viettrungluu
2011/01/31 19:01:41
Conceivably, other things (not directly done by th
| |
| 897 if (has_saved_context_menu_action_) { | |
| 898 menu->CompleteShow(PP_OK, saved_context_menu_action_); | |
| 899 has_saved_context_menu_action_ = false; | |
| 900 saved_context_menu_action_ = 0; | |
| 901 } else { | |
| 902 menu->CompleteShow(PP_ERROR_USERCANCEL, 0); | |
| 903 } | |
| 904 } | |
| 905 | |
| 906 void PepperPluginDelegateImpl::OnCustomContextMenuAction( | |
| 907 const webkit_glue::CustomContextMenuContext& custom_context, | |
| 908 unsigned action) { | |
| 909 // Just save the action. | |
| 910 DCHECK(!has_saved_context_menu_action_); | |
| 911 has_saved_context_menu_action_ = true; | |
| 912 saved_context_menu_action_ = action; | |
| 913 } | |
| 914 | |
| 854 webkit::ppapi::FullscreenContainer* | 915 webkit::ppapi::FullscreenContainer* |
| 855 PepperPluginDelegateImpl::CreateFullscreenContainer( | 916 PepperPluginDelegateImpl::CreateFullscreenContainer( |
| 856 webkit::ppapi::PluginInstance* instance) { | 917 webkit::ppapi::PluginInstance* instance) { |
| 857 return render_view_->CreatePepperFullscreenContainer(instance); | 918 return render_view_->CreatePepperFullscreenContainer(instance); |
| 858 } | 919 } |
| 859 | 920 |
| 860 std::string PepperPluginDelegateImpl::GetDefaultEncoding() { | 921 std::string PepperPluginDelegateImpl::GetDefaultEncoding() { |
| 861 // TODO(brettw) bug 56615: Somehow get the preference for the default | 922 // TODO(brettw) bug 56615: Somehow get the preference for the default |
| 862 // encoding here rather than using the global default for the UI language. | 923 // encoding here rather than using the global default for the UI language. |
| 863 return l10n_util::GetStringUTF8(IDS_DEFAULT_ENCODING); | 924 return l10n_util::GetStringUTF8(IDS_DEFAULT_ENCODING); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 889 | 950 |
| 890 void PepperPluginDelegateImpl::SetContentRestriction(int restrictions) { | 951 void PepperPluginDelegateImpl::SetContentRestriction(int restrictions) { |
| 891 render_view_->Send(new ViewHostMsg_UpdateContentRestrictions( | 952 render_view_->Send(new ViewHostMsg_UpdateContentRestrictions( |
| 892 render_view_->routing_id(), restrictions)); | 953 render_view_->routing_id(), restrictions)); |
| 893 } | 954 } |
| 894 | 955 |
| 895 void PepperPluginDelegateImpl::HasUnsupportedFeature() { | 956 void PepperPluginDelegateImpl::HasUnsupportedFeature() { |
| 896 render_view_->Send(new ViewHostMsg_PDFHasUnsupportedFeature( | 957 render_view_->Send(new ViewHostMsg_PDFHasUnsupportedFeature( |
| 897 render_view_->routing_id())); | 958 render_view_->routing_id())); |
| 898 } | 959 } |
| OLD | NEW |