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 "content/common/input/input_event_stream_validator.h" | 5 #include "content/common/input/input_event_stream_validator.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "content/public/common/content_switches.h" | 9 #include "content/public/common/content_switches.h" |
| 10 #include "third_party/WebKit/public/web/WebInputEvent.h" | 10 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 11 | 11 |
| 12 using blink::WebInputEvent; | 12 using blink::WebInputEvent; |
| 13 using blink::WebGestureEvent; | 13 using blink::WebGestureEvent; |
| 14 using blink::WebTouchEvent; | 14 using blink::WebTouchEvent; |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 | 17 |
| 18 InputEventStreamValidator::InputEventStreamValidator() | 18 InputEventStreamValidator::InputEventStreamValidator() |
| 19 : enabled_(CommandLine::ForCurrentProcess()->HasSwitch( | 19 : enabled_(CommandLine::ForCurrentProcess()->HasSwitch( |
|
jdduke (slow)
2014/12/20 01:12:17
Hmm, I should probably just get rid of the |enable
| |
| 20 switches::kValidateInputEventStream)) { | 20 switches::kValidateInputEventStream)) { |
| 21 } | 21 } |
| 22 | 22 |
| 23 InputEventStreamValidator::~InputEventStreamValidator() { | 23 InputEventStreamValidator::~InputEventStreamValidator() { |
| 24 } | 24 } |
| 25 | 25 |
| 26 void InputEventStreamValidator::Validate(const WebInputEvent& event) { | 26 void InputEventStreamValidator::Validate(const WebInputEvent& event) { |
| 27 if (!enabled_) | 27 if (!enabled_) |
| 28 return; | 28 return; |
| 29 | 29 |
| 30 DCHECK(ValidateImpl(event, &error_msg_)) << error_msg_; | 30 CHECK(ValidateImpl(event, &error_msg_)) << error_msg_; |
| 31 } | 31 } |
| 32 | 32 |
| 33 bool InputEventStreamValidator::ValidateImpl(const blink::WebInputEvent& event, | 33 bool InputEventStreamValidator::ValidateImpl(const blink::WebInputEvent& event, |
| 34 std::string* error_msg) { | 34 std::string* error_msg) { |
| 35 DCHECK(error_msg); | 35 DCHECK(error_msg); |
| 36 if (WebInputEvent::isGestureEventType(event.type)) { | 36 if (WebInputEvent::isGestureEventType(event.type)) { |
| 37 const WebGestureEvent& gesture = static_cast<const WebGestureEvent&>(event); | 37 const WebGestureEvent& gesture = static_cast<const WebGestureEvent&>(event); |
| 38 // TODO(jdduke): Validate touchpad gesture streams. | 38 // TODO(jdduke): Validate touchpad gesture streams. |
| 39 if (gesture.sourceDevice == blink::WebGestureDeviceTouchscreen) | 39 if (gesture.sourceDevice == blink::WebGestureDeviceTouchscreen) |
| 40 return gesture_validator_.Validate(gesture, error_msg); | 40 return gesture_validator_.Validate(gesture, error_msg); |
| 41 } else if (WebInputEvent::isTouchEventType(event.type)) { | 41 } else if (WebInputEvent::isTouchEventType(event.type)) { |
| 42 const WebTouchEvent& touch = static_cast<const WebTouchEvent&>(event); | 42 const WebTouchEvent& touch = static_cast<const WebTouchEvent&>(event); |
| 43 return touch_validator_.Validate(touch, error_msg); | 43 return touch_validator_.Validate(touch, error_msg); |
| 44 } | 44 } |
| 45 return true; | 45 return true; |
| 46 } | 46 } |
| 47 | 47 |
| 48 } // namespace content | 48 } // namespace content |
| OLD | NEW |