| 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 "ui/ui_controls/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 "ui/gfx/point.h" | 9 #include "ui/gfx/point.h" |
| 10 #include "ui/ui_controls/ui_controls_internal_win.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 namespace { |
| 16 ui::KeyboardCode key, | |
| 17 bool control, | |
| 18 bool shift, | |
| 19 bool alt, | |
| 20 bool command) { | |
| 21 DCHECK(!command); // No command key on Windows | |
| 22 return internal::SendKeyPressImpl(window, key, control, shift, alt, | |
| 23 base::Closure()); | |
| 24 } | |
| 25 | 16 |
| 26 bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window, | 17 class UIControlsWin : public UIControls { |
| 27 ui::KeyboardCode key, | 18 public: |
| 28 bool control, | 19 UIControlsWin() {} |
| 29 bool shift, | 20 virtual ~UIControlsWin() {} |
| 30 bool alt, | |
| 31 bool command, | |
| 32 const base::Closure& task) { | |
| 33 DCHECK(!command); // No command key on Windows | |
| 34 return internal::SendKeyPressImpl(window, key, control, shift, alt, task); | |
| 35 } | |
| 36 | 21 |
| 37 bool SendMouseMove(long x, long y) { | 22 bool SendKeyPress(gfx::NativeWindow window, |
| 38 return internal::SendMouseMoveImpl(x, y, base::Closure()); | 23 ui::KeyboardCode key, |
| 39 } | 24 bool control, |
| 25 bool shift, |
| 26 bool alt, |
| 27 bool command) OVERRIDE { |
| 28 DCHECK(!command); // No command key on Windows |
| 29 return internal::SendKeyPressImpl(window, key, control, shift, alt, |
| 30 base::Closure()); |
| 31 } |
| 40 | 32 |
| 41 bool SendMouseMoveNotifyWhenDone(long x, long y, const base::Closure& task) { | 33 bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window, |
| 42 return internal::SendMouseMoveImpl(x, y, task); | 34 ui::KeyboardCode key, |
| 43 } | 35 bool control, |
| 36 bool shift, |
| 37 bool alt, |
| 38 bool command, |
| 39 const base::Closure& task) OVERRIDE { |
| 40 DCHECK(!command); // No command key on Windows |
| 41 return internal::SendKeyPressImpl(window, key, control, shift, alt, task); |
| 42 } |
| 44 | 43 |
| 45 bool SendMouseEvents(MouseButton type, int state) { | 44 bool SendMouseMove(long x, long y) OVERRIDE { |
| 46 return internal::SendMouseEventsImpl(type, state, base::Closure()); | 45 return internal::SendMouseMoveImpl(x, y, base::Closure()); |
| 47 } | 46 } |
| 48 | 47 |
| 49 bool SendMouseEventsNotifyWhenDone(MouseButton type, int state, | 48 bool SendMouseMoveNotifyWhenDone( |
| 50 const base::Closure& task) { | 49 long x, long y, const base::Closure& task) OVERRIDE { |
| 51 return internal::SendMouseEventsImpl(type, state, task); | 50 return internal::SendMouseMoveImpl(x, y, task); |
| 52 } | 51 } |
| 53 | 52 |
| 54 bool SendMouseClick(MouseButton type) { | 53 bool SendMouseEvents(MouseButton type, int state) OVERRIDE { |
| 55 return internal::SendMouseEventsImpl(type, UP | DOWN, base::Closure()); | 54 return internal::SendMouseEventsImpl(type, state, base::Closure()); |
| 56 } | 55 } |
| 57 | 56 |
| 58 void RunClosureAfterAllPendingUIEvents(const base::Closure& closure) { | 57 bool SendMouseEventsNotifyWhenDone(MouseButton type, int state, |
| 59 // On windows, posting UI events is synchronous so just post the closure. | 58 const base::Closure& task) OVERRIDE { |
| 60 MessageLoopForUI::current()->PostTask(FROM_HERE, closure); | 59 return internal::SendMouseEventsImpl(type, state, task); |
| 60 } |
| 61 |
| 62 bool SendMouseClick(MouseButton type) OVERRIDE { |
| 63 return internal::SendMouseEventsImpl(type, UP | DOWN, base::Closure()); |
| 64 } |
| 65 |
| 66 void RunClosureAfterAllPendingUIEvents( |
| 67 const base::Closure& closure) OVERRIDE { |
| 68 // On windows, posting UI events is synchronous so just post the closure. |
| 69 MessageLoopForUI::current()->PostTask(FROM_HERE, closure); |
| 70 } |
| 71 |
| 72 private: |
| 73 DISALLOW_COPY_AND_ASSIGN(UIControlsWin); |
| 74 }; |
| 75 |
| 76 } // namespace |
| 77 |
| 78 UIControls* CreateNativeUIControls() { |
| 79 return new UIControlsWin; |
| 61 } | 80 } |
| 62 | 81 |
| 63 } // namespace ui_controls | 82 } // namespace ui_controls |
| OLD | NEW |