| OLD | NEW |
| 1 // Copyright (c) 2012 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/browser/automation/ui_controls.h" | 5 #include "ui/ui_controls/ui_controls.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "chrome/browser/automation/ui_controls_internal.h" | |
| 10 #include "ui/gfx/point.h" | 9 #include "ui/gfx/point.h" |
| 10 #include "ui/ui_controls/ui_controls_internal_win.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) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 48 | 48 |
| 49 bool SendMouseEventsNotifyWhenDone(MouseButton type, int state, | 49 bool SendMouseEventsNotifyWhenDone(MouseButton type, int state, |
| 50 const base::Closure& task) { | 50 const base::Closure& task) { |
| 51 return internal::SendMouseEventsImpl(type, state, task); | 51 return internal::SendMouseEventsImpl(type, state, task); |
| 52 } | 52 } |
| 53 | 53 |
| 54 bool SendMouseClick(MouseButton type) { | 54 bool SendMouseClick(MouseButton type) { |
| 55 return internal::SendMouseEventsImpl(type, UP | DOWN, base::Closure()); | 55 return internal::SendMouseEventsImpl(type, UP | DOWN, base::Closure()); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void MoveMouseToCenterAndPress(views::View* view, | |
| 59 MouseButton button, | |
| 60 int state, | |
| 61 const base::Closure& task) { | |
| 62 DCHECK(view); | |
| 63 DCHECK(view->GetWidget()); | |
| 64 gfx::Point view_center(view->width() / 2, view->height() / 2); | |
| 65 views::View::ConvertPointToScreen(view, &view_center); | |
| 66 SendMouseMove(view_center.x(), view_center.y()); | |
| 67 SendMouseEventsNotifyWhenDone(button, state, task); | |
| 68 } | |
| 69 | |
| 70 void RunClosureAfterAllPendingUIEvents(const base::Closure& closure) { | 58 void RunClosureAfterAllPendingUIEvents(const base::Closure& closure) { |
| 71 // On windows, posting UI events is synchronous so just post the closure. | 59 // On windows, posting UI events is synchronous so just post the closure. |
| 72 MessageLoopForUI::current()->PostTask(FROM_HERE, closure); | 60 MessageLoopForUI::current()->PostTask(FROM_HERE, closure); |
| 73 } | 61 } |
| 74 | 62 |
| 75 } // ui_controls | 63 } // namespace ui_controls |
| OLD | NEW |