Index: content/browser/renderer_host/legacy_render_widget_host_win.cc |
diff --git a/content/browser/renderer_host/legacy_render_widget_host_win.cc b/content/browser/renderer_host/legacy_render_widget_host_win.cc |
index 3afb92cbe59ef0f2d8a18f74448db133b69e8ad0..4723979d1ac59d616a27a89a5dea7b53f0e8f107 100644 |
--- a/content/browser/renderer_host/legacy_render_widget_host_win.cc |
+++ b/content/browser/renderer_host/legacy_render_widget_host_win.cc |
@@ -9,8 +9,7 @@ |
#include "base/command_line.h" |
#include "base/win/win_util.h" |
#include "base/win/windows_version.h" |
-#include "content/browser/accessibility/browser_accessibility_manager_win.h" |
-#include "content/browser/accessibility/browser_accessibility_win.h" |
+#include "content/browser/renderer_host/legacy_render_widget_host_win_delegate.h" |
#include "content/browser/renderer_host/render_widget_host_impl.h" |
#include "content/browser/renderer_host/render_widget_host_view_aura.h" |
#include "content/public/browser/browser_accessibility_state.h" |
@@ -25,14 +24,27 @@ |
namespace content { |
+namespace { |
+ |
// A custom MSAA object id used to determine if a screen reader or some |
// other client is listening on MSAA events - if so, we enable full web |
// accessibility support. |
const int kIdScreenReaderHoneyPot = 1; |
+} // namespace |
+ |
+LegacyRenderWidgetHostHWND::~LegacyRenderWidgetHostHWND() { |
+ // Re-enable flicks for just a moment |
+ base::win::EnableFlicks(hwnd()); |
+ |
+ if (::IsWindow(hwnd())) |
+ ::DestroyWindow(hwnd()); |
+} |
+ |
// static |
LegacyRenderWidgetHostHWND* LegacyRenderWidgetHostHWND::Create( |
- HWND parent) { |
+ HWND parent, |
+ LegacyRenderWidgetHostHWNDDelegate* delegate) { |
// content_unittests passes in the desktop window as the parent. We allow |
// the LegacyRenderWidgetHostHWND instance to be created in this case for |
// these tests to pass. |
@@ -42,25 +54,24 @@ LegacyRenderWidgetHostHWND* LegacyRenderWidgetHostHWND::Create( |
return nullptr; |
LegacyRenderWidgetHostHWND* legacy_window_instance = |
- new LegacyRenderWidgetHostHWND(parent); |
- // If we failed to create the child, or if the switch to disable the legacy |
- // window is passed in, then return NULL. |
+ new LegacyRenderWidgetHostHWND(parent, delegate); |
+ |
+ // If we failed to create the child, return nullptr. |
if (!::IsWindow(legacy_window_instance->hwnd())) { |
delete legacy_window_instance; |
- return NULL; |
+ return nullptr; |
} |
legacy_window_instance->Init(); |
return legacy_window_instance; |
} |
-void LegacyRenderWidgetHostHWND::Destroy() { |
- if (::IsWindow(hwnd())) |
- ::DestroyWindow(hwnd()); |
-} |
- |
void LegacyRenderWidgetHostHWND::UpdateParent(HWND parent) { |
if (GetWindowEventTarget(GetParent())) |
GetWindowEventTarget(GetParent())->HandleParentChanged(); |
+ |
+ if (!::IsWindow(hwnd())) |
+ return; |
+ |
::SetParent(hwnd(), parent); |
// If the new parent is the desktop Window, then we disable the child window |
// to ensure that it does not receive any input events. It should not because |
@@ -73,18 +84,26 @@ void LegacyRenderWidgetHostHWND::UpdateParent(HWND parent) { |
} |
HWND LegacyRenderWidgetHostHWND::GetParent() { |
+ if (!::IsWindow(hwnd())) |
+ return NULL; |
+ |
return ::GetParent(hwnd()); |
} |
void LegacyRenderWidgetHostHWND::Show() { |
- ::ShowWindow(hwnd(), SW_SHOW); |
+ if (::IsWindow(hwnd())) |
+ ::ShowWindow(hwnd(), SW_SHOW); |
} |
void LegacyRenderWidgetHostHWND::Hide() { |
- ::ShowWindow(hwnd(), SW_HIDE); |
+ if (::IsWindow(hwnd())) |
+ ::ShowWindow(hwnd(), SW_HIDE); |
} |
void LegacyRenderWidgetHostHWND::SetBounds(const gfx::Rect& bounds) { |
+ if (!::IsWindow(hwnd())) |
+ return; |
+ |
gfx::Rect bounds_in_pixel = display::win::ScreenWin::DIPToClientRect(hwnd(), |
bounds); |
::SetWindowPos(hwnd(), NULL, bounds_in_pixel.x(), bounds_in_pixel.y(), |
@@ -94,31 +113,18 @@ void LegacyRenderWidgetHostHWND::SetBounds(const gfx::Rect& bounds) { |
direct_manipulation_helper_->SetBounds(bounds_in_pixel); |
} |
-void LegacyRenderWidgetHostHWND::OnFinalMessage(HWND hwnd) { |
- if (host_) { |
- host_->OnLegacyWindowDestroyed(); |
- host_ = NULL; |
- } |
- |
- // Re-enable flicks for just a moment |
- base::win::EnableFlicks(hwnd); |
- |
- delete this; |
-} |
- |
-LegacyRenderWidgetHostHWND::LegacyRenderWidgetHostHWND(HWND parent) |
+LegacyRenderWidgetHostHWND::LegacyRenderWidgetHostHWND( |
+ HWND parent, |
+ LegacyRenderWidgetHostHWNDDelegate* delegate) |
: mouse_tracking_enabled_(false), |
- host_(NULL) { |
+ delegate_(delegate) { |
+ DCHECK(delegate_); |
RECT rect = {0}; |
Base::Create(parent, rect, L"Chrome Legacy Window", |
WS_CHILDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, |
WS_EX_TRANSPARENT); |
} |
-LegacyRenderWidgetHostHWND::~LegacyRenderWidgetHostHWND() { |
- DCHECK(!::IsWindow(hwnd())); |
-} |
- |
bool LegacyRenderWidgetHostHWND::Init() { |
if (base::win::GetVersion() >= base::win::VERSION_WIN7 && |
ui::AreTouchEventsEnabled()) |
@@ -176,24 +182,16 @@ LRESULT LegacyRenderWidgetHostHWND::OnGetObject(UINT message, |
return static_cast<LRESULT>(0L); |
} |
- if (static_cast<DWORD>(OBJID_CLIENT) != obj_id || !host_) |
- return static_cast<LRESULT>(0L); |
- |
- RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From( |
- host_->GetRenderWidgetHost()); |
- if (!rwhi) |
+ if (static_cast<DWORD>(OBJID_CLIENT) != obj_id) |
return static_cast<LRESULT>(0L); |
- BrowserAccessibilityManagerWin* manager = |
- static_cast<BrowserAccessibilityManagerWin*>( |
- rwhi->GetRootBrowserAccessibilityManager()); |
- if (!manager) |
+ base::win::ScopedComPtr<IAccessible> native_accessible( |
+ delegate_->GetNativeViewAccessible()); |
+ if (!native_accessible) |
return static_cast<LRESULT>(0L); |
- base::win::ScopedComPtr<IAccessible> root( |
- ToBrowserAccessibilityWin(manager->GetRoot())); |
return LresultFromObject(IID_IAccessible, w_param, |
- static_cast<IAccessible*>(root.Detach())); |
+ static_cast<IAccessible*>(native_accessible.Detach())); |
} |
// We send keyboard/mouse/touch messages to the parent window via SendMessage. |