From 66602da324d34c39337e14f583bb97c457072f0d Mon Sep 17 00:00:00 2001 From: fsamuel Date: Fri, 12 Sep 2014 15:02:43 -0700 Subject: Browser Plugin: Don't crash browser when reloading crashed webview We were accessing a NULL RWHV on BrowserPluginGuest::SetFocus. This CL adds a guard to ensure we only attempt to set focus if we have a View. BUG=413874 Review URL: https://codereview.chromium.org/564153003 Cr-Commit-Position: refs/heads/master@{#294674} --- content/browser/browser_plugin/browser_plugin_guest.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'content/browser/browser_plugin/browser_plugin_guest.cc') diff --git a/content/browser/browser_plugin/browser_plugin_guest.cc b/content/browser/browser_plugin/browser_plugin_guest.cc index 569c9de..847eff8 100644 --- a/content/browser/browser_plugin/browser_plugin_guest.cc +++ b/content/browser/browser_plugin/browser_plugin_guest.cc @@ -109,13 +109,16 @@ base::WeakPtr BrowserPluginGuest::AsWeakPtr() { void BrowserPluginGuest::SetFocus(RenderWidgetHost* rwh, bool focused) { focused_ = focused; + if (!rwh) + return; + rwh->Send(new InputMsg_SetFocus(rwh->GetRoutingID(), focused)); if (!focused && mouse_locked_) OnUnlockMouse(); // Restore the last seen state of text input to the view. RenderWidgetHostViewBase* rwhv = static_cast( - web_contents()->GetRenderWidgetHostView()); + rwh->GetView()); if (rwhv) { ViewHostMsg_TextInputState_Params params; params.type = last_text_input_type_; @@ -718,9 +721,8 @@ void BrowserPluginGuest::OnResizeGuest( void BrowserPluginGuest::OnSetFocus(int browser_plugin_instance_id, bool focused) { - - RenderWidgetHost* rwh = web_contents()->GetRenderWidgetHostView()-> - GetRenderWidgetHost(); + RenderWidgetHostView* rwhv = web_contents()->GetRenderWidgetHostView(); + RenderWidgetHost* rwh = rwhv ? rwhv->GetRenderWidgetHost() : NULL; SetFocus(rwh, focused); } -- cgit v1.1