1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/events/ozone/evdev/input_device_factory_evdev_proxy.h"
8 #include "base/thread_task_runner_handle.h"
9 #include "ui/events/ozone/evdev/input_device_factory_evdev.h"
15 void ForwardGetTouchDeviceStatusReply(
16 scoped_refptr
<base::SingleThreadTaskRunner
> reply_runner
,
17 const GetTouchDeviceStatusReply
& reply
,
18 scoped_ptr
<std::string
> status
) {
19 // Thread hop back to UI for reply.
20 reply_runner
->PostTask(FROM_HERE
, base::Bind(reply
, base::Passed(&status
)));
23 void ForwardGetTouchEventLogReply(
24 scoped_refptr
<base::SingleThreadTaskRunner
> reply_runner
,
25 const GetTouchEventLogReply
& reply
,
26 scoped_ptr
<std::vector
<base::FilePath
>> log_paths
) {
27 // Thread hop back to UI for reply.
28 reply_runner
->PostTask(FROM_HERE
,
29 base::Bind(reply
, base::Passed(&log_paths
)));
34 InputDeviceFactoryEvdevProxy::InputDeviceFactoryEvdevProxy(
35 scoped_refptr
<base::SingleThreadTaskRunner
> task_runner
,
36 base::WeakPtr
<InputDeviceFactoryEvdev
> input_device_factory
)
37 : task_runner_(task_runner
), input_device_factory_(input_device_factory
) {
40 InputDeviceFactoryEvdevProxy::~InputDeviceFactoryEvdevProxy() {
43 void InputDeviceFactoryEvdevProxy::AddInputDevice(int id
,
44 const base::FilePath
& path
) {
45 task_runner_
->PostTask(FROM_HERE
,
46 base::Bind(&InputDeviceFactoryEvdev::AddInputDevice
,
47 input_device_factory_
, id
, path
));
50 void InputDeviceFactoryEvdevProxy::RemoveInputDevice(
51 const base::FilePath
& path
) {
52 task_runner_
->PostTask(FROM_HERE
,
53 base::Bind(&InputDeviceFactoryEvdev::RemoveInputDevice
,
54 input_device_factory_
, path
));
57 void InputDeviceFactoryEvdevProxy::DisableInternalTouchpad() {
58 task_runner_
->PostTask(
59 FROM_HERE
, base::Bind(&InputDeviceFactoryEvdev::DisableInternalTouchpad
,
60 input_device_factory_
));
63 void InputDeviceFactoryEvdevProxy::EnableInternalTouchpad() {
64 task_runner_
->PostTask(
65 FROM_HERE
, base::Bind(&InputDeviceFactoryEvdev::EnableInternalTouchpad
,
66 input_device_factory_
));
69 void InputDeviceFactoryEvdevProxy::DisableInternalKeyboardExceptKeys(
70 scoped_ptr
<std::set
<DomCode
>> excepted_keys
) {
71 task_runner_
->PostTask(
73 base::Bind(&InputDeviceFactoryEvdev::DisableInternalKeyboardExceptKeys
,
74 input_device_factory_
, base::Passed(&excepted_keys
)));
77 void InputDeviceFactoryEvdevProxy::EnableInternalKeyboard() {
78 task_runner_
->PostTask(
79 FROM_HERE
, base::Bind(&InputDeviceFactoryEvdev::EnableInternalKeyboard
,
80 input_device_factory_
));
83 void InputDeviceFactoryEvdevProxy::SetCapsLockLed(bool enabled
) {
84 task_runner_
->PostTask(FROM_HERE
,
85 base::Bind(&InputDeviceFactoryEvdev::SetCapsLockLed
,
86 input_device_factory_
, enabled
));
89 void InputDeviceFactoryEvdevProxy::UpdateInputDeviceSettings(
90 const InputDeviceSettingsEvdev
& settings
) {
91 task_runner_
->PostTask(
92 FROM_HERE
, base::Bind(&InputDeviceFactoryEvdev::UpdateInputDeviceSettings
,
93 input_device_factory_
, settings
));
96 void InputDeviceFactoryEvdevProxy::GetTouchDeviceStatus(
97 const GetTouchDeviceStatusReply
& reply
) {
98 task_runner_
->PostTask(
100 base::Bind(&InputDeviceFactoryEvdev::GetTouchDeviceStatus
,
101 input_device_factory_
,
102 base::Bind(&ForwardGetTouchDeviceStatusReply
,
103 base::ThreadTaskRunnerHandle::Get(), reply
)));
106 void InputDeviceFactoryEvdevProxy::GetTouchEventLog(
107 const base::FilePath
& out_dir
,
108 const GetTouchEventLogReply
& reply
) {
109 task_runner_
->PostTask(
111 base::Bind(&InputDeviceFactoryEvdev::GetTouchEventLog
,
112 input_device_factory_
, out_dir
,
113 base::Bind(&ForwardGetTouchEventLogReply
,
114 base::ThreadTaskRunnerHandle::Get(), reply
)));