| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "blimp/net/input_message_generator.h" | 5 #include "blimp/net/input_message_generator.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "blimp/common/create_blimp_message.h" | 8 #include "blimp/common/create_blimp_message.h" |
| 9 #include "blimp/common/proto/blimp_message.pb.h" | 9 #include "blimp/common/proto/blimp_message.pb.h" |
| 10 #include "blimp/common/proto/input.pb.h" | 10 #include "blimp/common/proto/input.pb.h" |
| 11 #include "blimp/net/blimp_message_processor.h" | 11 #include "blimp/net/blimp_message_processor.h" |
| 12 #include "third_party/WebKit/public/platform/WebGestureDevice.h" | 12 #include "third_party/WebKit/public/platform/WebGestureDevice.h" |
| 13 #include "third_party/WebKit/public/platform/WebGestureEvent.h" | 13 #include "third_party/WebKit/public/platform/WebGestureEvent.h" |
| 14 | 14 |
| 15 namespace blimp { | 15 namespace blimp { |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 void CommonWebGestureToProto(const blink::WebGestureEvent& event, | 18 void CommonWebGestureToProto(const blink::WebGestureEvent& event, |
| 19 InputMessage::Type type, | 19 InputMessage::Type type, |
| 20 InputMessage* proto) { | 20 InputMessage* proto) { |
| 21 proto->set_type(type); | 21 proto->set_type(type); |
| 22 proto->set_timestamp_seconds(event.timeStampSeconds); | 22 proto->set_timestamp_seconds(event.timeStampSeconds()); |
| 23 | 23 |
| 24 GestureCommon* common = proto->mutable_gesture_common(); | 24 GestureCommon* common = proto->mutable_gesture_common(); |
| 25 common->set_x(event.x); | 25 common->set_x(event.x); |
| 26 common->set_y(event.y); | 26 common->set_y(event.y); |
| 27 common->set_global_x(event.globalX); | 27 common->set_global_x(event.globalX); |
| 28 common->set_global_y(event.globalY); | 28 common->set_global_y(event.globalY); |
| 29 } | 29 } |
| 30 | 30 |
| 31 void GestureScrollBeginToProto(const blink::WebGestureEvent& event, | 31 void GestureScrollBeginToProto(const blink::WebGestureEvent& event, |
| 32 InputMessage* proto) { | 32 InputMessage* proto) { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 | 145 |
| 146 InputMessageGenerator::InputMessageGenerator() {} | 146 InputMessageGenerator::InputMessageGenerator() {} |
| 147 | 147 |
| 148 InputMessageGenerator::~InputMessageGenerator() {} | 148 InputMessageGenerator::~InputMessageGenerator() {} |
| 149 | 149 |
| 150 std::unique_ptr<BlimpMessage> InputMessageGenerator::GenerateMessage( | 150 std::unique_ptr<BlimpMessage> InputMessageGenerator::GenerateMessage( |
| 151 const blink::WebGestureEvent& event) { | 151 const blink::WebGestureEvent& event) { |
| 152 InputMessage* details; | 152 InputMessage* details; |
| 153 std::unique_ptr<BlimpMessage> message = CreateBlimpMessage(&details); | 153 std::unique_ptr<BlimpMessage> message = CreateBlimpMessage(&details); |
| 154 | 154 |
| 155 switch (event.type) { | 155 switch (event.type()) { |
| 156 case blink::WebInputEvent::Type::GestureScrollBegin: | 156 case blink::WebInputEvent::Type::GestureScrollBegin: |
| 157 GestureScrollBeginToProto(event, details); | 157 GestureScrollBeginToProto(event, details); |
| 158 break; | 158 break; |
| 159 case blink::WebInputEvent::Type::GestureScrollEnd: | 159 case blink::WebInputEvent::Type::GestureScrollEnd: |
| 160 GestureScrollEndToProto(event, details); | 160 GestureScrollEndToProto(event, details); |
| 161 break; | 161 break; |
| 162 case blink::WebInputEvent::Type::GestureScrollUpdate: | 162 case blink::WebInputEvent::Type::GestureScrollUpdate: |
| 163 GestureScrollUpdateToProto(event, details); | 163 GestureScrollUpdateToProto(event, details); |
| 164 break; | 164 break; |
| 165 case blink::WebInputEvent::Type::GestureFlingStart: | 165 case blink::WebInputEvent::Type::GestureFlingStart: |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 case blink::WebInputEvent::Type::Char: | 208 case blink::WebInputEvent::Type::Char: |
| 209 case blink::WebInputEvent::Type::GestureDoubleTap: | 209 case blink::WebInputEvent::Type::GestureDoubleTap: |
| 210 case blink::WebInputEvent::Type::GestureTwoFingerTap: | 210 case blink::WebInputEvent::Type::GestureTwoFingerTap: |
| 211 case blink::WebInputEvent::Type::GestureLongPress: | 211 case blink::WebInputEvent::Type::GestureLongPress: |
| 212 case blink::WebInputEvent::Type::GestureLongTap: | 212 case blink::WebInputEvent::Type::GestureLongTap: |
| 213 case blink::WebInputEvent::Type::TouchStart: | 213 case blink::WebInputEvent::Type::TouchStart: |
| 214 case blink::WebInputEvent::Type::TouchMove: | 214 case blink::WebInputEvent::Type::TouchMove: |
| 215 case blink::WebInputEvent::Type::TouchEnd: | 215 case blink::WebInputEvent::Type::TouchEnd: |
| 216 case blink::WebInputEvent::Type::TouchCancel: | 216 case blink::WebInputEvent::Type::TouchCancel: |
| 217 case blink::WebInputEvent::Type::TouchScrollStarted: | 217 case blink::WebInputEvent::Type::TouchScrollStarted: |
| 218 DVLOG(1) << "Unsupported WebInputEvent type " << event.type; | 218 DVLOG(1) << "Unsupported WebInputEvent type " << event.type(); |
| 219 return nullptr; | 219 return nullptr; |
| 220 } | 220 } |
| 221 | 221 |
| 222 return message; | 222 return message; |
| 223 } | 223 } |
| 224 | 224 |
| 225 } // namespace blimp | 225 } // namespace blimp |
| OLD | NEW |