OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/renderer_host/legacy_render_widget_host_win.h" | 5 #include "content/browser/renderer_host/legacy_render_widget_host_win.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/win/windows_version.h" | 9 #include "base/win/windows_version.h" |
10 #include "content/browser/accessibility/browser_accessibility_manager_win.h" | 10 #include "content/browser/accessibility/browser_accessibility_manager_win.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 reinterpret_cast<void **>(window_accessible_.Receive())); | 117 reinterpret_cast<void **>(window_accessible_.Receive())); |
118 DCHECK(SUCCEEDED(hr)); | 118 DCHECK(SUCCEEDED(hr)); |
119 | 119 |
120 if (!BrowserAccessibilityState::GetInstance()->IsAccessibleBrowser()) { | 120 if (!BrowserAccessibilityState::GetInstance()->IsAccessibleBrowser()) { |
121 // Attempt to detect screen readers or other clients who want full | 121 // Attempt to detect screen readers or other clients who want full |
122 // accessibility support, by seeing if they respond to this event. | 122 // accessibility support, by seeing if they respond to this event. |
123 NotifyWinEvent(EVENT_SYSTEM_ALERT, hwnd(), kIdScreenReaderHoneyPot, | 123 NotifyWinEvent(EVENT_SYSTEM_ALERT, hwnd(), kIdScreenReaderHoneyPot, |
124 CHILDID_SELF); | 124 CHILDID_SELF); |
125 } | 125 } |
126 | 126 |
127 // http://crbug.com/440579 TODO(dmazzoni): remove this logging when | |
128 // flakiness is fixed. | |
129 LOG(INFO) << "LegacyRenderWidgetHostHWND::Init hwnd=" << hwnd(); | |
130 | |
131 return !!SUCCEEDED(hr); | 127 return !!SUCCEEDED(hr); |
132 } | 128 } |
133 | 129 |
134 // static | 130 // static |
135 ui::WindowEventTarget* LegacyRenderWidgetHostHWND::GetWindowEventTarget( | 131 ui::WindowEventTarget* LegacyRenderWidgetHostHWND::GetWindowEventTarget( |
136 HWND parent) { | 132 HWND parent) { |
137 return reinterpret_cast<ui::WindowEventTarget*>(ui::ViewProp::GetValue( | 133 return reinterpret_cast<ui::WindowEventTarget*>(ui::ViewProp::GetValue( |
138 parent, ui::WindowEventTarget::kWin32InputEventTarget)); | 134 parent, ui::WindowEventTarget::kWin32InputEventTarget)); |
139 } | 135 } |
140 | 136 |
141 LRESULT LegacyRenderWidgetHostHWND::OnEraseBkGnd(UINT message, | 137 LRESULT LegacyRenderWidgetHostHWND::OnEraseBkGnd(UINT message, |
142 WPARAM w_param, | 138 WPARAM w_param, |
143 LPARAM l_param) { | 139 LPARAM l_param) { |
144 return 1; | 140 return 1; |
145 } | 141 } |
146 | 142 |
147 LRESULT LegacyRenderWidgetHostHWND::OnGetObject(UINT message, | 143 LRESULT LegacyRenderWidgetHostHWND::OnGetObject(UINT message, |
148 WPARAM w_param, | 144 WPARAM w_param, |
149 LPARAM l_param) { | 145 LPARAM l_param) { |
150 // Only the lower 32 bits of l_param are valid when checking the object id | 146 // Only the lower 32 bits of l_param are valid when checking the object id |
151 // because it sometimes gets sign-extended incorrectly (but not always). | 147 // because it sometimes gets sign-extended incorrectly (but not always). |
152 DWORD obj_id = static_cast<DWORD>(static_cast<DWORD_PTR>(l_param)); | 148 DWORD obj_id = static_cast<DWORD>(static_cast<DWORD_PTR>(l_param)); |
153 | 149 |
154 // http://crbug.com/440579 TODO(dmazzoni): remove this logging when | |
155 // flakiness is fixed. | |
156 LOG(INFO) << "LegacyRenderWidgetHostHWND::OnGetObject" | |
157 << " message=" << message | |
158 << " w_param=" << w_param | |
159 << " l_param=" << l_param | |
160 << " obj_id=" << obj_id | |
161 << " host_=" << host_; | |
162 | |
163 if (kIdScreenReaderHoneyPot == obj_id) { | 150 if (kIdScreenReaderHoneyPot == obj_id) { |
164 // When an MSAA client has responded to our fake event on this id, | 151 // When an MSAA client has responded to our fake event on this id, |
165 // enable screen reader support. | 152 // enable screen reader support. |
166 BrowserAccessibilityState::GetInstance()->OnScreenReaderDetected(); | 153 BrowserAccessibilityState::GetInstance()->OnScreenReaderDetected(); |
167 return static_cast<LRESULT>(0L); | 154 return static_cast<LRESULT>(0L); |
168 } | 155 } |
169 | 156 |
170 if (OBJID_CLIENT != obj_id || !host_) | 157 if (OBJID_CLIENT != obj_id || !host_) |
171 return static_cast<LRESULT>(0L); | 158 return static_cast<LRESULT>(0L); |
172 | 159 |
173 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From( | 160 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From( |
174 host_->GetRenderWidgetHost()); | 161 host_->GetRenderWidgetHost()); |
175 if (!rwhi) { | 162 if (!rwhi) |
176 LOG(WARNING) << "No RWHI"; | |
177 return static_cast<LRESULT>(0L); | 163 return static_cast<LRESULT>(0L); |
178 } | |
179 | 164 |
180 BrowserAccessibilityManagerWin* manager = | 165 BrowserAccessibilityManagerWin* manager = |
181 static_cast<BrowserAccessibilityManagerWin*>( | 166 static_cast<BrowserAccessibilityManagerWin*>( |
182 rwhi->GetRootBrowserAccessibilityManager()); | 167 rwhi->GetRootBrowserAccessibilityManager()); |
183 if (!manager) { | 168 if (!manager) |
184 LOG(WARNING) << "No manager"; | |
185 return static_cast<LRESULT>(0L); | 169 return static_cast<LRESULT>(0L); |
186 } | |
187 | 170 |
188 base::win::ScopedComPtr<IAccessible> root( | 171 base::win::ScopedComPtr<IAccessible> root( |
189 manager->GetRoot()->ToBrowserAccessibilityWin()); | 172 manager->GetRoot()->ToBrowserAccessibilityWin()); |
190 return LresultFromObject(IID_IAccessible, w_param, | 173 return LresultFromObject(IID_IAccessible, w_param, |
191 static_cast<IAccessible*>(root.Detach())); | 174 static_cast<IAccessible*>(root.Detach())); |
192 } | 175 } |
193 | 176 |
194 // We send keyboard/mouse/touch messages to the parent window via SendMessage. | 177 // We send keyboard/mouse/touch messages to the parent window via SendMessage. |
195 // While this works, this has the side effect of converting input messages into | 178 // While this works, this has the side effect of converting input messages into |
196 // sent messages which changes their priority and could technically result | 179 // sent messages which changes their priority and could technically result |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 // generate the legacy WM_VSCROLL/WM_HSCROLL messages. | 371 // generate the legacy WM_VSCROLL/WM_HSCROLL messages. |
389 // We add these styles to ensure that trackpad/trackpoint scrolling | 372 // We add these styles to ensure that trackpad/trackpoint scrolling |
390 // work. | 373 // work. |
391 long current_style = ::GetWindowLong(hwnd(), GWL_STYLE); | 374 long current_style = ::GetWindowLong(hwnd(), GWL_STYLE); |
392 ::SetWindowLong(hwnd(), GWL_STYLE, | 375 ::SetWindowLong(hwnd(), GWL_STYLE, |
393 current_style | WS_VSCROLL | WS_HSCROLL); | 376 current_style | WS_VSCROLL | WS_HSCROLL); |
394 return 0; | 377 return 0; |
395 } | 378 } |
396 | 379 |
397 } // namespace content | 380 } // namespace content |
OLD | NEW |