Commit 19c1c373 authored by fsamuel@chromium.org's avatar fsamuel@chromium.org

Browser Plugin: Enable File Chooser (<input type="file">)

Plumb RunFileChooser to the embedder's WebContentsDelegate so if the embedder is allowed to show
a file chooser, then so is the guest.

BUG=143801
TEST=<input type="file"> in guest

Review URL: https://chromiumcodereview.appspot.com/11098056

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162392 0039d316-1c4b-4281-b951-d872f2087c98
parent 7cf43268
...@@ -94,8 +94,7 @@ void BrowserPluginEmbedder::CreateGuest(RenderViewHost* render_view_host, ...@@ -94,8 +94,7 @@ void BrowserPluginEmbedder::CreateGuest(RenderViewHost* render_view_host,
instance_id); instance_id);
guest = guest_web_contents->GetBrowserPluginGuest(); guest = guest_web_contents->GetBrowserPluginGuest();
guest->set_embedder_render_process_host(render_view_host->GetProcess()); guest->set_embedder_web_contents(web_contents());
guest->set_embedder_render_view_host(render_view_host);
RendererPreferences* guest_renderer_prefs = RendererPreferences* guest_renderer_prefs =
guest_web_contents->GetMutableRendererPrefs(); guest_web_contents->GetMutableRendererPrefs();
......
...@@ -42,8 +42,7 @@ BrowserPluginGuest::BrowserPluginGuest(int instance_id, ...@@ -42,8 +42,7 @@ BrowserPluginGuest::BrowserPluginGuest(int instance_id,
WebContentsImpl* web_contents, WebContentsImpl* web_contents,
RenderViewHost* render_view_host) RenderViewHost* render_view_host)
: WebContentsObserver(web_contents), : WebContentsObserver(web_contents),
embedder_render_process_host_(NULL), embedder_web_contents_(NULL),
embedder_render_view_host_(NULL),
instance_id_(instance_id), instance_id_(instance_id),
#if defined(OS_WIN) #if defined(OS_WIN)
damage_buffer_size_(0), damage_buffer_size_(0),
...@@ -135,6 +134,11 @@ void BrowserPluginGuest::RendererUnresponsive(WebContents* source) { ...@@ -135,6 +134,11 @@ void BrowserPluginGuest::RendererUnresponsive(WebContents* source) {
RecordAction(UserMetricsAction("BrowserPlugin.Guest.Hung")); RecordAction(UserMetricsAction("BrowserPlugin.Guest.Hung"));
} }
void BrowserPluginGuest::RunFileChooser(WebContents* web_contents,
const FileChooserParams& params) {
embedder_web_contents_->GetDelegate()->RunFileChooser(web_contents, params);
}
void BrowserPluginGuest::SetIsAcceptingTouchEvents(bool accept) { void BrowserPluginGuest::SetIsAcceptingTouchEvents(bool accept) {
SendMessageToEmbedder( SendMessageToEmbedder(
new BrowserPluginMsg_ShouldAcceptTouchEvents(instance_id(), accept)); new BrowserPluginMsg_ShouldAcceptTouchEvents(instance_id(), accept));
...@@ -172,9 +176,12 @@ void BrowserPluginGuest::DragStatusUpdate(WebKit::WebDragStatus drag_status, ...@@ -172,9 +176,12 @@ void BrowserPluginGuest::DragStatusUpdate(WebKit::WebDragStatus drag_status,
} }
void BrowserPluginGuest::UpdateDragCursor(WebKit::WebDragOperation operation) { void BrowserPluginGuest::UpdateDragCursor(WebKit::WebDragOperation operation) {
CHECK(embedder_render_view_host_); RenderViewHostImpl* embedder_render_view_host =
static_cast<RenderViewHostImpl*>(
embedder_web_contents_->GetRenderViewHost());
CHECK(embedder_render_view_host);
RenderViewHostDelegateView* view = RenderViewHostDelegateView* view =
embedder_render_view_host_->GetDelegate()->GetDelegateView(); embedder_render_view_host->GetDelegate()->GetDelegateView();
if (view) if (view)
view->UpdateDragCursor(operation); view->UpdateDragCursor(operation);
} }
...@@ -463,8 +470,7 @@ void BrowserPluginGuest::RenderViewGone(base::TerminationStatus status) { ...@@ -463,8 +470,7 @@ void BrowserPluginGuest::RenderViewGone(base::TerminationStatus status) {
} }
void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) { void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) {
DCHECK(embedder_render_process_host()); embedder_web_contents_->GetRenderProcessHost()->Send(msg);
embedder_render_process_host()->Send(msg);
} }
} // namespace content } // namespace content
...@@ -82,12 +82,8 @@ class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver, ...@@ -82,12 +82,8 @@ class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver,
guest_hang_timeout_ = timeout; guest_hang_timeout_ = timeout;
} }
void set_embedder_render_process_host( void set_embedder_web_contents(WebContents* web_contents) {
RenderProcessHost* render_process_host) { embedder_web_contents_ = web_contents;
embedder_render_process_host_ = render_process_host;
}
void set_embedder_render_view_host(RenderViewHost* render_view_host) {
embedder_render_view_host_ = render_view_host;
} }
bool visible() const { return visible_; } bool visible() const { return visible_; }
...@@ -126,6 +122,8 @@ class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver, ...@@ -126,6 +122,8 @@ class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver,
const std::string& request_method) OVERRIDE; const std::string& request_method) OVERRIDE;
virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE; virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE;
virtual void RendererUnresponsive(WebContents* source) OVERRIDE; virtual void RendererUnresponsive(WebContents* source) OVERRIDE;
virtual void RunFileChooser(WebContents* web_contents,
const FileChooserParams& params) OVERRIDE;
void UpdateRect(RenderViewHost* render_view_host, void UpdateRect(RenderViewHost* render_view_host,
const ViewHostMsg_UpdateRect_Params& params); const ViewHostMsg_UpdateRect_Params& params);
...@@ -215,9 +213,6 @@ class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver, ...@@ -215,9 +213,6 @@ class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver,
WebContentsImpl* web_contents, WebContentsImpl* web_contents,
RenderViewHost* render_view_host); RenderViewHost* render_view_host);
RenderProcessHost* embedder_render_process_host() {
return embedder_render_process_host_;
}
// Returns the identifier that uniquely identifies a browser plugin guest // Returns the identifier that uniquely identifies a browser plugin guest
// within an embedder. // within an embedder.
int instance_id() const { return instance_id_; } int instance_id() const { return instance_id_; }
...@@ -240,8 +235,7 @@ class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver, ...@@ -240,8 +235,7 @@ class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver,
static content::BrowserPluginHostFactory* factory_; static content::BrowserPluginHostFactory* factory_;
NotificationRegistrar notification_registrar_; NotificationRegistrar notification_registrar_;
RenderProcessHost* embedder_render_process_host_; WebContents* embedder_web_contents_;
RenderViewHost* embedder_render_view_host_;
// An identifier that uniquely identifies a browser plugin guest within an // An identifier that uniquely identifies a browser plugin guest within an
// embedder. // embedder.
int instance_id_; int instance_id_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment