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

Side by Side Diff: content/renderer/pepper/pepper_plugin_delegate_impl.cc

Issue 10544089: Implement the file chooser as a new resource "host" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/pepper_plugin_delegate_impl.h" 5 #include "content/renderer/pepper/pepper_plugin_delegate_impl.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <cstddef> 8 #include <cstddef>
9 #include <map> 9 #include <map>
10 #include <queue> 10 #include <queue>
(...skipping 23 matching lines...) Expand all
34 #include "content/public/common/referrer.h" 34 #include "content/public/common/referrer.h"
35 #include "content/public/renderer/content_renderer_client.h" 35 #include "content/public/renderer/content_renderer_client.h"
36 #include "content/renderer/browser_plugin/old/browser_plugin_constants.h" 36 #include "content/renderer/browser_plugin/old/browser_plugin_constants.h"
37 #include "content/renderer/browser_plugin/old/browser_plugin_registry.h" 37 #include "content/renderer/browser_plugin/old/browser_plugin_registry.h"
38 #include "content/renderer/gamepad_shared_memory_reader.h" 38 #include "content/renderer/gamepad_shared_memory_reader.h"
39 #include "content/renderer/media/audio_hardware.h" 39 #include "content/renderer/media/audio_hardware.h"
40 #include "content/renderer/media/media_stream_dispatcher.h" 40 #include "content/renderer/media/media_stream_dispatcher.h"
41 #include "content/renderer/media/pepper_platform_video_decoder_impl.h" 41 #include "content/renderer/media/pepper_platform_video_decoder_impl.h"
42 #include "content/renderer/p2p/p2p_transport_impl.h" 42 #include "content/renderer/p2p/p2p_transport_impl.h"
43 #include "content/renderer/p2p/socket_dispatcher.h" 43 #include "content/renderer/p2p/socket_dispatcher.h"
44 #include "content/renderer/pepper/content_renderer_pepper_host_factory.h"
44 #include "content/renderer/pepper/pepper_broker_impl.h" 45 #include "content/renderer/pepper/pepper_broker_impl.h"
45 #include "content/renderer/pepper/pepper_device_enumeration_event_handler.h" 46 #include "content/renderer/pepper/pepper_device_enumeration_event_handler.h"
46 #include "content/renderer/pepper/pepper_hung_plugin_filter.h" 47 #include "content/renderer/pepper/pepper_hung_plugin_filter.h"
47 #include "content/renderer/pepper/pepper_in_process_resource_creation.h" 48 #include "content/renderer/pepper/pepper_in_process_resource_creation.h"
48 #include "content/renderer/pepper/pepper_platform_audio_input_impl.h" 49 #include "content/renderer/pepper/pepper_platform_audio_input_impl.h"
49 #include "content/renderer/pepper/pepper_platform_audio_output_impl.h" 50 #include "content/renderer/pepper/pepper_platform_audio_output_impl.h"
50 #include "content/renderer/pepper/pepper_platform_context_3d_impl.h" 51 #include "content/renderer/pepper/pepper_platform_context_3d_impl.h"
51 #include "content/renderer/pepper/pepper_platform_image_2d_impl.h" 52 #include "content/renderer/pepper/pepper_platform_image_2d_impl.h"
52 #include "content/renderer/pepper/pepper_platform_video_capture_impl.h" 53 #include "content/renderer/pepper/pepper_platform_video_capture_impl.h"
53 #include "content/renderer/pepper/pepper_proxy_channel_delegate_impl.h" 54 #include "content/renderer/pepper/pepper_proxy_channel_delegate_impl.h"
54 #include "content/renderer/render_thread_impl.h" 55 #include "content/renderer/render_thread_impl.h"
55 #include "content/renderer/render_view_impl.h" 56 #include "content/renderer/render_view_impl.h"
56 #include "content/renderer/render_widget_fullscreen_pepper.h" 57 #include "content/renderer/render_widget_fullscreen_pepper.h"
57 #include "content/renderer/renderer_clipboard_client.h" 58 #include "content/renderer/renderer_clipboard_client.h"
58 #include "content/renderer/renderer_restrict_dispatch_group.h" 59 #include "content/renderer/renderer_restrict_dispatch_group.h"
59 #include "content/renderer/webplugin_delegate_proxy.h" 60 #include "content/renderer/webplugin_delegate_proxy.h"
60 #include "googleurl/src/gurl.h" 61 #include "googleurl/src/gurl.h"
61 #include "ipc/ipc_channel_handle.h" 62 #include "ipc/ipc_channel_handle.h"
62 #include "media/video/capture/video_capture_proxy.h" 63 #include "media/video/capture/video_capture_proxy.h"
63 #include "ppapi/c/dev/pp_video_dev.h" 64 #include "ppapi/c/dev/pp_video_dev.h"
64 #include "ppapi/c/pp_errors.h" 65 #include "ppapi/c/pp_errors.h"
65 #include "ppapi/c/private/ppb_flash.h" 66 #include "ppapi/c/private/ppb_flash.h"
67 #include "ppapi/host/ppapi_host.h"
66 #include "ppapi/proxy/host_dispatcher.h" 68 #include "ppapi/proxy/host_dispatcher.h"
67 #include "ppapi/proxy/pepper_file_messages.h" 69 #include "ppapi/proxy/pepper_file_messages.h"
68 #include "ppapi/proxy/ppapi_messages.h" 70 #include "ppapi/proxy/ppapi_messages.h"
69 #include "ppapi/shared_impl/file_path.h" 71 #include "ppapi/shared_impl/file_path.h"
70 #include "ppapi/shared_impl/platform_file.h" 72 #include "ppapi/shared_impl/platform_file.h"
71 #include "ppapi/shared_impl/ppapi_preferences.h" 73 #include "ppapi/shared_impl/ppapi_preferences.h"
72 #include "ppapi/shared_impl/ppb_device_ref_shared.h" 74 #include "ppapi/shared_impl/ppb_device_ref_shared.h"
73 #include "ppapi/thunk/enter.h" 75 #include "ppapi/thunk/enter.h"
74 #include "ppapi/thunk/ppb_tcp_server_socket_private_api.h" 76 #include "ppapi/thunk/ppb_tcp_server_socket_private_api.h"
75 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" 77 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h"
76 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" 78 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
77 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserComplet ion.h"
78 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams. h"
79 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 79 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
80 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 80 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
81 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" 81 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h"
82 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" 82 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h"
83 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 83 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
84 #include "ui/gfx/size.h" 84 #include "ui/gfx/size.h"
85 #include "webkit/fileapi/file_system_callback_dispatcher.h" 85 #include "webkit/fileapi/file_system_callback_dispatcher.h"
86 #include "webkit/plugins/npapi/webplugin.h" 86 #include "webkit/plugins/npapi/webplugin.h"
87 #include "webkit/plugins/ppapi/ppb_file_io_impl.h" 87 #include "webkit/plugins/ppapi/ppb_file_io_impl.h"
88 #include "webkit/plugins/ppapi/plugin_module.h" 88 #include "webkit/plugins/ppapi/plugin_module.h"
89 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 89 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
90 #include "webkit/plugins/ppapi/ppb_flash_impl.h" 90 #include "webkit/plugins/ppapi/ppb_flash_impl.h"
91 #include "webkit/plugins/ppapi/ppb_tcp_server_socket_private_impl.h" 91 #include "webkit/plugins/ppapi/ppb_tcp_server_socket_private_impl.h"
92 #include "webkit/plugins/ppapi/ppb_tcp_socket_private_impl.h" 92 #include "webkit/plugins/ppapi/ppb_tcp_socket_private_impl.h"
93 #include "webkit/plugins/ppapi/ppb_udp_socket_private_impl.h" 93 #include "webkit/plugins/ppapi/ppb_udp_socket_private_impl.h"
94 #include "webkit/plugins/ppapi/resource_helper.h" 94 #include "webkit/plugins/ppapi/resource_helper.h"
95 #include "webkit/plugins/webplugininfo.h" 95 #include "webkit/plugins/webplugininfo.h"
96 96
97 using WebKit::WebView; 97 using WebKit::WebView;
98 using WebKit::WebFrame; 98 using WebKit::WebFrame;
99 99
100 namespace content { 100 namespace content {
101 101
102 namespace { 102 namespace {
103 103
104 class HostDispatcherWrapper 104 class HostDispatcherWrapper
105 : public webkit::ppapi::PluginDelegate::OutOfProcessProxy { 105 : public webkit::ppapi::PluginDelegate::OutOfProcessProxy {
106 public: 106 public:
107 HostDispatcherWrapper() {} 107 HostDispatcherWrapper(RenderViewImpl* rv)
108 : render_view_(rv),
109 host_factory_(rv) {
110 }
108 virtual ~HostDispatcherWrapper() {} 111 virtual ~HostDispatcherWrapper() {}
109 112
110 bool Init(const IPC::ChannelHandle& channel_handle, 113 bool Init(const IPC::ChannelHandle& channel_handle,
111 PP_Module pp_module, 114 PP_Module pp_module,
112 PP_GetInterface_Func local_get_interface, 115 PP_GetInterface_Func local_get_interface,
113 const ppapi::Preferences& preferences, 116 const ppapi::Preferences& preferences,
114 PepperHungPluginFilter* filter) { 117 PepperHungPluginFilter* filter) {
115 if (channel_handle.name.empty()) 118 if (channel_handle.name.empty())
116 return false; 119 return false;
117 120
118 #if defined(OS_POSIX) 121 #if defined(OS_POSIX)
119 DCHECK_NE(-1, channel_handle.socket.fd); 122 DCHECK_NE(-1, channel_handle.socket.fd);
120 if (channel_handle.socket.fd == -1) 123 if (channel_handle.socket.fd == -1)
121 return false; 124 return false;
122 #endif 125 #endif
123 126
124 dispatcher_delegate_.reset(new PepperProxyChannelDelegateImpl); 127 dispatcher_delegate_.reset(new PepperProxyChannelDelegateImpl);
125 dispatcher_.reset(new ppapi::proxy::HostDispatcher( 128 dispatcher_.reset(new ppapi::proxy::HostDispatcher(
126 pp_module, local_get_interface, filter)); 129 pp_module, local_get_interface, filter));
127 130
131 host_.reset(new ppapi::host::PpapiHost(dispatcher_.get(), &host_factory_));
132 dispatcher_->AddFilter(host_.get());
133
128 if (!dispatcher_->InitHostWithChannel(dispatcher_delegate_.get(), 134 if (!dispatcher_->InitHostWithChannel(dispatcher_delegate_.get(),
129 channel_handle, 135 channel_handle,
130 true, // Client. 136 true, // Client.
131 preferences)) { 137 preferences)) {
132 dispatcher_.reset(); 138 dispatcher_.reset();
133 dispatcher_delegate_.reset(); 139 dispatcher_delegate_.reset();
134 return false; 140 return false;
135 } 141 }
136 dispatcher_->channel()->SetRestrictDispatchChannelGroup( 142 dispatcher_->channel()->SetRestrictDispatchChannelGroup(
137 content::kRendererRestrictDispatchGroup_Pepper); 143 content::kRendererRestrictDispatchGroup_Pepper);
138 return true; 144 return true;
139 } 145 }
140 146
141 // OutOfProcessProxy implementation. 147 // OutOfProcessProxy implementation.
142 virtual const void* GetProxiedInterface(const char* name) { 148 virtual const void* GetProxiedInterface(const char* name) {
143 return dispatcher_->GetProxiedInterface(name); 149 return dispatcher_->GetProxiedInterface(name);
144 } 150 }
145 virtual void AddInstance(PP_Instance instance) { 151 virtual void AddInstance(PP_Instance instance) {
146 ppapi::proxy::HostDispatcher::SetForInstance(instance, dispatcher_.get()); 152 ppapi::proxy::HostDispatcher::SetForInstance(instance, dispatcher_.get());
147 } 153 }
148 virtual void RemoveInstance(PP_Instance instance) { 154 virtual void RemoveInstance(PP_Instance instance) {
149 ppapi::proxy::HostDispatcher::RemoveForInstance(instance); 155 ppapi::proxy::HostDispatcher::RemoveForInstance(instance);
150 } 156 }
151 157
152 private: 158 private:
159 RenderViewImpl* render_view_;
160 ContentRendererPepperHostFactory host_factory_;
161
162 scoped_ptr<ppapi::host::PpapiHost> host_;
163
153 scoped_ptr<ppapi::proxy::HostDispatcher> dispatcher_; 164 scoped_ptr<ppapi::proxy::HostDispatcher> dispatcher_;
154 scoped_ptr<ppapi::proxy::ProxyChannel::Delegate> dispatcher_delegate_; 165 scoped_ptr<ppapi::proxy::ProxyChannel::Delegate> dispatcher_delegate_;
155 }; 166 };
156 167
157 class QuotaCallbackTranslator : public QuotaDispatcher::Callback { 168 class QuotaCallbackTranslator : public QuotaDispatcher::Callback {
158 public: 169 public:
159 typedef webkit::ppapi::PluginDelegate::AvailableSpaceCallback PluginCallback; 170 typedef webkit::ppapi::PluginDelegate::AvailableSpaceCallback PluginCallback;
160 explicit QuotaCallbackTranslator(const PluginCallback& cb) : callback_(cb) {} 171 explicit QuotaCallbackTranslator(const PluginCallback& cb) : callback_(cb) {}
161 virtual void DidQueryStorageUsageAndQuota(int64 usage, int64 quota) OVERRIDE { 172 virtual void DidQueryStorageUsageAndQuota(int64 usage, int64 quota) OVERRIDE {
162 callback_.Run(std::max(static_cast<int64>(0), quota - usage)); 173 callback_.Run(std::max(static_cast<int64>(0), quota - usage));
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 scoped_refptr<PepperHungPluginFilter> hung_filter( 261 scoped_refptr<PepperHungPluginFilter> hung_filter(
251 new PepperHungPluginFilter(path, render_view_->routing_id(), 262 new PepperHungPluginFilter(path, render_view_->routing_id(),
252 plugin_child_id)); 263 plugin_child_id));
253 264
254 // Create a new HostDispatcher for the proxying, and hook it to a new 265 // Create a new HostDispatcher for the proxying, and hook it to a new
255 // PluginModule. Note that AddLiveModule must be called before any early 266 // PluginModule. Note that AddLiveModule must be called before any early
256 // returns since the module's destructor will remove itself. 267 // returns since the module's destructor will remove itself.
257 module = new webkit::ppapi::PluginModule(info->name, path, 268 module = new webkit::ppapi::PluginModule(info->name, path,
258 PepperPluginRegistry::GetInstance()); 269 PepperPluginRegistry::GetInstance());
259 PepperPluginRegistry::GetInstance()->AddLiveModule(path, module); 270 PepperPluginRegistry::GetInstance()->AddLiveModule(path, module);
260 scoped_ptr<HostDispatcherWrapper> dispatcher(new HostDispatcherWrapper); 271 scoped_ptr<HostDispatcherWrapper> dispatcher(
272 new HostDispatcherWrapper(render_view_));
261 if (!dispatcher->Init( 273 if (!dispatcher->Init(
262 channel_handle, 274 channel_handle,
263 module->pp_module(), 275 module->pp_module(),
264 webkit::ppapi::PluginModule::GetLocalGetInterfaceFunc(), 276 webkit::ppapi::PluginModule::GetLocalGetInterfaceFunc(),
265 GetPreferences(), 277 GetPreferences(),
266 hung_filter.get())) 278 hung_filter.get()))
267 return scoped_refptr<webkit::ppapi::PluginModule>(); 279 return scoped_refptr<webkit::ppapi::PluginModule>();
268 module->InitAsProxied(dispatcher.release()); 280 module->InitAsProxied(dispatcher.release());
269 return module; 281 return module;
270 } 282 }
(...skipping 14 matching lines...) Expand all
285 new PepperHungPluginFilter(path, 297 new PepperHungPluginFilter(path,
286 render_view_->routing_id(), 298 render_view_->routing_id(),
287 guest_process_id)); 299 guest_process_id));
288 // Create a new HostDispatcher for the proxying, and hook it to a new 300 // Create a new HostDispatcher for the proxying, and hook it to a new
289 // PluginModule. 301 // PluginModule.
290 module = new webkit::ppapi::PluginModule(kBrowserPluginName, 302 module = new webkit::ppapi::PluginModule(kBrowserPluginName,
291 path, 303 path,
292 registry); 304 registry);
293 RenderThreadImpl::current()->browser_plugin_registry()->AddModule( 305 RenderThreadImpl::current()->browser_plugin_registry()->AddModule(
294 guest_process_id, module); 306 guest_process_id, module);
295 scoped_ptr<HostDispatcherWrapper> dispatcher(new HostDispatcherWrapper); 307 scoped_ptr<HostDispatcherWrapper> dispatcher(
308 new HostDispatcherWrapper(render_view_));
296 if (!dispatcher->Init( 309 if (!dispatcher->Init(
297 channel_handle, 310 channel_handle,
298 module->pp_module(), 311 module->pp_module(),
299 webkit::ppapi::PluginModule::GetLocalGetInterfaceFunc(), 312 webkit::ppapi::PluginModule::GetLocalGetInterfaceFunc(),
300 GetPreferences(), 313 GetPreferences(),
301 hung_filter.get())) 314 hung_filter.get()))
302 return scoped_refptr<webkit::ppapi::PluginModule>(); 315 return scoped_refptr<webkit::ppapi::PluginModule>();
303 module->InitAsProxied(dispatcher.release()); 316 module->InitAsProxied(dispatcher.release());
304 return module; 317 return module;
305 } 318 }
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 if (!broker_impl.get()) 722 if (!broker_impl.get())
710 return NULL; 723 return NULL;
711 broker = broker_impl; 724 broker = broker_impl;
712 } 725 }
713 726
714 // Adds a reference, ensuring not deleted when broker_impl goes out of scope. 727 // Adds a reference, ensuring not deleted when broker_impl goes out of scope.
715 broker->Connect(client); 728 broker->Connect(client);
716 return broker; 729 return broker;
717 } 730 }
718 731
719 bool PepperPluginDelegateImpl::RunFileChooser(
720 const WebKit::WebFileChooserParams& params,
721 WebKit::WebFileChooserCompletion* chooser_completion) {
722 return render_view_->runFileChooser(params, chooser_completion);
723 }
724
725 bool PepperPluginDelegateImpl::AsyncOpenFile( 732 bool PepperPluginDelegateImpl::AsyncOpenFile(
726 const FilePath& path, 733 const FilePath& path,
727 int flags, 734 int flags,
728 const AsyncOpenFileCallback& callback) { 735 const AsyncOpenFileCallback& callback) {
729 int message_id = pending_async_open_files_.Add( 736 int message_id = pending_async_open_files_.Add(
730 new AsyncOpenFileCallback(callback)); 737 new AsyncOpenFileCallback(callback));
731 IPC::Message* msg = new ViewHostMsg_AsyncOpenFile( 738 IPC::Message* msg = new ViewHostMsg_AsyncOpenFile(
732 render_view_->routing_id(), path, flags, message_id); 739 render_view_->routing_id(), path, flags, message_id);
733 return render_view_->Send(msg); 740 return render_view_->Send(msg);
734 } 741 }
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after
1713 else 1720 else
1714 return render_view_->mouse_lock_dispatcher(); 1721 return render_view_->mouse_lock_dispatcher();
1715 } 1722 }
1716 1723
1717 webkit_glue::ClipboardClient* 1724 webkit_glue::ClipboardClient*
1718 PepperPluginDelegateImpl::CreateClipboardClient() const { 1725 PepperPluginDelegateImpl::CreateClipboardClient() const {
1719 return new RendererClipboardClient; 1726 return new RendererClipboardClient;
1720 } 1727 }
1721 1728
1722 } // namespace content 1729 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698