| 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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 Response EmulationHandler::SetVisibleSize(int width, int height) { | 240 Response EmulationHandler::SetVisibleSize(int width, int height) { |
| 241 if (width < 0 || height < 0) | 241 if (width < 0 || height < 0) |
| 242 return Response::InvalidParams("Width and height must be non-negative"); | 242 return Response::InvalidParams("Width and height must be non-negative"); |
| 243 | 243 |
| 244 // Set size of frame by resizing RWHV if available. | 244 // Set size of frame by resizing RWHV if available. |
| 245 RenderWidgetHostImpl* widget_host = | 245 RenderWidgetHostImpl* widget_host = |
| 246 host_ ? host_->GetRenderWidgetHost() : nullptr; | 246 host_ ? host_->GetRenderWidgetHost() : nullptr; |
| 247 if (!widget_host) | 247 if (!widget_host) |
| 248 return Response::Error("Target does not support setVisibleSize"); | 248 return Response::Error("Target does not support setVisibleSize"); |
| 249 | 249 |
| 250 if (width == 0) |
| 251 width = widget_host->GetView()->GetViewBounds().width(); |
| 252 if (height == 0) |
| 253 height = widget_host->GetView()->GetViewBounds().height(); |
| 250 widget_host->GetView()->SetSize(gfx::Size(width, height)); | 254 widget_host->GetView()->SetSize(gfx::Size(width, height)); |
| 251 return Response::OK(); | 255 return Response::OK(); |
| 252 } | 256 } |
| 253 | 257 |
| 254 WebContentsImpl* EmulationHandler::GetWebContents() { | 258 WebContentsImpl* EmulationHandler::GetWebContents() { |
| 255 return host_ ? | 259 return host_ ? |
| 256 static_cast<WebContentsImpl*>(WebContents::FromRenderFrameHost(host_)) : | 260 static_cast<WebContentsImpl*>(WebContents::FromRenderFrameHost(host_)) : |
| 257 nullptr; | 261 nullptr; |
| 258 } | 262 } |
| 259 | 263 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 279 widget_host->Send(new ViewMsg_EnableDeviceEmulation( | 283 widget_host->Send(new ViewMsg_EnableDeviceEmulation( |
| 280 widget_host->GetRoutingID(), device_emulation_params_)); | 284 widget_host->GetRoutingID(), device_emulation_params_)); |
| 281 } else { | 285 } else { |
| 282 widget_host->Send(new ViewMsg_DisableDeviceEmulation( | 286 widget_host->Send(new ViewMsg_DisableDeviceEmulation( |
| 283 widget_host->GetRoutingID())); | 287 widget_host->GetRoutingID())); |
| 284 } | 288 } |
| 285 } | 289 } |
| 286 | 290 |
| 287 } // namespace protocol | 291 } // namespace protocol |
| 288 } // namespace content | 292 } // namespace content |
| OLD | NEW |