| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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.h" | 5 #include "chrome/browser/automation/ui_controls.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 #include <mach/mach_time.h> | 8 #include <mach/mach_time.h> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 | 233 |
| 234 // Win and Linux implement a SendKeyPress() this as a | 234 // Win and Linux implement a SendKeyPress() this as a |
| 235 // SendKeyPressAndRelease(), so we should as well (despite the name). | 235 // SendKeyPressAndRelease(), so we should as well (despite the name). |
| 236 bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window, | 236 bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window, |
| 237 app::KeyboardCode key, | 237 app::KeyboardCode key, |
| 238 bool control, | 238 bool control, |
| 239 bool shift, | 239 bool shift, |
| 240 bool alt, | 240 bool alt, |
| 241 bool command, | 241 bool command, |
| 242 Task* task) { | 242 Task* task) { |
| 243 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); | 243 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 244 | 244 |
| 245 std::vector<NSEvent*> events; | 245 std::vector<NSEvent*> events; |
| 246 SynthesizeKeyEventsSequence( | 246 SynthesizeKeyEventsSequence( |
| 247 window, key, control, shift, alt, command, &events); | 247 window, key, control, shift, alt, command, &events); |
| 248 | 248 |
| 249 // TODO(suzhe): Using [NSApplication postEvent:atStart:] here causes | 249 // TODO(suzhe): Using [NSApplication postEvent:atStart:] here causes |
| 250 // BrowserKeyEventsTest.CommandKeyEvents to fail. See http://crbug.com/49270 | 250 // BrowserKeyEventsTest.CommandKeyEvents to fail. See http://crbug.com/49270 |
| 251 // But using [NSApplication sendEvent:] should be safe for keyboard events, | 251 // But using [NSApplication sendEvent:] should be safe for keyboard events, |
| 252 // because until now, no code wants to retrieve the next event when handling | 252 // because until now, no code wants to retrieve the next event when handling |
| 253 // a keyboard event. | 253 // a keyboard event. |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 NSPoint center = NSMakePoint(NSMidX(bounds), NSMidY(bounds)); | 373 NSPoint center = NSMakePoint(NSMidX(bounds), NSMidY(bounds)); |
| 374 center = [view convertPoint:center toView:nil]; | 374 center = [view convertPoint:center toView:nil]; |
| 375 center = [window convertBaseToScreen:center]; | 375 center = [window convertBaseToScreen:center]; |
| 376 center = NSMakePoint(center.x, [screen frame].size.height - center.y); | 376 center = NSMakePoint(center.x, [screen frame].size.height - center.y); |
| 377 | 377 |
| 378 SendMouseMoveNotifyWhenDone(center.x, center.y, | 378 SendMouseMoveNotifyWhenDone(center.x, center.y, |
| 379 new ClickTask(button, state, task)); | 379 new ClickTask(button, state, task)); |
| 380 } | 380 } |
| 381 | 381 |
| 382 } // ui_controls | 382 } // ui_controls |
| OLD | NEW |