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..d4b78796d3de853e51ec0259e049ab8773c7135e 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,6 @@ |
#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/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,26 +20,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 |
+ |
// 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())) |
+ switches::kDisableLegacyIntermediateWindow)) { |
return NULL; |
+ } |
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; |
@@ -50,11 +49,6 @@ LegacyRenderWidgetHostHWND* LegacyRenderWidgetHostHWND::Create( |
return legacy_window_instance; |
} |
-void LegacyRenderWidgetHostHWND::Destroy() { |
- if (::IsWindow(hwnd())) |
- ::DestroyWindow(hwnd()); |
-} |
- |
void LegacyRenderWidgetHostHWND::UpdateParent(HWND parent) { |
::SetParent(hwnd(), parent); |
// If the new parent is the desktop Window, then we disable the child window |
@@ -86,17 +80,11 @@ void LegacyRenderWidgetHostHWND::SetBounds(const gfx::Rect& bounds) { |
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) { |
RECT rect = {0}; |
Base::Create(parent, rect, L"Chrome Legacy Window", |
WS_CHILDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, |
@@ -104,13 +92,15 @@ LegacyRenderWidgetHostHWND::LegacyRenderWidgetHostHWND(HWND parent) |
} |
LegacyRenderWidgetHostHWND::~LegacyRenderWidgetHostHWND() { |
- DCHECK(!::IsWindow(hwnd())); |
+ if (::IsWindow(hwnd())) |
+ ::DestroyWindow(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 +144,17 @@ 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) |
+ DCHECK(delegate_); |
+ 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. |