| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/chromeos/system/input_device_settings.h" | 5 #include "chrome/browser/chromeos/system/input_device_settings.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
| 17 #include "base/process/kill.h" | 17 #include "base/process/kill.h" |
| 18 #include "base/process/launch.h" | 18 #include "base/process/launch.h" |
| 19 #include "base/process/process_handle.h" | 19 #include "base/process/process_handle.h" |
| 20 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
| 21 #include "base/strings/stringprintf.h" | 21 #include "base/strings/stringprintf.h" |
| 22 #include "base/sys_info.h" | 22 #include "base/sys_info.h" |
| 23 #include "base/task_runner.h" | 23 #include "base/task_runner.h" |
| 24 #include "base/threading/sequenced_worker_pool.h" | 24 #include "base/threading/sequenced_worker_pool.h" |
| 25 #include "chrome/browser/chromeos/system/fake_input_device_settings.h" |
| 25 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
| 26 #include "ui/events/base_event_utils.h" | 27 #include "ui/events/base_event_utils.h" |
| 27 #include "ui/events/devices/x11/device_data_manager_x11.h" | 28 #include "ui/events/devices/x11/device_data_manager_x11.h" |
| 28 #include "ui/events/devices/x11/device_list_cache_x11.h" | 29 #include "ui/events/devices/x11/device_list_cache_x11.h" |
| 29 #include "ui/events/devices/x11/touch_factory_x11.h" | 30 #include "ui/events/devices/x11/touch_factory_x11.h" |
| 30 #include "ui/gfx/x/x11_types.h" | 31 #include "ui/gfx/x/x11_types.h" |
| 31 | 32 |
| 32 namespace chromeos { | 33 namespace chromeos { |
| 33 namespace system { | 34 namespace system { |
| 34 | 35 |
| 35 namespace { | 36 namespace { |
| 36 | 37 |
| 37 InputDeviceSettings* g_instance = nullptr; | 38 InputDeviceSettings* g_instance = nullptr; |
| 38 InputDeviceSettings* g_test_instance = nullptr; | 39 FakeInputDeviceSettings* g_test_instance = nullptr; |
| 39 | 40 |
| 40 const char kDeviceTypeTouchpad[] = "touchpad"; | 41 const char kDeviceTypeTouchpad[] = "touchpad"; |
| 41 const char kDeviceTypeMouse[] = "mouse"; | 42 const char kDeviceTypeMouse[] = "mouse"; |
| 42 const char kInputControl[] = "/opt/google/input/inputcontrol"; | 43 const char kInputControl[] = "/opt/google/input/inputcontrol"; |
| 43 | 44 |
| 44 // The name of the xinput device corresponding to the internal touchpad. | 45 // The name of the xinput device corresponding to the internal touchpad. |
| 45 const char kInternalTouchpadName[] = "Elan Touchpad"; | 46 const char kInternalTouchpadName[] = "Elan Touchpad"; |
| 46 | 47 |
| 47 typedef base::RefCountedData<bool> RefCountedBool; | 48 typedef base::RefCountedData<bool> RefCountedBool; |
| 48 | 49 |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 // static | 344 // static |
| 344 InputDeviceSettings* InputDeviceSettings::Get() { | 345 InputDeviceSettings* InputDeviceSettings::Get() { |
| 345 if (g_test_instance) | 346 if (g_test_instance) |
| 346 return g_test_instance; | 347 return g_test_instance; |
| 347 if (!g_instance) | 348 if (!g_instance) |
| 348 g_instance = new InputDeviceSettingsImplX11; | 349 g_instance = new InputDeviceSettingsImplX11; |
| 349 return g_instance; | 350 return g_instance; |
| 350 } | 351 } |
| 351 | 352 |
| 352 // static | 353 // static |
| 354 FakeInputDeviceSettings* InputDeviceSettings::GetForTesting() { |
| 355 if (!g_test_instance) |
| 356 g_test_instance = new FakeInputDeviceSettings(); |
| 357 return g_test_instance; |
| 358 } |
| 359 |
| 360 // static |
| 353 void InputDeviceSettings::SetSettingsForTesting( | 361 void InputDeviceSettings::SetSettingsForTesting( |
| 354 InputDeviceSettings* test_settings) { | 362 FakeInputDeviceSettings* test_settings) { |
| 355 if (g_test_instance == test_settings) | 363 if (g_test_instance == test_settings) |
| 356 return; | 364 return; |
| 357 delete g_test_instance; | 365 delete g_test_instance; |
| 358 g_test_instance = test_settings; | 366 g_test_instance = test_settings; |
| 359 } | 367 } |
| 360 | 368 |
| 361 } // namespace system | 369 } // namespace system |
| 362 } // namespace chromeos | 370 } // namespace chromeos |
| OLD | NEW |