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

Unified Diff: ui/ui_controls/ui_controls.cc

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.cc
diff --git a/ui/ui_controls/ui_controls.cc b/ui/ui_controls/ui_controls.cc
new file mode 100644
index 0000000000000000000000000000000000000000..90141a74941676bcac1e4d249d0cc2ea36a295a3
--- /dev/null
+++ b/ui/ui_controls/ui_controls.cc
@@ -0,0 +1,115 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/ui_controls/ui_controls.h"
+
+#include "base/logging.h"
+
+namespace ui_controls {
+
+namespace {
+
+UIControls* g_ui_controls[UI_CONTROLS_TYPE_LAST + 1] = { 0 };
+UIControlsTypeDelegate* g_ui_controls_type_delegate = NULL;
+
+} // namespace
+
+UIControls::UIControls() {
+}
+
+UIControls::~UIControls() {
+}
+
+// static
+UIControls* UIControls::GetUIControlsFor(gfx::NativeView view) {
+ UIControlsType type = UI_CONTROLS_TYPE_NATIVE;
+ if (g_ui_controls_type_delegate)
+ type = g_ui_controls_type_delegate->GetUIControlsTypeForNativeView(view);
+ if (type == UI_CONTROLS_TYPE_NATIVE)
+ return GetNativeUIControls();
+ DCHECK(g_ui_controls[type]);
+ return g_ui_controls[type];
+}
+
+// static
+void UIControls::SetUIControlsInstance(
+ UIControlsType type, UIControls* instance) {
+ DCHECK_LE(type, UI_CONTROLS_TYPE_LAST);
oshima 2012/11/16 20:41:39 I was thinking about delete g_ui_controls[type];
scottmg 2012/11/16 22:34:06 Done.
+ g_ui_controls[type] = instance;
+}
+
+// static
+UIControls* UIControls::GetUIControlsByType(UIControlsType type) {
+ return g_ui_controls[type];
+}
+
+// static
+void UIControls::SetUIControlsTypeDelegate(UIControlsTypeDelegate* delegate) {
+ g_ui_controls_type_delegate = delegate;
+}
+
+// static
+UIControls* UIControls::GetNativeUIControls() {
+ if (!g_ui_controls[UI_CONTROLS_TYPE_NATIVE])
+ g_ui_controls[UI_CONTROLS_TYPE_NATIVE] = CreateNativeUIControls();
+ return g_ui_controls[UI_CONTROLS_TYPE_NATIVE];
+}
+
+
+// ALL OF THESE ARE DEPRECATED, SEE HEADER. http://crbug.com/128578
+bool SendKeyPress(gfx::NativeWindow window,
+ ui::KeyboardCode key,
+ bool control,
+ bool shift,
+ bool alt,
+ bool command) {
+ return UIControls::GetNativeUIControls()->SendKeyPress(
+ window, key, control, shift, alt, command);
+}
+
+bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window,
+ ui::KeyboardCode key,
+ bool control,
+ bool shift,
+ bool alt,
+ bool command,
+ const base::Closure& task) {
+ return UIControls::GetNativeUIControls()->SendKeyPressNotifyWhenDone(
+ window, key, control, shift, alt, command, task);
+}
+
+bool SendMouseMove(long x, long y) {
+ return UIControls::GetNativeUIControls()->SendMouseMove(x, y);
+}
+
+bool SendMouseMoveNotifyWhenDone(long x,
+ long y,
+ const base::Closure& task) {
+ return UIControls::GetNativeUIControls()->SendMouseMoveNotifyWhenDone(
+ x, y, task);
+}
+
+bool SendMouseEvents(MouseButton type, int state) {
+ return UIControls::GetNativeUIControls()->SendMouseEvents(type, state);
+}
+
+bool SendMouseEventsNotifyWhenDone(
+ MouseButton type, int state,
+ const base::Closure& task) {
+ return UIControls::GetNativeUIControls()->SendMouseEventsNotifyWhenDone(
+ type, state, task);
+}
+
+bool SendMouseClick(MouseButton type) {
+ return UIControls::GetNativeUIControls()->SendMouseClick(type);
+}
+
+#if defined(TOOLKIT_VIEWS)
+UI_EXPORT void RunClosureAfterAllPendingUIEvents(const base::Closure& closure) {
+ return UIControls::GetNativeUIControls()->RunClosureAfterAllPendingUIEvents(
+ closure);
+}
+#endif
+
+} // namespace ui_controls

Powered by Google App Engine
This is Rietveld 408576698