| 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..1887d361a20ff676f0a0bdd7738d9cf2829356fe
|
| --- /dev/null
|
| +++ b/ui/ui_controls/ui_controls.cc
|
| @@ -0,0 +1,116 @@
|
| +// 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);
|
| + delete g_ui_controls[type];
|
| + 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
|
|
|