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

Unified Diff: content/browser/devtools/protocol/emulation_handler.cc

Issue 2226323002: Resize DevTools target frames. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move command to Emulation, pull out other fixes into separate patch. Created 4 years, 4 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/protocol/emulation_handler.cc
diff --git a/content/browser/devtools/protocol/emulation_handler.cc b/content/browser/devtools/protocol/emulation_handler.cc
index aa0d798a4336d7408220b2a0aff252774ae86c21..9701280c0fe07a853803efad87b3f2188e0936ce 100644
--- a/content/browser/devtools/protocol/emulation_handler.cc
+++ b/content/browser/devtools/protocol/emulation_handler.cc
@@ -245,6 +245,33 @@ Response EmulationHandler::ClearDeviceMetricsOverride() {
return Response::OK();
}
+Response EmulationHandler::GetFrameSize(int* width, int* height) {
+ // Get size of frame from RWHV if available.
+ RenderWidgetHostImpl* widget_host =
+ host_ ? host_->GetRenderWidgetHost() : nullptr;
+ if (!widget_host)
+ return Response::ServerError("Target does not support GetFrameSize");
+
+ gfx::Size size = widget_host->GetView()->GetViewBounds().size();
+ *width = size.width();
+ *height = size.height();
+ return Response::OK();
+}
+
+Response EmulationHandler::SetFrameSize(int width, int height) {
+ if (width < 0 || height < 0)
+ return Response::InvalidParams("Width and height must be non-negative");
+
+ // Set size of frame by resizing RWHV if available.
+ RenderWidgetHostImpl* widget_host =
+ host_ ? host_->GetRenderWidgetHost() : nullptr;
+ if (!widget_host)
+ return Response::ServerError("Target does not support SetFrameSize");
+
+ widget_host->GetView()->SetSize(gfx::Size(width, height));
+ return Response::OK();
+}
+
WebContentsImpl* EmulationHandler::GetWebContents() {
return host_ ?
static_cast<WebContentsImpl*>(WebContents::FromRenderFrameHost(host_)) :

Powered by Google App Engine
This is Rietveld 408576698