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 "ui/events/ozone/device/udev/device_manager_udev.h" | 5 #include "ui/events/ozone/device/udev/device_manager_udev.h" |
6 | 6 |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
9 #include "ui/events/ozone/device/device_event.h" | 9 #include "ui/events/ozone/device/device_event.h" |
10 #include "ui/events/ozone/device/device_event_observer.h" | 10 #include "ui/events/ozone/device/device_event_observer.h" |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 const char* path = device::udev_device_get_devnode(device); | 155 const char* path = device::udev_device_get_devnode(device); |
156 const char* action = device::udev_device_get_action(device); | 156 const char* action = device::udev_device_get_action(device); |
157 const char* subsystem = | 157 const char* subsystem = |
158 device::udev_device_get_property_value(device, "SUBSYSTEM"); | 158 device::udev_device_get_property_value(device, "SUBSYSTEM"); |
159 | 159 |
160 if (!path || !subsystem) | 160 if (!path || !subsystem) |
161 return nullptr; | 161 return nullptr; |
162 | 162 |
163 DeviceEvent::DeviceType device_type; | 163 DeviceEvent::DeviceType device_type; |
164 if (!strcmp(subsystem, "input") && | 164 if (!strcmp(subsystem, "input") && |
165 base::StartsWithASCII(path, "/dev/input/event", true)) | 165 StartsWithASCII(path, "/dev/input/event", true)) |
166 device_type = DeviceEvent::INPUT; | 166 device_type = DeviceEvent::INPUT; |
167 else if (!strcmp(subsystem, "drm") && | 167 else if (!strcmp(subsystem, "drm") && |
168 base::StartsWithASCII(path, "/dev/dri/card", true)) | 168 StartsWithASCII(path, "/dev/dri/card", true)) |
169 device_type = DeviceEvent::DISPLAY; | 169 device_type = DeviceEvent::DISPLAY; |
170 else | 170 else |
171 return nullptr; | 171 return nullptr; |
172 | 172 |
173 DeviceEvent::ActionType action_type; | 173 DeviceEvent::ActionType action_type; |
174 if (!action || !strcmp(action, "add")) | 174 if (!action || !strcmp(action, "add")) |
175 action_type = DeviceEvent::ADD; | 175 action_type = DeviceEvent::ADD; |
176 else if (!strcmp(action, "remove")) | 176 else if (!strcmp(action, "remove")) |
177 action_type = DeviceEvent::REMOVE; | 177 action_type = DeviceEvent::REMOVE; |
178 else if (!strcmp(action, "change")) | 178 else if (!strcmp(action, "change")) |
179 action_type = DeviceEvent::CHANGE; | 179 action_type = DeviceEvent::CHANGE; |
180 else | 180 else |
181 return nullptr; | 181 return nullptr; |
182 | 182 |
183 return make_scoped_ptr( | 183 return make_scoped_ptr( |
184 new DeviceEvent(device_type, action_type, base::FilePath(path))); | 184 new DeviceEvent(device_type, action_type, base::FilePath(path))); |
185 } | 185 } |
186 | 186 |
187 } // namespace ui | 187 } // namespace ui |
OLD | NEW |