Index: ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc |
diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc |
index 48368f962f2f3433b76c5ad20746ad28f135a481..8b1f178470d94acf43e64f2dca4e9800a8ae427f 100644 |
--- a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc |
+++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc |
@@ -96,8 +96,14 @@ DesktopWindowTreeHostWin::~DesktopWindowTreeHostWin() { |
// static |
aura::Window* DesktopWindowTreeHostWin::GetContentWindowForHWND(HWND hwnd) { |
+ // All HWND's we create should have WindowTreeHost instances associated with |
+ // them. There are exceptions like the content layer creating HWND's which |
+ // are not associated with WindowTreeHost instances. In such cases we should |
+ // try and find the WindowTreeHost associated with the parent. |
aura::WindowTreeHost* host = |
aura::WindowTreeHost::GetForAcceleratedWidget(hwnd); |
+ if (!host) |
+ host = aura::WindowTreeHost::GetForAcceleratedWidget(::GetParent(hwnd)); |
return host ? host->window()->GetProperty(kContentWindowForRootWindow) : NULL; |
} |