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 327e0b9b43e73df9a7280366ecd5d05eed899ba2..25333b365c2609e261f348d8433019979cbbd07c 100644 |
--- a/content/browser/renderer_host/legacy_render_widget_host_win.cc |
+++ b/content/browser/renderer_host/legacy_render_widget_host_win.cc |
@@ -7,8 +7,7 @@ |
#include "base/command_line.h" |
#include "base/memory/scoped_ptr.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" |
@@ -22,40 +21,44 @@ |
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() { |
+ if (::IsWindow(hwnd())) |
+ ::DestroyWindow(hwnd()); |
+} |
+ |
// static |
LegacyRenderWidgetHostHWND* LegacyRenderWidgetHostHWND::Create( |
- HWND parent) { |
- // 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. |
+ HWND parent, |
+ LegacyRenderWidgetHostHWNDDelegate* delegate) { |
if (CommandLine::ForCurrentProcess()->HasSwitch( |
- switches::kDisableLegacyIntermediateWindow) || |
- (!GetWindowEventTarget(parent) && parent != ::GetDesktopWindow())) |
- return NULL; |
+ switches::kDisableLegacyIntermediateWindow)) { |
+ 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 NULL. |
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 (!::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 |
@@ -68,49 +71,49 @@ 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 = gfx::win::DIPToScreenRect(bounds); |
::SetWindowPos(hwnd(), NULL, bounds_in_pixel.x(), bounds_in_pixel.y(), |
bounds_in_pixel.width(), bounds_in_pixel.height(), |
SWP_NOREDRAW); |
} |
-void LegacyRenderWidgetHostHWND::OnFinalMessage(HWND hwnd) { |
- if (host_) { |
- host_->OnLegacyWindowDestroyed(); |
- host_ = NULL; |
- } |
- 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()) |
+ ui::AreTouchEventsEnabled()) { |
RegisterTouchWindow(hwnd(), TWF_WANTPALM); |
+ } |
HRESULT hr = ::CreateStdAccessibleObject( |
hwnd(), OBJID_WINDOW, IID_IAccessible, |
@@ -154,24 +157,16 @@ LRESULT LegacyRenderWidgetHostHWND::OnGetObject(UINT message, |
return static_cast<LRESULT>(0L); |
} |
- if (OBJID_CLIENT != obj_id || !host_) |
- return static_cast<LRESULT>(0L); |
- |
- RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From( |
- host_->GetRenderWidgetHost()); |
- if (!rwhi) |
+ if (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( |
- manager->GetRoot()->ToBrowserAccessibilityWin()); |
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. |