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 namespace content { | 12 namespace content { |
13 | 13 |
14 using blink::WebInputEvent; | 14 using blink::WebInputEvent; |
15 using blink::WebGestureEvent; | 15 using blink::WebGestureEvent; |
16 | 16 |
17 InputEventStreamValidator::InputEventStreamValidator() { | 17 InputEventStreamValidator::InputEventStreamValidator() { |
18 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 18 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
19 enabled_ = command_line->HasSwitch(switches::kValidateInputEventStream); | 19 enabled_ = command_line->HasSwitch(switches::kValidateInputEventStream); |
20 } | 20 } |
21 InputEventStreamValidator::~InputEventStreamValidator() {} | 21 InputEventStreamValidator::~InputEventStreamValidator() {} |
22 | 22 |
23 void InputEventStreamValidator::OnEvent(const WebInputEvent& event) { | 23 void InputEventStreamValidator::OnEvent(const WebInputEvent& event) { |
24 if (!enabled_) | 24 if (!enabled_) |
25 return; | 25 return; |
26 const char* error_message = NULL; | 26 const char* error_message = NULL; |
27 if (WebInputEvent::isGestureEventType(event.type)) { | 27 if (WebInputEvent::isGestureEventType(event.type)) { |
28 const WebGestureEvent& gesture_event = | 28 const WebGestureEvent& gesture_event = |
29 static_cast<const WebGestureEvent&>(event); | 29 static_cast<const WebGestureEvent&>(event); |
30 if (gesture_event.sourceDevice == blink::WebGestureEvent::Touchscreen) { | 30 if (gesture_event.sourceDevice == blink::WebGestureDeviceTouchpad) { |
31 if (!gesture_validator_.Validate(gesture_event, &error_message)) | 31 if (!gesture_validator_.Validate(gesture_event, &error_message)) |
32 NOTREACHED() << error_message; | 32 NOTREACHED() << error_message; |
33 } | 33 } |
34 } | 34 } |
35 } | 35 } |
36 | 36 |
37 } // namespace content | 37 } // namespace content |
OLD | NEW |