Chromium Code Reviews| 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/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/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 | 12 |
| 13 namespace ui { | 13 namespace ui { |
| 14 | 14 |
| 15 // We consider the touchscreen to be internal if it is an I2c device. We search | |
| 16 // all the dev input nodes registered by I2C devices to see if we can find | |
| 17 // eventXXX. | |
| 15 bool IsTouchscreenInternal(const base::FilePath& path) { | 18 bool IsTouchscreenInternal(const base::FilePath& path) { |
| 16 std::string event_node = path.BaseName().value(); | 19 std::string event_node = path.BaseName().value(); |
|
sadrul
2014/11/06 21:05:27
Can you add CHECK_NE(TYPE_UI, MessageLoop::current
dnicoara
2014/11/10 19:34:51
Worker threads don't have a message loop. Is there
sadrul
2014/11/11 18:29:51
Perhaps CHECK(!MessageLoopForUI::IsCurrent())?
| |
| 17 if (event_node.empty() || !StartsWithASCII(event_node, "event", false)) | 20 if (event_node.empty() || !StartsWithASCII(event_node, "event", false)) |
| 18 return false; | 21 return false; |
| 19 | 22 |
| 20 // Extract id "XXX" from "eventXXX" | 23 // Extract id "XXX" from "eventXXX" |
| 21 std::string event_node_id = event_node.substr(5); | 24 std::string event_node_id = event_node.substr(5); |
| 22 | 25 |
| 23 // I2C input device registers its dev input node at | 26 // I2C input device registers its dev input node at |
| 24 // /sys/bus/i2c/devices/*/input/inputXXX/eventXXX | 27 // /sys/bus/i2c/devices/*/input/inputXXX/eventXXX |
| 25 base::FileEnumerator i2c_enum( | 28 base::FileEnumerator i2c_enum( |
| 26 base::FilePath(FILE_PATH_LITERAL("/sys/bus/i2c/devices/")), | 29 base::FilePath(FILE_PATH_LITERAL("/sys/bus/i2c/devices/")), |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 37 input = input_enum.Next()) { | 40 input = input_enum.Next()) { |
| 38 if (input.BaseName().value().substr(5) == event_node_id) | 41 if (input.BaseName().value().substr(5) == event_node_id) |
| 39 return true; | 42 return true; |
| 40 } | 43 } |
| 41 } | 44 } |
| 42 | 45 |
| 43 return false; | 46 return false; |
| 44 } | 47 } |
| 45 | 48 |
| 46 } // namespace | 49 } // namespace |
| OLD | NEW |