OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/protocol/emulation_handler.h" | 5 #include "content/browser/devtools/protocol/emulation_handler.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 | 238 |
239 Response EmulationHandler::ClearDeviceMetricsOverride() { | 239 Response EmulationHandler::ClearDeviceMetricsOverride() { |
240 if (!device_emulation_enabled_) | 240 if (!device_emulation_enabled_) |
241 return Response::OK(); | 241 return Response::OK(); |
242 | 242 |
243 device_emulation_enabled_ = false; | 243 device_emulation_enabled_ = false; |
244 UpdateDeviceEmulationState(); | 244 UpdateDeviceEmulationState(); |
245 return Response::OK(); | 245 return Response::OK(); |
246 } | 246 } |
247 | 247 |
| 248 Response EmulationHandler::SetVisibleSize(int width, int height) { |
| 249 if (width < 0 || height < 0) |
| 250 return Response::InvalidParams("Width and height must be non-negative"); |
| 251 |
| 252 // Set size of frame by resizing RWHV if available. |
| 253 RenderWidgetHostImpl* widget_host = |
| 254 host_ ? host_->GetRenderWidgetHost() : nullptr; |
| 255 if (!widget_host) |
| 256 return Response::ServerError("Target does not support setVisibleSize"); |
| 257 |
| 258 widget_host->GetView()->SetSize(gfx::Size(width, height)); |
| 259 return Response::OK(); |
| 260 } |
| 261 |
248 WebContentsImpl* EmulationHandler::GetWebContents() { | 262 WebContentsImpl* EmulationHandler::GetWebContents() { |
249 return host_ ? | 263 return host_ ? |
250 static_cast<WebContentsImpl*>(WebContents::FromRenderFrameHost(host_)) : | 264 static_cast<WebContentsImpl*>(WebContents::FromRenderFrameHost(host_)) : |
251 nullptr; | 265 nullptr; |
252 } | 266 } |
253 | 267 |
254 void EmulationHandler::UpdateTouchEventEmulationState() { | 268 void EmulationHandler::UpdateTouchEventEmulationState() { |
255 RenderWidgetHostImpl* widget_host = | 269 RenderWidgetHostImpl* widget_host = |
256 host_ ? host_->GetRenderWidgetHost() : nullptr; | 270 host_ ? host_->GetRenderWidgetHost() : nullptr; |
257 if (!widget_host) | 271 if (!widget_host) |
(...skipping 16 matching lines...) Expand all Loading... |
274 widget_host->GetRoutingID(), device_emulation_params_)); | 288 widget_host->GetRoutingID(), device_emulation_params_)); |
275 } else { | 289 } else { |
276 widget_host->Send(new ViewMsg_DisableDeviceEmulation( | 290 widget_host->Send(new ViewMsg_DisableDeviceEmulation( |
277 widget_host->GetRoutingID())); | 291 widget_host->GetRoutingID())); |
278 } | 292 } |
279 } | 293 } |
280 | 294 |
281 } // namespace emulation | 295 } // namespace emulation |
282 } // namespace devtools | 296 } // namespace devtools |
283 } // namespace content | 297 } // namespace content |
OLD | NEW |