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 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "chrome/browser/automation/ui_controls_internal.h" | 9 #include "chrome/browser/automation/ui_controls_internal.h" |
10 #include "ui/aura/desktop.h" | 10 #include "ui/aura/root_window.h" |
11 #include "ui/views/view.h" | 11 #include "ui/views/view.h" |
12 | 12 |
13 namespace ui_controls { | 13 namespace ui_controls { |
14 | 14 |
15 bool SendKeyPress(gfx::NativeWindow window, | 15 bool SendKeyPress(gfx::NativeWindow window, |
16 ui::KeyboardCode key, | 16 ui::KeyboardCode key, |
17 bool control, | 17 bool control, |
18 bool shift, | 18 bool shift, |
19 bool alt, | 19 bool alt, |
20 bool command) { | 20 bool command) { |
21 DCHECK(!command); // No command key on Aura | 21 DCHECK(!command); // No command key on Aura |
22 return internal::SendKeyPressImpl(key, control, shift, alt, base::Closure()); | 22 return internal::SendKeyPressImpl(key, control, shift, alt, base::Closure()); |
23 } | 23 } |
24 | 24 |
25 bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window, | 25 bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window, |
26 ui::KeyboardCode key, | 26 ui::KeyboardCode key, |
27 bool control, | 27 bool control, |
28 bool shift, | 28 bool shift, |
29 bool alt, | 29 bool alt, |
30 bool command, | 30 bool command, |
31 const base::Closure& task) { | 31 const base::Closure& task) { |
32 DCHECK(!command); // No command key on Aura | 32 DCHECK(!command); // No command key on Aura |
33 return internal::SendKeyPressImpl(key, control, shift, alt, task); | 33 return internal::SendKeyPressImpl(key, control, shift, alt, task); |
34 } | 34 } |
35 | 35 |
36 bool SendMouseMove(long x, long y) { | 36 bool SendMouseMove(long x, long y) { |
37 gfx::Point point(x, y); | 37 gfx::Point point(x, y); |
38 aura::Desktop::GetInstance()->ConvertPointToNativeScreen(&point); | 38 aura::RootWindow::GetInstance()->ConvertPointToNativeScreen(&point); |
39 return internal::SendMouseMoveImpl(point.x(), point.y(), base::Closure()); | 39 return internal::SendMouseMoveImpl(point.x(), point.y(), base::Closure()); |
40 } | 40 } |
41 | 41 |
42 bool SendMouseMoveNotifyWhenDone(long x, long y, const base::Closure& task) { | 42 bool SendMouseMoveNotifyWhenDone(long x, long y, const base::Closure& task) { |
43 gfx::Point point(x, y); | 43 gfx::Point point(x, y); |
44 aura::Desktop::GetInstance()->ConvertPointToNativeScreen(&point); | 44 aura::RootWindow::GetInstance()->ConvertPointToNativeScreen(&point); |
45 return internal::SendMouseMoveImpl(point.x(), point.y(), task); | 45 return internal::SendMouseMoveImpl(point.x(), point.y(), task); |
46 } | 46 } |
47 | 47 |
48 bool SendMouseEvents(MouseButton type, int state) { | 48 bool SendMouseEvents(MouseButton type, int state) { |
49 return internal::SendMouseEventsImpl(type, state, base::Closure()); | 49 return internal::SendMouseEventsImpl(type, state, base::Closure()); |
50 } | 50 } |
51 | 51 |
52 bool SendMouseEventsNotifyWhenDone(MouseButton type, int state, | 52 bool SendMouseEventsNotifyWhenDone(MouseButton type, int state, |
53 const base::Closure& task) { | 53 const base::Closure& task) { |
54 return internal::SendMouseEventsImpl(type, state, task); | 54 return internal::SendMouseEventsImpl(type, state, task); |
(...skipping 14 matching lines...) Expand all Loading... |
69 SendMouseMove(view_center.x(), view_center.y()); | 69 SendMouseMove(view_center.x(), view_center.y()); |
70 SendMouseEventsNotifyWhenDone(button, state, task); | 70 SendMouseEventsNotifyWhenDone(button, state, task); |
71 } | 71 } |
72 | 72 |
73 void RunClosureAfterAllPendingUIEvents(const base::Closure& task) { | 73 void RunClosureAfterAllPendingUIEvents(const base::Closure& task) { |
74 // On windows, posting UI events is synchronous so just post the closure. | 74 // On windows, posting UI events is synchronous so just post the closure. |
75 MessageLoopForUI::current()->PostTask(FROM_HERE, task); | 75 MessageLoopForUI::current()->PostTask(FROM_HERE, task); |
76 } | 76 } |
77 | 77 |
78 } // namespace ui_controls | 78 } // namespace ui_controls |
OLD | NEW |