Chromium Code Reviews| 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 3ba80e72ff818489f835cd3ef50174083b910ab2..59b40c19f83124dd885ba7a1b8b096862601337d 100644 |
| --- a/content/browser/web_contents/web_contents_view_aura.cc |
| +++ b/content/browser/web_contents/web_contents_view_aura.cc |
| @@ -67,10 +67,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, |
| @@ -642,6 +649,10 @@ class WebContentsViewAura::WindowObserver |
| #if defined(OS_WIN) |
| if (!window->GetRootWindow()->HasObserver(this)) |
| window->GetRootWindow()->AddObserver(this); |
| + if (view_->legacy_hwnd_) { |
| + view_->legacy_hwnd_->UpdateParent( |
| + window->GetHost()->GetAcceleratedWidget()); |
| + } |
| #endif |
| } |
| } |
| @@ -661,6 +672,9 @@ class WebContentsViewAura::WindowObserver |
| root_children[i]->RemoveObserver(this); |
| } |
| } |
| + |
| + if (view_->legacy_hwnd_) |
| + view_->legacy_hwnd_->UpdateParent(ui::GetHiddenWindow()); |
| #endif |
| } |
| } |
| @@ -1017,6 +1031,10 @@ void WebContentsViewAura::SizeContents(const gfx::Size& size) { |
| if (bounds.size() != size) { |
| bounds.set_size(size); |
| window_->SetBounds(bounds); |
| +#if defined(OS_WIN) |
| + if (legacy_hwnd_) |
| + legacy_hwnd_->SetBounds(window_->GetBoundsInRootWindow()); |
| +#endif |
| } 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. |
| @@ -1110,6 +1128,14 @@ void WebContentsViewAura::CreateView( |
| // platforms as well. |
| if (delegate_) |
| drag_dest_delegate_ = delegate_->GetDragDestDelegate(); |
| + |
| +#if defined(OS_WIN) |
| + if (context && context->GetHost()) { |
| + HWND parent_hwnd = context->GetHost()->GetAcceleratedWidget(); |
| + CHECK(parent_hwnd); |
| + legacy_hwnd_.reset(LegacyRenderWidgetHostHWND::Create(parent_hwnd, this)); |
| + } |
| +#endif |
| } |
| RenderWidgetHostViewBase* WebContentsViewAura::CreateViewForWidget( |
| @@ -1150,12 +1176,24 @@ RenderWidgetHostViewBase* WebContentsViewAura::CreateViewForWidget( |
| } |
| AttachTouchEditableToRenderView(); |
| + |
| +#if defined(OS_WIN) |
| + if (legacy_hwnd_) |
| + view->SetLegacyRenderWidgetHostHWND(legacy_hwnd_.get()); |
| +#endif |
| + |
| return view; |
| } |
| RenderWidgetHostViewBase* WebContentsViewAura::CreateViewForPopupWidget( |
| RenderWidgetHost* render_widget_host) { |
| - return new RenderWidgetHostViewAura(render_widget_host, false); |
| + RenderWidgetHostViewAura* view = |
| + new RenderWidgetHostViewAura(render_widget_host, false); |
| +#if defined(OS_WIN) |
| + if (legacy_hwnd_) |
| + view->SetLegacyRenderWidgetHostHWND(legacy_hwnd_.get()); |
| +#endif |
| + return view; |
| } |
| void WebContentsViewAura::SetPageTitle(const base::string16& title) { |
| @@ -1635,6 +1673,35 @@ void WebContentsViewAura::UpdateWebContentsVisibility(bool visible) { |
| if (web_contents_->should_normally_be_visible()) |
| web_contents_->WasHidden(); |
| } |
| + |
| +#if defined(OS_WIN) |
| + if (!legacy_hwnd_) |
| + return; |
| + |
| + if (visible && GetNativeView() && GetNativeView()->GetHost()) { |
| + 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; |
|
sky
2014/10/27 15:21:33
nullptr
dmazzoni
2014/10/27 20:32:32
Done.
|
| + |
| + return manager->GetRoot()->ToBrowserAccessibilityWin(); |
| } |
| +#endif |
| } // namespace content |