Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: ui/ui_controls/ui_controls.h

Issue 11419013: Add desktop vs. ash context to ui_controls Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: mac typo Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #ifndef UI_UI_CONTROLS_UI_CONTROLS_H_ 5 #ifndef UI_UI_CONTROLS_UI_CONTROLS_H_
6 #define UI_UI_CONTROLS_UI_CONTROLS_H_ 6 #define UI_UI_CONTROLS_UI_CONTROLS_H_
7 7
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 9
10 #if defined(OS_WIN) 10 #if defined(OS_WIN)
11 #include <wtypes.h> 11 #include <wtypes.h>
12 #endif 12 #endif
13 13
14 #include "base/callback_forward.h" 14 #include "base/callback_forward.h"
15 #include "ui/base/keycodes/keyboard_codes.h" 15 #include "ui/base/keycodes/keyboard_codes.h"
16 #include "ui/base/ui_export.h"
16 #include "ui/gfx/native_widget_types.h" 17 #include "ui/gfx/native_widget_types.h"
17 #include "ui/base/ui_export.h" 18 #include "ui/ui_controls/ui_controls_type_delegate.h"
18 19
19 namespace ui_controls { 20 namespace ui_controls {
20 21
21 // Many of the functions in this class include a variant that takes a Closure. 22 // Many of the functions in this class include a variant that takes a Closure.
22 // The version that takes a Closure waits until the generated event is 23 // The version that takes a Closure waits until the generated event is
23 // processed. Once the generated event is processed the Closure is Run (and 24 // processed. Once the generated event is processed the Closure is Run (and
24 // deleted). Note that this is a somewhat fragile process in that any event of 25 // deleted). Note that this is a somewhat fragile process in that any event of
25 // the correct type (key down, mouse click, etc.) will trigger the Closure to be 26 // the correct type (key down, mouse click, etc.) will trigger the Closure to be
26 // run. Hence a usage such as 27 // run. Hence a usage such as
27 // 28 //
28 // SendKeyPress(...); 29 // SendKeyPress(...);
29 // SendKeyPressNotifyWhenDone(..., task); 30 // SendKeyPressNotifyWhenDone(..., task);
30 // 31 //
31 // might trigger |task| early. 32 // might trigger |task| early.
32 // 33 //
33 // Note: Windows does not currently do anything with the |window| argument for 34 // Note: Windows does not currently do anything with the |window| argument for
34 // these functions, so passing NULL is ok. 35 // these functions, so passing NULL is ok.
35 36
36 // Send a key press with/without modifier keys. 37 // Send a key press with/without modifier keys.
37 // 38 //
38 // If you're writing a test chances are you want the variant in ui_test_utils. 39 // If you're writing a test chances are you want the variant in ui_test_utils.
39 // See it for details. 40 // See it for details.
41
42 enum MouseButton {
43 LEFT = 0,
44 MIDDLE,
45 RIGHT,
46 };
47
48 // Used to indicate the state of the button when generating events.
49 enum MouseButtonState {
50 UP = 1,
51 DOWN = 2
52 };
53
54 // TRANSITION CODE: These global methods all forward to the native
55 // implementation and are deprecated in favor of retrieving in the correct one
56 // according to UIControlsType. http://crbug.com/128578
40 UI_EXPORT bool SendKeyPress(gfx::NativeWindow window, 57 UI_EXPORT bool SendKeyPress(gfx::NativeWindow window,
41 ui::KeyboardCode key, 58 ui::KeyboardCode key,
42 bool control, 59 bool control,
43 bool shift, 60 bool shift,
44 bool alt, 61 bool alt,
45 bool command); 62 bool command);
46 UI_EXPORT bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window, 63 UI_EXPORT bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window,
47 ui::KeyboardCode key, 64 ui::KeyboardCode key,
48 bool control, 65 bool control,
49 bool shift, 66 bool shift,
50 bool alt, 67 bool alt,
51 bool command, 68 bool command,
52 const base::Closure& task); 69 const base::Closure& task);
53 70
54 // Simulate a mouse move. (x,y) are absolute screen coordinates. 71 // Simulate a mouse move. (x,y) are absolute screen coordinates.
55 UI_EXPORT bool SendMouseMove(long x, long y); 72 UI_EXPORT bool SendMouseMove(long x, long y);
56 UI_EXPORT bool SendMouseMoveNotifyWhenDone(long x, 73 UI_EXPORT bool SendMouseMoveNotifyWhenDone(long x,
57 long y, 74 long y,
58 const base::Closure& task); 75 const base::Closure& task);
59
60 enum MouseButton {
61 LEFT = 0,
62 MIDDLE,
63 RIGHT,
64 };
65
66 // Used to indicate the state of the button when generating events.
67 enum MouseButtonState {
68 UP = 1,
69 DOWN = 2
70 };
71
72 // Sends a mouse down and/or up message. The click will be sent to wherever
73 // the cursor currently is, so be sure to move the cursor before calling this
74 // (and be sure the cursor has arrived!).
75 UI_EXPORT bool SendMouseEvents(MouseButton type, int state); 76 UI_EXPORT bool SendMouseEvents(MouseButton type, int state);
76 UI_EXPORT bool SendMouseEventsNotifyWhenDone( 77 UI_EXPORT bool SendMouseEventsNotifyWhenDone(
77 MouseButton type, int state, 78 MouseButton type, int state,
78 const base::Closure& task); 79 const base::Closure& task);
79 // Same as SendMouseEvents with UP | DOWN.
80 UI_EXPORT bool SendMouseClick(MouseButton type); 80 UI_EXPORT bool SendMouseClick(MouseButton type);
81 81
82 #if defined(TOOLKIT_VIEWS) 82 #if defined(TOOLKIT_VIEWS)
83 // Runs |closure| after processing all pending ui events. 83 // Runs |closure| after processing all pending ui events.
84 UI_EXPORT void RunClosureAfterAllPendingUIEvents( 84 UI_EXPORT void RunClosureAfterAllPendingUIEvents(
85 const base::Closure& closure); 85 const base::Closure& closure);
86 #endif 86 #endif
87 87
88 #if defined(USE_AURA) 88 // End of deprecated transition methods.
89 class UIControlsAura; 89
90 UI_EXPORT void InstallUIControlsAura(UIControlsAura* instance); 90 class UI_EXPORT UIControls {
91 public:
92 UIControls();
93 virtual ~UIControls();
94
95 // Retrieves the UIControls instance that the specified NativeView is
96 // attached to. A Value of NULL is treated as |UI_CONTROLS_TYPE_NATIVE|.
97 static UIControls* GetUIControlsFor(gfx::NativeView view);
98
99 // Returns the UI_CONTROLS_TYPE_NATIVE UIControls. This should be used with
100 // caution, as it is likely to be incorrect for code that runs on Windows.
101 static UIControls* GetNativeUIControls();
102
103 // Sets the global UIControls instance for a particular type. Only
104 // the _NATIVE UIControlsType must be provided.
105 static void SetUIControlsInstance(UIControlsType type, UIControls* instance);
106
107 // Returns the global UIControls instance for particular type. Types other
108 // than _NATIVE may be NULL.
109 static UIControls* GetUIControlsByType(UIControlsType type);
110
111 // Sets the global UIControlsTypeDelegate. May be left unset if the platform
112 // only uses the _NATIVE UIControlsType.
113 static void SetUIControlsTypeDelegate(UIControlsTypeDelegate* delegate);
114
115 // Many of the functions in this class include a variant that takes a
116 // Closure. The version that takes a Closure waits until the generated event
117 // is processed. Once the generated event is processed the Closure is Run
118 // (and deleted). Note that this is a somewhat fragile process in that any
119 // event of the correct type (key down, mouse click, etc.) will trigger the
120 // Closure to be run. Hence a usage such as
121 //
122 // SendKeyPress(...);
123 // SendKeyPressNotifyWhenDone(..., task);
124 //
125 // might trigger |task| early.
126 //
127 // Note: Windows does not currently do anything with the |window| argument
128 // for these functions, so passing NULL is ok.
129
130 // Send a key press with/without modifier keys.
131 //
132 // If you're writing a test chances are you want the variant in ui_test_utils.
133 // See it for details.
134 virtual bool SendKeyPress(gfx::NativeWindow window,
135 ui::KeyboardCode key,
136 bool control,
137 bool shift,
138 bool alt,
139 bool command) = 0;
140 virtual bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window,
141 ui::KeyboardCode key,
142 bool control,
143 bool shift,
144 bool alt,
145 bool command,
146 const base::Closure& task) = 0;
147
148 // Simulate a mouse move. (x,y) are absolute screen coordinates.
149 virtual bool SendMouseMove(long x, long y) = 0;
150 virtual bool SendMouseMoveNotifyWhenDone(long x,
151 long y,
152 const base::Closure& task) = 0;
153
154 // Sends a mouse down and/or up message. The click will be sent to wherever
155 // the cursor currently is, so be sure to move the cursor before calling this
156 // (and be sure the cursor has arrived!).
157 virtual bool SendMouseEvents(MouseButton type, int state) = 0;
158 virtual bool SendMouseEventsNotifyWhenDone(
159 MouseButton type, int state,
160 const base::Closure& task) = 0;
161 // Same as SendMouseEvents with UP | DOWN.
162 virtual bool SendMouseClick(MouseButton type) = 0;
163
164 #if defined(TOOLKIT_VIEWS)
165 // Runs |closure| after processing all pending ui events.
166 virtual void RunClosureAfterAllPendingUIEvents(
167 const base::Closure& closure) = 0;
91 #endif 168 #endif
169 };
170
171 UIControls* CreateNativeUIControls();
92 172
93 } // namespace ui_controls 173 } // namespace ui_controls
94 174
95 #endif // UI_UI_CONTROLS_UI_CONTROLS_H_ 175 #endif // UI_UI_CONTROLS_UI_CONTROLS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698