OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/browser/devtools/renderer_overrides_handler.h" | 5 #include "content/browser/devtools/renderer_overrides_handler.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/barrier_closure.h" | 10 #include "base/barrier_closure.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 screencast_command_ = NULL; | 185 screencast_command_ = NULL; |
186 UpdateTouchEventEmulationState(); | 186 UpdateTouchEventEmulationState(); |
187 SetColorPickerEnabled(false); | 187 SetColorPickerEnabled(false); |
188 } | 188 } |
189 | 189 |
190 void RendererOverridesHandler::OnSwapCompositorFrame( | 190 void RendererOverridesHandler::OnSwapCompositorFrame( |
191 const cc::CompositorFrameMetadata& frame_metadata) { | 191 const cc::CompositorFrameMetadata& frame_metadata) { |
192 last_compositor_frame_metadata_ = frame_metadata; | 192 last_compositor_frame_metadata_ = frame_metadata; |
193 has_last_compositor_frame_metadata_ = true; | 193 has_last_compositor_frame_metadata_ = true; |
194 | 194 |
195 if (screencast_command_) | 195 if (screencast_command_.get()) |
196 InnerSwapCompositorFrame(); | 196 InnerSwapCompositorFrame(); |
197 if (color_picker_enabled_) | 197 if (color_picker_enabled_) |
198 UpdateColorPickerFrame(); | 198 UpdateColorPickerFrame(); |
199 } | 199 } |
200 | 200 |
201 void RendererOverridesHandler::OnVisibilityChanged(bool visible) { | 201 void RendererOverridesHandler::OnVisibilityChanged(bool visible) { |
202 if (!screencast_command_) | 202 if (!screencast_command_.get()) |
203 return; | 203 return; |
204 NotifyScreencastVisibility(visible); | 204 NotifyScreencastVisibility(visible); |
205 } | 205 } |
206 | 206 |
207 void RendererOverridesHandler::SetRenderViewHost( | 207 void RendererOverridesHandler::SetRenderViewHost( |
208 RenderViewHostImpl* host) { | 208 RenderViewHostImpl* host) { |
209 host_ = host; | 209 host_ = host; |
210 if (!host) | 210 if (!host) |
211 return; | 211 return; |
212 UpdateTouchEventEmulationState(); | 212 UpdateTouchEventEmulationState(); |
(...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1163 cursor.InitFromCursorInfo(cursor_info); | 1163 cursor.InitFromCursorInfo(cursor_info); |
1164 DCHECK(host_); | 1164 DCHECK(host_); |
1165 host_->SetCursor(cursor); | 1165 host_->SetCursor(cursor); |
1166 } | 1166 } |
1167 | 1167 |
1168 // Input agent handlers ------------------------------------------------------ | 1168 // Input agent handlers ------------------------------------------------------ |
1169 | 1169 |
1170 scoped_refptr<DevToolsProtocol::Response> | 1170 scoped_refptr<DevToolsProtocol::Response> |
1171 RendererOverridesHandler::InputEmulateTouchFromMouseEvent( | 1171 RendererOverridesHandler::InputEmulateTouchFromMouseEvent( |
1172 scoped_refptr<DevToolsProtocol::Command> command) { | 1172 scoped_refptr<DevToolsProtocol::Command> command) { |
1173 if (!screencast_command_) | 1173 if (!screencast_command_.get()) |
1174 return command->InternalErrorResponse("Screencast should be turned on"); | 1174 return command->InternalErrorResponse("Screencast should be turned on"); |
1175 | 1175 |
1176 base::DictionaryValue* params = command->params(); | 1176 base::DictionaryValue* params = command->params(); |
1177 if (!params) | 1177 if (!params) |
1178 return command->NoSuchMethodErrorResponse(); | 1178 return command->NoSuchMethodErrorResponse(); |
1179 | 1179 |
1180 std::string type; | 1180 std::string type; |
1181 if (!params->GetString( | 1181 if (!params->GetString( |
1182 devtools::Input::emulateTouchFromMouseEvent::kParamType, | 1182 devtools::Input::emulateTouchFromMouseEvent::kParamType, |
1183 &type)) { | 1183 &type)) { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1292 if (event->type == WebInputEvent::MouseWheel) | 1292 if (event->type == WebInputEvent::MouseWheel) |
1293 host_->ForwardWheelEvent(wheel_event); | 1293 host_->ForwardWheelEvent(wheel_event); |
1294 else | 1294 else |
1295 host_->ForwardMouseEvent(mouse_event); | 1295 host_->ForwardMouseEvent(mouse_event); |
1296 return command->SuccessResponse(NULL); | 1296 return command->SuccessResponse(NULL); |
1297 } | 1297 } |
1298 | 1298 |
1299 void RendererOverridesHandler::UpdateTouchEventEmulationState() { | 1299 void RendererOverridesHandler::UpdateTouchEventEmulationState() { |
1300 if (!host_) | 1300 if (!host_) |
1301 return; | 1301 return; |
1302 bool enabled = touch_emulation_enabled_ || screencast_command_; | 1302 bool enabled = touch_emulation_enabled_ || screencast_command_.get(); |
1303 host_->SetTouchEventEmulationEnabled(enabled); | 1303 host_->SetTouchEventEmulationEnabled(enabled); |
1304 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( | 1304 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( |
1305 WebContents::FromRenderViewHost(host_)); | 1305 WebContents::FromRenderViewHost(host_)); |
1306 if (web_contents) | 1306 if (web_contents) |
1307 web_contents->SetForceDisableOverscrollContent(enabled); | 1307 web_contents->SetForceDisableOverscrollContent(enabled); |
1308 } | 1308 } |
1309 | 1309 |
1310 } // namespace content | 1310 } // namespace content |
OLD | NEW |