Index: content/browser/web_contents/web_contents_view_aura.cc |
diff --git a/content/browser/web_contents/web_contents_view_aura.cc b/content/browser/web_contents/web_contents_view_aura.cc |
index 63bd454bd6de08cf4dea78aac6a90449c24ed659..3ca558959b0df2a2e6e75bc323a0c58e99e3e7f2 100644 |
--- a/content/browser/web_contents/web_contents_view_aura.cc |
+++ b/content/browser/web_contents/web_contents_view_aura.cc |
@@ -66,10 +66,17 @@ |
#include "ui/gfx/image/image.h" |
#include "ui/gfx/image/image_png_rep.h" |
#include "ui/gfx/image/image_skia.h" |
+#include "ui/gfx/native_widget_types.h" |
#include "ui/gfx/screen.h" |
#include "ui/wm/public/drag_drop_client.h" |
#include "ui/wm/public/drag_drop_delegate.h" |
+#if defined(OS_WIN) |
+#include "content/browser/accessibility/browser_accessibility_manager.h" |
+#include "content/browser/accessibility/browser_accessibility_win.h" |
+#include "ui/base/win/hidden_window.h" |
+#endif |
+ |
namespace content { |
WebContentsView* CreateWebContentsView( |
WebContentsImpl* web_contents, |
@@ -633,6 +640,8 @@ class WebContentsViewAura::WindowObserver |
#if defined(OS_WIN) |
if (!window->GetRootWindow()->HasObserver(this)) |
window->GetRootWindow()->AddObserver(this); |
+ view_->legacy_hwnd_->UpdateParent( |
+ window->GetHost()->GetAcceleratedWidget()); |
#endif |
} |
} |
@@ -652,6 +661,10 @@ class WebContentsViewAura::WindowObserver |
root_children[i]->RemoveObserver(this); |
} |
} |
+ |
+ // Update the legacy window's parent temporarily to the desktop window. |
+ // It will eventually get reparented to the right root. |
+ view_->legacy_hwnd_->UpdateParent(::GetDesktopWindow()); |
#endif |
} |
} |
@@ -1005,6 +1018,7 @@ void WebContentsViewAura::SizeContents(const gfx::Size& size) { |
if (bounds.size() != size) { |
bounds.set_size(size); |
window_->SetBounds(bounds); |
+ legacy_hwnd_->SetBounds(window_->GetBoundsInRootWindow()); |
} else { |
// Our size matches what we want but the renderers size may not match. |
// Pretend we were resized so that the renderers size is updated too. |
@@ -1098,6 +1112,15 @@ void WebContentsViewAura::CreateView( |
// platforms as well. |
if (delegate_) |
drag_dest_delegate_ = delegate_->GetDragDestDelegate(); |
+ |
+#if defined(OS_WIN) |
+ HWND parent_hwnd; |
+ if (context && context->GetHost()) |
+ parent_hwnd = context->GetHost()->GetAcceleratedWidget(); |
+ else |
+ parent_hwnd = ::GetDesktopWindow(); |
ananta
2014/08/04 19:28:34
When would context or GetHost be NULL?
dmazzoni
2014/09/10 23:01:31
I'm not sure. Note that context is NULL-checked ea
|
+ legacy_hwnd_.reset(LegacyRenderWidgetHostHWND::Create(parent_hwnd, this)); |
+#endif |
} |
RenderWidgetHostViewBase* WebContentsViewAura::CreateViewForWidget( |
@@ -1138,12 +1161,22 @@ RenderWidgetHostViewBase* WebContentsViewAura::CreateViewForWidget( |
} |
AttachTouchEditableToRenderView(); |
+ |
+#if defined(OS_WIN) |
+ view->SetLegacyRenderWidgetHostHWND(legacy_hwnd_.get()); |
+#endif |
+ |
return view; |
} |
RenderWidgetHostViewBase* WebContentsViewAura::CreateViewForPopupWidget( |
RenderWidgetHost* render_widget_host) { |
- return new RenderWidgetHostViewAura(render_widget_host); |
+ RenderWidgetHostViewAura* view = |
+ new RenderWidgetHostViewAura(render_widget_host); |
+#if defined(OS_WIN) |
+ view->SetLegacyRenderWidgetHostHWND(legacy_hwnd_.get()); |
+#endif |
+ return view; |
} |
void WebContentsViewAura::SetPageTitle(const base::string16& title) { |
@@ -1612,6 +1645,32 @@ void WebContentsViewAura::UpdateWebContentsVisibility(bool visible) { |
if (web_contents_->should_normally_be_visible()) |
web_contents_->WasHidden(); |
} |
+ |
+#if defined(OS_WIN) |
+ if (visible) { |
+ legacy_hwnd_->UpdateParent( |
+ GetNativeView()->GetHost()->GetAcceleratedWidget()); |
+ legacy_hwnd_->SetBounds(window_->GetBoundsInRootWindow()); |
+ legacy_hwnd_->Show(); |
+ } else { |
+ // We reparent the legacy Chrome_RenderWidgetHostHWND window to the global |
+ // hidden window on the same lines as Windowed plugin windows. |
+ legacy_hwnd_->UpdateParent(ui::GetHiddenWindow()); |
+ legacy_hwnd_->Hide(); |
+ } |
+#endif |
} |
+#if defined(OS_WIN) |
+gfx::NativeViewAccessible |
+WebContentsViewAura::GetNativeViewAccessible() { |
+ BrowserAccessibilityManager* manager = |
+ web_contents_->GetRootBrowserAccessibilityManager(); |
+ if (!manager) |
+ return NULL; |
+ |
+ return manager->GetRoot()->ToBrowserAccessibilityWin(); |
+} |
+#endif |
+ |
} // namespace content |