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