| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
| 14 #include "chrome/browser/automation/ui_controls_internal.h" | 14 #include "chrome/browser/automation/ui_controls_internal.h" |
| 15 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
| 16 #include "ui/base/keycodes/keyboard_code_conversion_mac.h" | 16 #include "ui/base/keycodes/keyboard_code_conversion_mac.h" |
| 17 | 17 |
| 18 using content::BrowserThread; |
| 19 |
| 18 // Implementation details: We use [NSApplication sendEvent:] instead | 20 // Implementation details: We use [NSApplication sendEvent:] instead |
| 19 // of [NSApplication postEvent:atStart:] so that the event gets sent | 21 // of [NSApplication postEvent:atStart:] so that the event gets sent |
| 20 // immediately. This lets us run the post-event task right | 22 // immediately. This lets us run the post-event task right |
| 21 // immediately as well. Unfortunately I cannot subclass NSEvent (it's | 23 // immediately as well. Unfortunately I cannot subclass NSEvent (it's |
| 22 // probably a class cluster) to allow other easy answers. For | 24 // probably a class cluster) to allow other easy answers. For |
| 23 // example, if I could subclass NSEvent, I could run the Task in it's | 25 // example, if I could subclass NSEvent, I could run the Task in it's |
| 24 // dealloc routine (which necessarily happens after the event is | 26 // dealloc routine (which necessarily happens after the event is |
| 25 // dispatched). Unlike Linux, Mac does not have message loop | 27 // dispatched). Unlike Linux, Mac does not have message loop |
| 26 // observer/notification. Unlike windows, I cannot post non-events | 28 // observer/notification. Unlike windows, I cannot post non-events |
| 27 // into the event queue. (I can post other kinds of tasks but can't | 29 // into the event queue. (I can post other kinds of tasks but can't |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 center = [view convertPoint:center toView:nil]; | 378 center = [view convertPoint:center toView:nil]; |
| 377 center = [window convertBaseToScreen:center]; | 379 center = [window convertBaseToScreen:center]; |
| 378 center = NSMakePoint(center.x, [screen frame].size.height - center.y); | 380 center = NSMakePoint(center.x, [screen frame].size.height - center.y); |
| 379 | 381 |
| 380 SendMouseMoveNotifyWhenDone( | 382 SendMouseMoveNotifyWhenDone( |
| 381 center.x, center.y, | 383 center.x, center.y, |
| 382 base::Bind(&ui_controls::ClickTask, button, state, task)); | 384 base::Bind(&ui_controls::ClickTask, button, state, task)); |
| 383 } | 385 } |
| 384 | 386 |
| 385 } // ui_controls | 387 } // ui_controls |
| OLD | NEW |