| OLD | NEW |
| 1 // Copyright (c) 2010 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_frame/test/simulate_input.h" | 5 #include "chrome_frame/test/simulate_input.h" |
| 6 | 6 |
| 7 #include <atlbase.h> | 7 #include <atlbase.h> |
| 8 #include <atlwin.h> | 8 #include <atlwin.h> |
| 9 | 9 |
| 10 #include "chrome_frame/utils.h" | 10 #include "chrome_frame/utils.h" |
| 11 | 11 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 HWND hwnd = GetForegroundWindow(); | 94 HWND hwnd = GetForegroundWindow(); |
| 95 base::ProcessId current_foreground_pid = 0; | 95 base::ProcessId current_foreground_pid = 0; |
| 96 DWORD active_thread_id = GetWindowThreadProcessId(hwnd, | 96 DWORD active_thread_id = GetWindowThreadProcessId(hwnd, |
| 97 ¤t_foreground_pid); | 97 ¤t_foreground_pid); |
| 98 if (current_foreground_pid == process_id) | 98 if (current_foreground_pid == process_id) |
| 99 return true; | 99 return true; |
| 100 | 100 |
| 101 PidAndWindow paw = { process_id }; | 101 PidAndWindow paw = { process_id }; |
| 102 EnumWindows(FindWindowInProcessCallback, reinterpret_cast<LPARAM>(&paw)); | 102 EnumWindows(FindWindowInProcessCallback, reinterpret_cast<LPARAM>(&paw)); |
| 103 if (!IsWindow(paw.hwnd)) { | 103 if (!IsWindow(paw.hwnd)) { |
| 104 DLOG(ERROR) << "failed to find process window"; | 104 LOG(ERROR) << "failed to find process window"; |
| 105 return false; | 105 return false; |
| 106 } | 106 } |
| 107 | 107 |
| 108 bool ret = ForceSetForegroundWindow(paw.hwnd); | 108 bool ret = ForceSetForegroundWindow(paw.hwnd); |
| 109 LOG_IF(ERROR, !ret) << "ForceSetForegroundWindow: " << ret; | 109 LOG_IF(ERROR, !ret) << "ForceSetForegroundWindow: " << ret; |
| 110 | 110 |
| 111 return ret; | 111 return ret; |
| 112 } | 112 } |
| 113 | 113 |
| 114 void SendScanCode(short scan_code, Modifier modifiers) { | 114 void SendScanCode(short scan_code, Modifier modifiers) { |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 } | 252 } |
| 253 | 253 |
| 254 void SendStringA(const std::string& s) { | 254 void SendStringA(const std::string& s) { |
| 255 for (size_t i = 0; i < s.length(); i++) { | 255 for (size_t i = 0; i < s.length(); i++) { |
| 256 SendCharA(s[i], NONE); | 256 SendCharA(s[i], NONE); |
| 257 Sleep(10); | 257 Sleep(10); |
| 258 } | 258 } |
| 259 } | 259 } |
| 260 | 260 |
| 261 } // namespace simulate_input | 261 } // namespace simulate_input |
| 262 | |
| OLD | NEW |