Index: ui/events/devices/input_device.cc |
diff --git a/ui/events/devices/input_device.cc b/ui/events/devices/input_device.cc |
index 4734edd0280986dc11f231b3a65394e6db004d4b..aeac8a5eaa01185f82c242d81dc994162d2d16e2 100644 |
--- a/ui/events/devices/input_device.cc |
+++ b/ui/events/devices/input_device.cc |
@@ -6,8 +6,26 @@ |
#include <string> |
+#include "base/strings/stringprintf.h" |
+ |
namespace ui { |
+namespace { |
+ |
+std::string InputDeviceTypeString(InputDeviceType type) { |
+#define ECASE(value) \ |
+ case value: \ |
+ return #value |
+ switch (type) { |
+ ECASE(INPUT_DEVICE_INTERNAL); |
+ ECASE(INPUT_DEVICE_EXTERNAL); |
+ ECASE(INPUT_DEVICE_UNKNOWN); |
+ } |
+#undef ECASE |
+} |
+ |
+} // namespace |
+ |
// static |
const int InputDevice::kInvalidId = 0; |
@@ -37,4 +55,9 @@ InputDevice::InputDevice(const InputDevice& other) = default; |
InputDevice::~InputDevice() { |
} |
+std::string InputDevice::ToString() const { |
+ return base::StringPrintf("InputDevice[id=%d, name=\"%s\", type=%s]", id, |
+ name.c_str(), InputDeviceTypeString(type).c_str()); |
+} |
+ |
} // namespace ui |