OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <mmsystem.h> | 8 #include <mmsystem.h> |
9 | 9 |
10 #include "base/event_recorder.h" | 10 #include "base/event_recorder.h" |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 return ::CallNextHookEx(journal_hook_, nCode, wParam, lParam); | 172 return ::CallNextHookEx(journal_hook_, nCode, wParam, lParam); |
173 | 173 |
174 // Check for the break key being pressed and stop recording. | 174 // Check for the break key being pressed and stop recording. |
175 if (::GetKeyState(VK_CANCEL) & 0x8000) { | 175 if (::GetKeyState(VK_CANCEL) & 0x8000) { |
176 StopRecording(); | 176 StopRecording(); |
177 return ::CallNextHookEx(journal_hook_, nCode, wParam, lParam); | 177 return ::CallNextHookEx(journal_hook_, nCode, wParam, lParam); |
178 } | 178 } |
179 | 179 |
180 // The Journal Recorder must stop recording events when system modal | 180 // The Journal Recorder must stop recording events when system modal |
181 // dialogs are present. (see msdn link above) | 181 // dialogs are present. (see msdn link above) |
182 switch(nCode) { | 182 switch (nCode) { |
183 case HC_SYSMODALON: | 183 case HC_SYSMODALON: |
184 recording_enabled = false; | 184 recording_enabled = false; |
185 break; | 185 break; |
186 case HC_SYSMODALOFF: | 186 case HC_SYSMODALOFF: |
187 recording_enabled = true; | 187 recording_enabled = true; |
188 break; | 188 break; |
189 } | 189 } |
190 | 190 |
191 if (nCode == HC_ACTION && recording_enabled) { | 191 if (nCode == HC_ACTION && recording_enabled) { |
192 // Aha - we have an event to record. | 192 // Aha - we have an event to record. |
193 msg_ptr = reinterpret_cast<EVENTMSG*>(lParam); | 193 msg_ptr = reinterpret_cast<EVENTMSG*>(lParam); |
194 msg_ptr->time = timeGetTime(); | 194 msg_ptr->time = timeGetTime(); |
195 fwrite(msg_ptr, sizeof(EVENTMSG), 1, file_); | 195 fwrite(msg_ptr, sizeof(EVENTMSG), 1, file_); |
196 fflush(file_); | 196 fflush(file_); |
197 } | 197 } |
198 | 198 |
199 return CallNextHookEx(journal_hook_, nCode, wParam, lParam); | 199 return CallNextHookEx(journal_hook_, nCode, wParam, lParam); |
200 } | 200 } |
201 | 201 |
202 // Windows callback for the playback mode. | 202 // Windows callback for the playback mode. |
203 LRESULT EventRecorder::PlaybackWndProc(int nCode, WPARAM wParam, | 203 LRESULT EventRecorder::PlaybackWndProc(int nCode, WPARAM wParam, |
204 LPARAM lParam) { | 204 LPARAM lParam) { |
205 static bool playback_enabled = true; | 205 static bool playback_enabled = true; |
206 int delay = 0; | 206 int delay = 0; |
207 | 207 |
208 switch(nCode) { | 208 switch (nCode) { |
209 // A system modal dialog box is being displayed. Stop playing back | 209 // A system modal dialog box is being displayed. Stop playing back |
210 // messages. | 210 // messages. |
211 case HC_SYSMODALON: | 211 case HC_SYSMODALON: |
212 playback_enabled = false; | 212 playback_enabled = false; |
213 break; | 213 break; |
214 | 214 |
215 // A system modal dialog box is destroyed. We can start playing back | 215 // A system modal dialog box is destroyed. We can start playing back |
216 // messages again. | 216 // messages again. |
217 case HC_SYSMODALOFF: | 217 case HC_SYSMODALOFF: |
218 playback_enabled = true; | 218 playback_enabled = true; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 // indicating that the message is not removed from the message queue after | 250 // indicating that the message is not removed from the message queue after |
251 // PeekMessage processing. | 251 // PeekMessage processing. |
252 case HC_NOREMOVE: | 252 case HC_NOREMOVE: |
253 break; | 253 break; |
254 } | 254 } |
255 | 255 |
256 return CallNextHookEx(journal_hook_, nCode, wParam, lParam); | 256 return CallNextHookEx(journal_hook_, nCode, wParam, lParam); |
257 } | 257 } |
258 | 258 |
259 } // namespace base | 259 } // namespace base |
OLD | NEW |