summaryrefslogtreecommitdiffstats
path: root/content/browser/browser_plugin/browser_plugin_guest.cc
diff options
context:
space:
mode:
authorfsamuel <fsamuel@chromium.org>2014-09-12 15:02:43 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-12 22:06:27 +0000
commit66602da324d34c39337e14f583bb97c457072f0d (patch)
treeef527e3103771c6faa6013c1f9977a6a37549293 /content/browser/browser_plugin/browser_plugin_guest.cc
parent8aec45ee2c9b7c74ea4b317bf756db660ad7ff27 (diff)
downloadchromium_src-66602da324d34c39337e14f583bb97c457072f0d.zip
chromium_src-66602da324d34c39337e14f583bb97c457072f0d.tar.gz
chromium_src-66602da324d34c39337e14f583bb97c457072f0d.tar.bz2
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}
Diffstat (limited to 'content/browser/browser_plugin/browser_plugin_guest.cc')
-rw-r--r--content/browser/browser_plugin/browser_plugin_guest.cc10
1 files changed, 6 insertions, 4 deletions
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> 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<RenderWidgetHostViewBase*>(
- 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);
}