| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/automation/ui_controls_internal.h" | 5 #include "ui/ui_controls/ui_controls_internal_win.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "ui/base/keycodes/keyboard_code_conversion_win.h" | 12 #include "ui/base/keycodes/keyboard_code_conversion_win.h" |
| 13 #include "ui/base/keycodes/keyboard_codes.h" | 13 #include "ui/base/keycodes/keyboard_codes.h" |
| 14 | 14 |
| 15 #if defined(USE_AURA) | 15 #if defined(USE_AURA) |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 return false; | 164 return false; |
| 165 | 165 |
| 166 return true; | 166 return true; |
| 167 } | 167 } |
| 168 | 168 |
| 169 } // namespace | 169 } // namespace |
| 170 | 170 |
| 171 namespace ui_controls { | 171 namespace ui_controls { |
| 172 namespace internal { | 172 namespace internal { |
| 173 | 173 |
| 174 bool SendKeyPressImpl(gfx::NativeWindow native_window, | 174 bool SendKeyPressImpl(HWND window, |
| 175 ui::KeyboardCode key, | 175 ui::KeyboardCode key, |
| 176 bool control, | 176 bool control, |
| 177 bool shift, | 177 bool shift, |
| 178 bool alt, | 178 bool alt, |
| 179 const base::Closure& task) { | 179 const base::Closure& task) { |
| 180 // SendInput only works as we expect it if one of our windows is the | 180 // SendInput only works as we expect it if one of our windows is the |
| 181 // foreground window already. | 181 // foreground window already. |
| 182 #if defined(USE_AURA) | |
| 183 HWND window = native_window->GetRootWindow()->GetAcceleratedWidget(); | |
| 184 #else | |
| 185 HWND window = native_window; | |
| 186 #endif | |
| 187 HWND target_window = (::GetActiveWindow() && | 182 HWND target_window = (::GetActiveWindow() && |
| 188 ::GetWindow(::GetActiveWindow(), GW_OWNER) == window) ? | 183 ::GetWindow(::GetActiveWindow(), GW_OWNER) == window) ? |
| 189 ::GetActiveWindow() : | 184 ::GetActiveWindow() : |
| 190 window; | 185 window; |
| 191 if (window && ::GetForegroundWindow() != target_window) | 186 if (window && ::GetForegroundWindow() != target_window) |
| 192 return false; | 187 return false; |
| 193 | 188 |
| 194 scoped_refptr<InputDispatcher> dispatcher( | 189 scoped_refptr<InputDispatcher> dispatcher( |
| 195 !task.is_null() ? new InputDispatcher(task, WM_KEYUP) : NULL); | 190 !task.is_null() ? new InputDispatcher(task, WM_KEYUP) : NULL); |
| 196 | 191 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 return false; | 338 return false; |
| 344 | 339 |
| 345 if (dispatcher.get()) | 340 if (dispatcher.get()) |
| 346 dispatcher->AddRef(); | 341 dispatcher->AddRef(); |
| 347 | 342 |
| 348 return true; | 343 return true; |
| 349 } | 344 } |
| 350 | 345 |
| 351 } // namespace internal | 346 } // namespace internal |
| 352 } // namespace ui_controls | 347 } // namespace ui_controls |
| OLD | NEW |