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 6ca6445822c027431da126a18f7173a591bff694..11ae2a919b6a2a3630dd1c64bbdb094c3f86e129 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 |
@@ -85,17 +79,11 @@ void LegacyRenderWidgetHostHWND::SetBounds(const gfx::Rect& bounds) { |
bounds_in_pixel.width(), bounds_in_pixel.height(), 0); |
} |
-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, |
@@ -103,13 +91,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, |
@@ -153,24 +143,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. |