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