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

Side by Side Diff: ui/events/devices/device_util_linux.cc

Issue 1242023005: Remove legacy StartsWithASCII function. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: y Created 5 years, 5 months 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 unified diff | Download patch
« no previous file with comments | « ui/base/x/x11_util.cc ('k') | ui/events/ozone/device/udev/device_manager_udev.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/devices/device_util_linux.h" 5 #include "ui/events/devices/device_util_linux.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/files/file_enumerator.h" 9 #include "base/files/file_enumerator.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 14
15 namespace ui { 15 namespace ui {
16 16
17 InputDeviceType GetInputDeviceTypeFromPath(const base::FilePath& path) { 17 InputDeviceType GetInputDeviceTypeFromPath(const base::FilePath& path) {
18 DCHECK(!base::MessageLoopForUI::IsCurrent()); 18 DCHECK(!base::MessageLoopForUI::IsCurrent());
19 std::string event_node = path.BaseName().value(); 19 std::string event_node = path.BaseName().value();
20 if (event_node.empty() || !base::StartsWithASCII(event_node, "event", false)) 20 if (event_node.empty() ||
21 !base::StartsWith(event_node, "event",
22 base::CompareCase::INSENSITIVE_ASCII))
21 return InputDeviceType::INPUT_DEVICE_UNKNOWN; 23 return InputDeviceType::INPUT_DEVICE_UNKNOWN;
22 24
23 // Find sysfs device path for this device. 25 // Find sysfs device path for this device.
24 base::FilePath sysfs_path = 26 base::FilePath sysfs_path =
25 base::FilePath(FILE_PATH_LITERAL("/sys/class/input")); 27 base::FilePath(FILE_PATH_LITERAL("/sys/class/input"));
26 sysfs_path = sysfs_path.Append(path.BaseName()); 28 sysfs_path = sysfs_path.Append(path.BaseName());
27 sysfs_path = base::MakeAbsoluteFilePath(sysfs_path); 29 sysfs_path = base::MakeAbsoluteFilePath(sysfs_path);
28 30
29 // Device does not exist. 31 // Device does not exist.
30 if (sysfs_path.empty()) 32 if (sysfs_path.empty())
(...skipping 29 matching lines...) Expand all
60 if (subsystem_path == "/sys/bus/usb") 62 if (subsystem_path == "/sys/bus/usb")
61 return InputDeviceType::INPUT_DEVICE_EXTERNAL; 63 return InputDeviceType::INPUT_DEVICE_EXTERNAL;
62 if (subsystem_path == "/sys/class/bluetooth") 64 if (subsystem_path == "/sys/class/bluetooth")
63 return InputDeviceType::INPUT_DEVICE_EXTERNAL; 65 return InputDeviceType::INPUT_DEVICE_EXTERNAL;
64 } 66 }
65 67
66 return InputDeviceType::INPUT_DEVICE_UNKNOWN; 68 return InputDeviceType::INPUT_DEVICE_UNKNOWN;
67 } 69 }
68 70
69 } // namespace 71 } // namespace
OLDNEW
« no previous file with comments | « ui/base/x/x11_util.cc ('k') | ui/events/ozone/device/udev/device_manager_udev.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698