Index: content/browser/renderer_host/render_widget_host_view_aura.cc |
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc |
index a7eb8d667baec6cc472c40178036fbbd5c092b27..7e2521e27f060126831396b5b64663c6b7d65fbf 100644 |
--- a/content/browser/renderer_host/render_widget_host_view_aura.cc |
+++ b/content/browser/renderer_host/render_widget_host_view_aura.cc |
@@ -387,8 +387,7 @@ void RenderWidgetHostViewAura::ApplyEventFilterForPopupExit( |
target != popup_parent_host_view_->window_)) { |
// Note: popup_parent_host_view_ may be NULL when there are multiple |
// popup children per view. See: RenderWidgetHostViewAura::InitAsPopup(). |
- in_shutdown_ = true; |
- host_->Shutdown(); |
+ Shutdown(); |
} |
} |
@@ -1819,10 +1818,7 @@ void RenderWidgetHostViewAura::OnKeyEvent(ui::KeyEvent* event) { |
} |
} |
} |
- if (!in_shutdown_) { |
- in_shutdown_ = true; |
- host_->Shutdown(); |
- } |
+ Shutdown(); |
} else { |
if (event->key_code() == ui::VKEY_RETURN) { |
// Do not forward return key release events if no press event was handled. |
@@ -2212,9 +2208,15 @@ void RenderWidgetHostViewAura::OnWindowFocused(aura::Window* gained_focus, |
return; |
} |
#endif |
- in_shutdown_ = true; |
- host_->Shutdown(); |
+ Shutdown(); |
+ return; |
} |
+ |
+ // Close the child popup window if we lose focus (e.g. due to a JS alert or |
+ // system modal dialog). This is particularly important if |
+ // |popup_child_host_view_| has mouse capture. |
+ if (popup_child_host_view_) |
+ popup_child_host_view_->Shutdown(); |
} |
} |
@@ -2305,6 +2307,13 @@ ui::InputMethod* RenderWidgetHostViewAura::GetInputMethod() const { |
return root_window->GetProperty(aura::client::kRootWindowInputMethodKey); |
} |
+void RenderWidgetHostViewAura::Shutdown() { |
+ if (!in_shutdown_) { |
+ in_shutdown_ = true; |
+ host_->Shutdown(); |
+ } |
+} |
+ |
bool RenderWidgetHostViewAura::NeedsInputGrab() { |
return popup_type_ == blink::WebPopupTypeSelect; |
} |