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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ui/ui_controls/ui_controls.h
diff --git a/ui/ui_controls/ui_controls.h b/ui/ui_controls/ui_controls.h
index 6bfebc842a239a990a30fc0826d747ee74c4a665..994ebdf60fe2a8a65fb87ea3dacb1888a8202c7f 100644
--- a/ui/ui_controls/ui_controls.h
+++ b/ui/ui_controls/ui_controls.h
@@ -13,8 +13,9 @@
#include "base/callback_forward.h"
#include "ui/base/keycodes/keyboard_codes.h"
-#include "ui/gfx/native_widget_types.h"
#include "ui/base/ui_export.h"
+#include "ui/gfx/native_widget_types.h"
+#include "ui/ui_controls/ui_controls_type_delegate.h"
namespace ui_controls {
@@ -37,6 +38,22 @@ namespace ui_controls {
//
// If you're writing a test chances are you want the variant in ui_test_utils.
// See it for details.
+
+enum MouseButton {
+ LEFT = 0,
+ MIDDLE,
+ RIGHT,
+};
+
+// Used to indicate the state of the button when generating events.
+enum MouseButtonState {
+ UP = 1,
+ DOWN = 2
+};
+
+// TRANSITION CODE: These global methods all forward to the native
+// implementation and are deprecated in favor of retrieving in the correct one
+// according to UIControlsType. http://crbug.com/128578
UI_EXPORT bool SendKeyPress(gfx::NativeWindow window,
ui::KeyboardCode key,
bool control,
@@ -56,27 +73,10 @@ UI_EXPORT bool SendMouseMove(long x, long y);
UI_EXPORT bool SendMouseMoveNotifyWhenDone(long x,
long y,
const base::Closure& task);
-
-enum MouseButton {
- LEFT = 0,
- MIDDLE,
- RIGHT,
-};
-
-// Used to indicate the state of the button when generating events.
-enum MouseButtonState {
- UP = 1,
- DOWN = 2
-};
-
-// Sends a mouse down and/or up message. The click will be sent to wherever
-// the cursor currently is, so be sure to move the cursor before calling this
-// (and be sure the cursor has arrived!).
UI_EXPORT bool SendMouseEvents(MouseButton type, int state);
UI_EXPORT bool SendMouseEventsNotifyWhenDone(
MouseButton type, int state,
const base::Closure& task);
-// Same as SendMouseEvents with UP | DOWN.
UI_EXPORT bool SendMouseClick(MouseButton type);
#if defined(TOOLKIT_VIEWS)
@@ -85,10 +85,90 @@ UI_EXPORT void RunClosureAfterAllPendingUIEvents(
const base::Closure& closure);
#endif
-#if defined(USE_AURA)
-class UIControlsAura;
-UI_EXPORT void InstallUIControlsAura(UIControlsAura* instance);
+// End of deprecated transition methods.
+
+class UI_EXPORT UIControls {
+ public:
+ UIControls();
+ virtual ~UIControls();
+
+ // Retrieves the UIControls instance that the specified NativeView is
+ // attached to. A Value of NULL is treated as |UI_CONTROLS_TYPE_NATIVE|.
+ static UIControls* GetUIControlsFor(gfx::NativeView view);
+
+ // Returns the UI_CONTROLS_TYPE_NATIVE UIControls. This should be used with
+ // caution, as it is likely to be incorrect for code that runs on Windows.
+ static UIControls* GetNativeUIControls();
+
+ // Sets the global UIControls instance for a particular type. Only
+ // the _NATIVE UIControlsType must be provided.
+ static void SetUIControlsInstance(UIControlsType type, UIControls* instance);
+
+ // Returns the global UIControls instance for particular type. Types other
+ // than _NATIVE may be NULL.
+ static UIControls* GetUIControlsByType(UIControlsType type);
+
+ // Sets the global UIControlsTypeDelegate. May be left unset if the platform
+ // only uses the _NATIVE UIControlsType.
+ static void SetUIControlsTypeDelegate(UIControlsTypeDelegate* delegate);
+
+ // Many of the functions in this class include a variant that takes a
+ // Closure. The version that takes a Closure waits until the generated event
+ // is processed. Once the generated event is processed the Closure is Run
+ // (and deleted). Note that this is a somewhat fragile process in that any
+ // event of the correct type (key down, mouse click, etc.) will trigger the
+ // Closure to be run. Hence a usage such as
+ //
+ // SendKeyPress(...);
+ // SendKeyPressNotifyWhenDone(..., task);
+ //
+ // might trigger |task| early.
+ //
+ // Note: Windows does not currently do anything with the |window| argument
+ // for these functions, so passing NULL is ok.
+
+ // Send a key press with/without modifier keys.
+ //
+ // If you're writing a test chances are you want the variant in ui_test_utils.
+ // See it for details.
+ virtual bool SendKeyPress(gfx::NativeWindow window,
+ ui::KeyboardCode key,
+ bool control,
+ bool shift,
+ bool alt,
+ bool command) = 0;
+ virtual bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window,
+ ui::KeyboardCode key,
+ bool control,
+ bool shift,
+ bool alt,
+ bool command,
+ const base::Closure& task) = 0;
+
+ // Simulate a mouse move. (x,y) are absolute screen coordinates.
+ virtual bool SendMouseMove(long x, long y) = 0;
+ virtual bool SendMouseMoveNotifyWhenDone(long x,
+ long y,
+ const base::Closure& task) = 0;
+
+ // Sends a mouse down and/or up message. The click will be sent to wherever
+ // the cursor currently is, so be sure to move the cursor before calling this
+ // (and be sure the cursor has arrived!).
+ virtual bool SendMouseEvents(MouseButton type, int state) = 0;
+ virtual bool SendMouseEventsNotifyWhenDone(
+ MouseButton type, int state,
+ const base::Closure& task) = 0;
+ // Same as SendMouseEvents with UP | DOWN.
+ virtual bool SendMouseClick(MouseButton type) = 0;
+
+#if defined(TOOLKIT_VIEWS)
+ // Runs |closure| after processing all pending ui events.
+ virtual void RunClosureAfterAllPendingUIEvents(
+ const base::Closure& closure) = 0;
#endif
+};
+
+UIControls* CreateNativeUIControls();
} // namespace ui_controls

Powered by Google App Engine
This is Rietveld 408576698