Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: chrome/renderer/pepper_plugin_delegate_impl.cc

Issue 6253017: Pepper/Flapper: First pass at context menu implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix mock plugin delegate Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 755 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 webkit::ppapi::PPB_Flash_NetConnector_Impl* connector, 813 webkit::ppapi::PPB_Flash_NetConnector_Impl* connector,
812 const char* host, 814 const char* host,
813 uint16_t port) { 815 uint16_t port) {
814 int request_id = pending_connect_tcps_.Add( 816 int request_id = pending_connect_tcps_.Add(
815 new scoped_refptr<webkit::ppapi::PPB_Flash_NetConnector_Impl>(connector)); 817 new scoped_refptr<webkit::ppapi::PPB_Flash_NetConnector_Impl>(connector));
816 IPC::Message* msg = 818 IPC::Message* msg =
817 new PepperMsg_ConnectTcp(render_view_->routing_id(), 819 new PepperMsg_ConnectTcp(render_view_->routing_id(),
818 request_id, 820 request_id,
819 std::string(host), 821 std::string(host),
820 port); 822 port);
821 if (!render_view_->Send(msg)) 823 if (!render_view_->Send(msg)) {
824 pending_connect_tcps_.Remove(request_id);
822 return PP_ERROR_FAILED; 825 return PP_ERROR_FAILED;
826 }
823 827
824 return PP_ERROR_WOULDBLOCK; 828 return PP_ERROR_WOULDBLOCK;
825 } 829 }
826 830
827 int32_t PepperPluginDelegateImpl::ConnectTcpAddress( 831 int32_t PepperPluginDelegateImpl::ConnectTcpAddress(
828 webkit::ppapi::PPB_Flash_NetConnector_Impl* connector, 832 webkit::ppapi::PPB_Flash_NetConnector_Impl* connector,
829 const struct PP_Flash_NetAddress* addr) { 833 const struct PP_Flash_NetAddress* addr) {
830 int request_id = pending_connect_tcps_.Add( 834 int request_id = pending_connect_tcps_.Add(
831 new scoped_refptr<webkit::ppapi::PPB_Flash_NetConnector_Impl>(connector)); 835 new scoped_refptr<webkit::ppapi::PPB_Flash_NetConnector_Impl>(connector));
832 IPC::Message* msg = 836 IPC::Message* msg =
833 new PepperMsg_ConnectTcpAddress(render_view_->routing_id(), 837 new PepperMsg_ConnectTcpAddress(render_view_->routing_id(),
834 request_id, 838 request_id,
835 *addr); 839 *addr);
836 if (!render_view_->Send(msg)) 840 if (!render_view_->Send(msg)) {
841 pending_connect_tcps_.Remove(request_id);
837 return PP_ERROR_FAILED; 842 return PP_ERROR_FAILED;
843 }
838 844
839 return PP_ERROR_WOULDBLOCK; 845 return PP_ERROR_WOULDBLOCK;
840 } 846 }
841 847
842 void PepperPluginDelegateImpl::OnConnectTcpACK( 848 void PepperPluginDelegateImpl::OnConnectTcpACK(
843 int request_id, 849 int request_id,
844 base::PlatformFile socket, 850 base::PlatformFile socket,
845 const PP_Flash_NetAddress& local_addr, 851 const PP_Flash_NetAddress& local_addr,
846 const PP_Flash_NetAddress& remote_addr) { 852 const PP_Flash_NetAddress& remote_addr) {
847 scoped_refptr<webkit::ppapi::PPB_Flash_NetConnector_Impl> connector = 853 scoped_refptr<webkit::ppapi::PPB_Flash_NetConnector_Impl> connector =
848 *pending_connect_tcps_.Lookup(request_id); 854 *pending_connect_tcps_.Lookup(request_id);
849 pending_connect_tcps_.Remove(request_id); 855 pending_connect_tcps_.Remove(request_id);
850 856
851 connector->CompleteConnectTcp(socket, local_addr, remote_addr); 857 connector->CompleteConnectTcp(socket, local_addr, remote_addr);
852 } 858 }
853 859
860 int32_t PepperPluginDelegateImpl::ShowContextMenu(
861 webkit::ppapi::PPB_Flash_Menu_Impl* menu,
862 const gfx::Point& position) {
863 int request_id = pending_context_menus_.Add(
864 new scoped_refptr<webkit::ppapi::PPB_Flash_Menu_Impl>(menu));
865
866 ContextMenuParams params;
867 params.x = position.x();
868 params.y = position.y();
869 params.custom_context.is_pepper_menu = true;
870 params.custom_context.request_id = request_id;
871 params.custom_items = menu->menu_data();
872
873 IPC::Message* msg = new ViewHostMsg_ContextMenu(render_view_->routing_id(),
874 params);
875 if (!render_view_->Send(msg)) {
876 pending_context_menus_.Remove(request_id);
877 return PP_ERROR_FAILED;
878 }
879
880 return PP_ERROR_WOULDBLOCK;
881 }
882
883 void PepperPluginDelegateImpl::CompleteShowContextMenu(
884 int request_id,
885 bool did_select,
886 unsigned action) {
887 scoped_refptr<webkit::ppapi::PPB_Flash_Menu_Impl> menu =
888 *pending_context_menus_.Lookup(request_id);
889 if (!menu) {
890 NOTREACHED() << "CompleteShowContextMenu() called twice for the same menu.";
891 return;
892 }
893 pending_context_menus_.Remove(request_id);
894
895 // TODO(viettrungluu): "user cancel" for everything else is not right....
896 if (did_select)
897 menu->CompleteShow(PP_OK, action);
898 else
899 menu->CompleteShow(PP_ERROR_USERCANCEL, 0);
900 }
901
854 webkit::ppapi::FullscreenContainer* 902 webkit::ppapi::FullscreenContainer*
855 PepperPluginDelegateImpl::CreateFullscreenContainer( 903 PepperPluginDelegateImpl::CreateFullscreenContainer(
856 webkit::ppapi::PluginInstance* instance) { 904 webkit::ppapi::PluginInstance* instance) {
857 return render_view_->CreatePepperFullscreenContainer(instance); 905 return render_view_->CreatePepperFullscreenContainer(instance);
858 } 906 }
859 907
860 std::string PepperPluginDelegateImpl::GetDefaultEncoding() { 908 std::string PepperPluginDelegateImpl::GetDefaultEncoding() {
861 // TODO(brettw) bug 56615: Somehow get the preference for the default 909 // TODO(brettw) bug 56615: Somehow get the preference for the default
862 // encoding here rather than using the global default for the UI language. 910 // encoding here rather than using the global default for the UI language.
863 return l10n_util::GetStringUTF8(IDS_DEFAULT_ENCODING); 911 return l10n_util::GetStringUTF8(IDS_DEFAULT_ENCODING);
(...skipping 25 matching lines...) Expand all
889 937
890 void PepperPluginDelegateImpl::SetContentRestriction(int restrictions) { 938 void PepperPluginDelegateImpl::SetContentRestriction(int restrictions) {
891 render_view_->Send(new ViewHostMsg_UpdateContentRestrictions( 939 render_view_->Send(new ViewHostMsg_UpdateContentRestrictions(
892 render_view_->routing_id(), restrictions)); 940 render_view_->routing_id(), restrictions));
893 } 941 }
894 942
895 void PepperPluginDelegateImpl::HasUnsupportedFeature() { 943 void PepperPluginDelegateImpl::HasUnsupportedFeature() {
896 render_view_->Send(new ViewHostMsg_PDFHasUnsupportedFeature( 944 render_view_->Send(new ViewHostMsg_PDFHasUnsupportedFeature(
897 render_view_->routing_id())); 945 render_view_->routing_id()));
898 } 946 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698