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

Unified Diff: content/browser/devtools/renderer_overrides_handler.cc

Issue 508973003: DevTools: Protocol handler generator for content (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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/browser/devtools/renderer_overrides_handler.cc
diff --git a/content/browser/devtools/renderer_overrides_handler.cc b/content/browser/devtools/renderer_overrides_handler.cc
index 7bb629b9aaffacb9fee9a90e0d40460ce892d62d..b897cbf83fdd2467589a351fb6e38991d2bfd2f4 100644
--- a/content/browser/devtools/renderer_overrides_handler.cc
+++ b/content/browser/devtools/renderer_overrides_handler.cc
@@ -174,11 +174,6 @@ RendererOverridesHandler::RendererOverridesHandler()
base::Bind(
&RendererOverridesHandler::PageSetColorPickerEnabled,
base::Unretained(this)));
- RegisterCommandHandler(
- devtools::Input::emulateTouchFromMouseEvent::kName,
- base::Bind(
- &RendererOverridesHandler::InputEmulateTouchFromMouseEvent,
- base::Unretained(this)));
mouse_event_callback_ = base::Bind(
&RendererOverridesHandler::HandleMouseEvent,
base::Unretained(this));
@@ -1189,137 +1184,6 @@ void RendererOverridesHandler::UpdateColorPickerCursor() {
host_->SetCursor(cursor);
}
-// Input agent handlers ------------------------------------------------------
-
-scoped_refptr<DevToolsProtocol::Response>
-RendererOverridesHandler::InputEmulateTouchFromMouseEvent(
- scoped_refptr<DevToolsProtocol::Command> command) {
- if (!screencast_command_.get())
- return command->InternalErrorResponse("Screencast should be turned on");
-
- base::DictionaryValue* params = command->params();
- if (!params)
- return command->NoSuchMethodErrorResponse();
-
- std::string type;
- if (!params->GetString(
- devtools::Input::emulateTouchFromMouseEvent::kParamType,
- &type)) {
- return command->InvalidParamResponse(
- devtools::Input::emulateTouchFromMouseEvent::kParamType);
- }
-
- blink::WebMouseWheelEvent wheel_event;
- blink::WebMouseEvent mouse_event;
- blink::WebMouseEvent* event = &mouse_event;
-
- if (type ==
- devtools::Input::emulateTouchFromMouseEvent::Type::kEnumMousePressed) {
- event->type = WebInputEvent::MouseDown;
- } else if (type ==
- devtools::Input::emulateTouchFromMouseEvent::Type::kEnumMouseReleased) {
- event->type = WebInputEvent::MouseUp;
- } else if (type ==
- devtools::Input::emulateTouchFromMouseEvent::Type::kEnumMouseMoved) {
- event->type = WebInputEvent::MouseMove;
- } else if (type ==
- devtools::Input::emulateTouchFromMouseEvent::Type::kEnumMouseWheel) {
- double deltaX = 0;
- double deltaY = 0;
- if (!params->GetDouble(
- devtools::Input::emulateTouchFromMouseEvent::kParamDeltaX,
- &deltaX)) {
- return command->InvalidParamResponse(
- devtools::Input::emulateTouchFromMouseEvent::kParamDeltaX);
- }
- if (!params->GetDouble(
- devtools::Input::emulateTouchFromMouseEvent::kParamDeltaY,
- &deltaY)) {
- return command->InvalidParamResponse(
- devtools::Input::emulateTouchFromMouseEvent::kParamDeltaY);
- }
- wheel_event.deltaX = static_cast<float>(deltaX);
- wheel_event.deltaY = static_cast<float>(deltaY);
- event = &wheel_event;
- event->type = WebInputEvent::MouseWheel;
- } else {
- return command->InvalidParamResponse(
- devtools::Input::emulateTouchFromMouseEvent::kParamType);
- }
-
- int modifiers = 0;
- if (params->GetInteger(
- devtools::Input::emulateTouchFromMouseEvent::kParamModifiers,
- &modifiers)) {
- if (modifiers & 1)
- event->modifiers |= WebInputEvent::AltKey;
- if (modifiers & 2)
- event->modifiers |= WebInputEvent::ControlKey;
- if (modifiers & 4)
- event->modifiers |= WebInputEvent::MetaKey;
- if (modifiers & 8)
- event->modifiers |= WebInputEvent::ShiftKey;
- }
-
- params->GetDouble(
- devtools::Input::emulateTouchFromMouseEvent::kParamTimestamp,
- &event->timeStampSeconds);
-
- if (!params->GetInteger(devtools::Input::emulateTouchFromMouseEvent::kParamX,
- &event->x)) {
- return command->InvalidParamResponse(
- devtools::Input::emulateTouchFromMouseEvent::kParamX);
- }
-
- if (!params->GetInteger(devtools::Input::emulateTouchFromMouseEvent::kParamY,
- &event->y)) {
- return command->InvalidParamResponse(
- devtools::Input::emulateTouchFromMouseEvent::kParamY);
- }
-
- event->windowX = event->x;
- event->windowY = event->y;
- event->globalX = event->x;
- event->globalY = event->y;
-
- params->GetInteger(
- devtools::Input::emulateTouchFromMouseEvent::kParamClickCount,
- &event->clickCount);
-
- std::string button;
- if (!params->GetString(
- devtools::Input::emulateTouchFromMouseEvent::kParamButton,
- &button)) {
- return command->InvalidParamResponse(
- devtools::Input::emulateTouchFromMouseEvent::kParamButton);
- }
-
- if (button == "none") {
- event->button = WebMouseEvent::ButtonNone;
- } else if (button == "left") {
- event->button = WebMouseEvent::ButtonLeft;
- event->modifiers |= WebInputEvent::LeftButtonDown;
- } else if (button == "middle") {
- event->button = WebMouseEvent::ButtonMiddle;
- event->modifiers |= WebInputEvent::MiddleButtonDown;
- } else if (button == "right") {
- event->button = WebMouseEvent::ButtonRight;
- event->modifiers |= WebInputEvent::RightButtonDown;
- } else {
- return command->InvalidParamResponse(
- devtools::Input::emulateTouchFromMouseEvent::kParamButton);
- }
-
- if (!host_)
- return command->InternalErrorResponse("Could not connect to view");
-
- if (event->type == WebInputEvent::MouseWheel)
- host_->ForwardWheelEvent(wheel_event);
- else
- host_->ForwardMouseEvent(mouse_event);
- return command->SuccessResponse(NULL);
-}
-
void RendererOverridesHandler::UpdateTouchEventEmulationState() {
if (!host_)
return;

Powered by Google App Engine
This is Rietveld 408576698