Chromium Code Reviews| 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 3fbce10dbaca04e51561930e9e2e8a69b91d16b1..47e7d191d21608853eb2b3096a5e558bf264df59 100644 |
| --- a/content/browser/devtools/renderer_overrides_handler.cc |
| +++ b/content/browser/devtools/renderer_overrides_handler.cc |
| @@ -65,27 +65,6 @@ static int kDefaultScreenshotQuality = 80; |
| static int kFrameRateThresholdMs = 100; |
| static int kCaptureRetryLimit = 2; |
| -void ParseGenericInputParams(base::DictionaryValue* params, |
| - WebInputEvent* event) { |
| - 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); |
| -} |
| - |
| } // namespace |
| RendererOverridesHandler::RendererOverridesHandler(DevToolsAgentHost* agent) |
| @@ -162,16 +141,6 @@ RendererOverridesHandler::RendererOverridesHandler(DevToolsAgentHost* agent) |
| &RendererOverridesHandler::PageQueryUsageAndQuota, |
| base::Unretained(this))); |
| RegisterCommandHandler( |
| - devtools::Input::dispatchMouseEvent::kName, |
| - base::Bind( |
| - &RendererOverridesHandler::InputDispatchMouseEvent, |
| - base::Unretained(this))); |
| - RegisterCommandHandler( |
| - devtools::Input::dispatchGestureEvent::kName, |
| - base::Bind( |
| - &RendererOverridesHandler::InputDispatchGestureEvent, |
| - base::Unretained(this))); |
| - RegisterCommandHandler( |
| devtools::Input::emulateTouchFromMouseEvent::kName, |
| base::Bind( |
| &RendererOverridesHandler::InputEmulateTouchFromMouseEvent, |
| @@ -879,40 +848,14 @@ void RendererOverridesHandler::NotifyScreencastVisibility(bool visible) { |
| // Input agent handlers ------------------------------------------------------ |
| scoped_refptr<DevToolsProtocol::Response> |
| -RendererOverridesHandler::InputDispatchMouseEvent( |
| - scoped_refptr<DevToolsProtocol::Command> command) { |
| - base::DictionaryValue* params = command->params(); |
| - if (!params) |
| - return NULL; |
| - |
| - bool device_space = false; |
| - if (!params->GetBoolean( |
| - devtools::Input::dispatchMouseEvent::kParamDeviceSpace, |
| - &device_space) || |
| - !device_space) { |
| - return NULL; |
| - } |
| - |
| - if (!DispatchMouseEventFromCommand(command)) |
| - return NULL; |
| - return command->SuccessResponse(NULL); |
| -} |
| - |
| -scoped_refptr<DevToolsProtocol::Response> |
| RendererOverridesHandler::InputEmulateTouchFromMouseEvent( |
| scoped_refptr<DevToolsProtocol::Command> command) { |
| if (!screencast_command_) |
| return NULL; |
| - if (!DispatchMouseEventFromCommand(command)) |
| - return NULL; |
| - return command->SuccessResponse(NULL); |
| -} |
| -bool RendererOverridesHandler::DispatchMouseEventFromCommand( |
| - scoped_refptr<DevToolsProtocol::Command> command) { |
| base::DictionaryValue* params = command->params(); |
| if (!params) |
| - return false; |
| + return NULL; |
|
pfeldman
2014/08/04 12:16:22
return error responce instead.
dgozman
2014/08/05 08:21:01
Done.
|
| RenderViewHost* host = agent_->GetRenderViewHost(); |
| @@ -920,7 +863,7 @@ bool RendererOverridesHandler::DispatchMouseEventFromCommand( |
| if (!params->GetString( |
| devtools::Input::emulateTouchFromMouseEvent::kParamType, |
| &type)) { |
| - return false; |
| + return NULL; |
| } |
| blink::WebMouseWheelEvent wheel_event; |
| @@ -946,23 +889,39 @@ bool RendererOverridesHandler::DispatchMouseEventFromCommand( |
| !params->GetDouble( |
| devtools::Input::emulateTouchFromMouseEvent::kParamDeltaY, |
| &deltaY)) { |
| - return false; |
| + return NULL; |
| } |
| wheel_event.deltaX = static_cast<float>(deltaX); |
| wheel_event.deltaY = static_cast<float>(deltaY); |
| event = &wheel_event; |
| event->type = WebInputEvent::MouseWheel; |
| } else { |
| - return false; |
| + return NULL; |
| + } |
| + |
| + 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; |
| } |
| - ParseGenericInputParams(params, event); |
| + params->GetDouble( |
| + devtools::Input::emulateTouchFromMouseEvent::kParamTimestamp, |
| + &event->timeStampSeconds); |
| if (!params->GetInteger(devtools::Input::emulateTouchFromMouseEvent::kParamX, |
| &event->x) || |
| !params->GetInteger(devtools::Input::emulateTouchFromMouseEvent::kParamY, |
| &event->y)) { |
| - return false; |
| + return NULL; |
| } |
| event->windowX = event->x; |
| @@ -978,7 +937,7 @@ bool RendererOverridesHandler::DispatchMouseEventFromCommand( |
| if (!params->GetString( |
| devtools::Input::emulateTouchFromMouseEvent::kParamButton, |
| &button)) { |
| - return false; |
| + return NULL; |
| } |
| if (button == "none") { |
| @@ -993,95 +952,13 @@ bool RendererOverridesHandler::DispatchMouseEventFromCommand( |
| event->button = WebMouseEvent::ButtonRight; |
| event->modifiers |= WebInputEvent::RightButtonDown; |
| } else { |
| - return false; |
| + return NULL; |
| } |
| if (event->type == WebInputEvent::MouseWheel) |
| host->ForwardWheelEvent(wheel_event); |
| else |
| host->ForwardMouseEvent(mouse_event); |
| - return true; |
| -} |
| - |
| -scoped_refptr<DevToolsProtocol::Response> |
| -RendererOverridesHandler::InputDispatchGestureEvent( |
| - scoped_refptr<DevToolsProtocol::Command> command) { |
| - base::DictionaryValue* params = command->params(); |
| - if (!params) |
| - return NULL; |
| - |
| - RenderViewHostImpl* host = static_cast<RenderViewHostImpl*>( |
| - agent_->GetRenderViewHost()); |
| - blink::WebGestureEvent event; |
| - ParseGenericInputParams(params, &event); |
| - event.sourceDevice = blink::WebGestureDeviceTouchscreen; |
| - |
| - std::string type; |
| - if (params->GetString(devtools::Input::dispatchGestureEvent::kParamType, |
| - &type)) { |
| - if (type == |
| - devtools::Input::dispatchGestureEvent::Type::kEnumScrollBegin) |
| - event.type = WebInputEvent::GestureScrollBegin; |
| - else if (type == |
| - devtools::Input::dispatchGestureEvent::Type::kEnumScrollUpdate) |
| - event.type = WebInputEvent::GestureScrollUpdate; |
| - else if (type == |
| - devtools::Input::dispatchGestureEvent::Type::kEnumScrollEnd) |
| - event.type = WebInputEvent::GestureScrollEnd; |
| - else if (type == |
| - devtools::Input::dispatchGestureEvent::Type::kEnumTapDown) |
| - event.type = WebInputEvent::GestureTapDown; |
| - else if (type == |
| - devtools::Input::dispatchGestureEvent::Type::kEnumTap) |
| - event.type = WebInputEvent::GestureTap; |
| - else if (type == |
| - devtools::Input::dispatchGestureEvent::Type::kEnumPinchBegin) |
| - event.type = WebInputEvent::GesturePinchBegin; |
| - else if (type == |
| - devtools::Input::dispatchGestureEvent::Type::kEnumPinchUpdate) |
| - event.type = WebInputEvent::GesturePinchUpdate; |
| - else if (type == |
| - devtools::Input::dispatchGestureEvent::Type::kEnumPinchEnd) |
| - event.type = WebInputEvent::GesturePinchEnd; |
| - else |
| - return NULL; |
| - } else { |
| - return NULL; |
| - } |
| - |
| - if (!params->GetInteger(devtools::Input::dispatchGestureEvent::kParamX, |
| - &event.x) || |
| - !params->GetInteger(devtools::Input::dispatchGestureEvent::kParamY, |
| - &event.y)) { |
| - return NULL; |
| - } |
| - event.globalX = event.x; |
| - event.globalY = event.y; |
| - |
| - if (type == "scrollUpdate") { |
| - int dx = 0; |
| - int dy = 0; |
| - if (!params->GetInteger( |
| - devtools::Input::dispatchGestureEvent::kParamDeltaX, &dx) || |
| - !params->GetInteger( |
| - devtools::Input::dispatchGestureEvent::kParamDeltaY, &dy)) { |
| - return NULL; |
| - } |
| - event.data.scrollUpdate.deltaX = dx; |
| - event.data.scrollUpdate.deltaY = dy; |
| - } |
| - |
| - if (type == "pinchUpdate") { |
| - double scale; |
| - if (!params->GetDouble( |
| - devtools::Input::dispatchGestureEvent::kParamPinchScale, |
| - &scale)) { |
| - return NULL; |
| - } |
| - event.data.pinchUpdate.scale = static_cast<float>(scale); |
| - } |
| - |
| - host->ForwardGestureEvent(event); |
| return command->SuccessResponse(NULL); |
| } |