Index: components/mus/input_devices/touchscreen_device_struct_traits.h |
diff --git a/components/mus/input_devices/touchscreen_device_struct_traits.h b/components/mus/input_devices/touchscreen_device_struct_traits.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b8e8cc13b58236f794962c94365a3c3e8fb45478 |
--- /dev/null |
+++ b/components/mus/input_devices/touchscreen_device_struct_traits.h |
@@ -0,0 +1,49 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef COMPONENTS_MUS_INPUT_DEVICES_TOUCHSCREEN_DEVICE_STRUCT_TRAITS_H_ |
+#define COMPONENTS_MUS_INPUT_DEVICES_TOUCHSCREEN_DEVICE_STRUCT_TRAITS_H_ |
+ |
+#include <string> |
+ |
+#include "base/strings/string_piece.h" |
+#include "components/mus/public/interfaces/input_devices/input_devices.mojom.h" |
+#include "ui/events/devices/touchscreen_device.h" |
+#include "ui/gfx/geometry/size.h" |
+ |
+namespace mojo { |
+ |
+template <> |
+struct StructTraits<input_device::mojom::TouchscreenDevice, |
+ ui::TouchscreenDevice> { |
+ static const ui::InputDevice& input_device( |
+ const ui::TouchscreenDevice& device) { |
+ return static_cast<const ui::InputDevice&>(device); |
+ } |
+ |
+ static gfx::Size size(const ui::TouchscreenDevice& device) { |
+ return device.size; |
+ } |
+ |
+ static int32_t touch_points(const ui::TouchscreenDevice& device) { |
+ return device.touch_points; |
+ } |
+ |
+ static bool Read(input_device::mojom::TouchscreenDeviceDataView data, |
+ ui::TouchscreenDevice* out) { |
+ if (!data.ReadInputDevice(static_cast<ui::InputDevice*>(out))) |
+ return false; |
+ |
+ if (!data.ReadSize(&out->size)) |
+ return false; |
+ |
+ out->touch_points = data.touch_points(); |
+ |
+ return true; |
+ } |
+}; |
+ |
+} // namespace mojo |
+ |
+#endif // COMPONENTS_MUS_INPUT_DEVICES_TOUCHSCREEN_DEVICE_STRUCT_TRAITS_H_ |