Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Unified Diff: content/common/input/input_event_stream_validator.cc

Issue 290473006: Add a TouchEventStreamValidator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/common/input/input_event_stream_validator.cc
diff --git a/content/common/input/input_event_stream_validator.cc b/content/common/input/input_event_stream_validator.cc
index bd6dd6428c94c233d31496bf41e3e57f41f1ed83..85ac42cb5cf8d6a4e4e0be6624249b9a2fe6f3d4 100644
--- a/content/common/input/input_event_stream_validator.cc
+++ b/content/common/input/input_event_stream_validator.cc
@@ -9,29 +9,40 @@
#include "content/public/common/content_switches.h"
#include "third_party/WebKit/public/web/WebInputEvent.h"
-namespace content {
-
using blink::WebInputEvent;
using blink::WebGestureEvent;
+using blink::WebTouchEvent;
-InputEventStreamValidator::InputEventStreamValidator() {
- CommandLine* command_line = CommandLine::ForCurrentProcess();
- enabled_ = command_line->HasSwitch(switches::kValidateInputEventStream);
+namespace content {
+
+InputEventStreamValidator::InputEventStreamValidator()
+ : enabled_(CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kValidateInputEventStream)) {
}
-InputEventStreamValidator::~InputEventStreamValidator() {}
-void InputEventStreamValidator::OnEvent(const WebInputEvent& event) {
+InputEventStreamValidator::~InputEventStreamValidator() {
+}
+
+void InputEventStreamValidator::Validate(const WebInputEvent& event) {
if (!enabled_)
return;
- const char* error_message = NULL;
+
+ DCHECK(ValidateImpl(event, &error_msg_)) << error_msg_;
+}
+
+bool InputEventStreamValidator::ValidateImpl(const blink::WebInputEvent& event,
+ std::string* error_msg) {
+ DCHECK(error_msg);
if (WebInputEvent::isGestureEventType(event.type)) {
- const WebGestureEvent& gesture_event =
- static_cast<const WebGestureEvent&>(event);
- if (gesture_event.sourceDevice == blink::WebGestureDeviceTouchscreen) {
- if (!gesture_validator_.Validate(gesture_event, &error_message))
- NOTREACHED() << error_message;
- }
+ const WebGestureEvent& gesture = static_cast<const WebGestureEvent&>(event);
+ // TODO(jdduke): Validate touchpad gesture streams.
+ if (gesture.sourceDevice == blink::WebGestureDeviceTouchscreen)
+ return gesture_validator_.Validate(gesture, error_msg);
+ } else if (WebInputEvent::isTouchEventType(event.type)) {
+ const WebTouchEvent& touch = static_cast<const WebTouchEvent&>(event);
+ return touch_validator_.Validate(touch, error_msg);
}
+ return true;
}
} // namespace content
« no previous file with comments | « content/common/input/input_event_stream_validator.h ('k') | content/common/input/touch_event_stream_validator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698