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 12c377a4fc84eab5396d2d195ded5158134a463f..f498f335592675d5e5818d054ccf19010c14a739 100644 |
--- a/content/browser/devtools/protocol/emulation_handler.cc |
+++ b/content/browser/devtools/protocol/emulation_handler.cc |
@@ -146,7 +146,9 @@ Response EmulationHandler::SetDeviceMetricsOverride( |
const int* screen_height, |
const int* position_x, |
const int* position_y, |
- const std::unique_ptr<base::DictionaryValue>& screen_orientation) { |
+ const std::unique_ptr<base::DictionaryValue>& screen_orientation, |
+ const int* visual_viewport_width, |
+ const int* visual_viewport_height) { |
const static int max_size = 10000000; |
const static double max_scale = 10; |
const static int max_orientation_angle = 360; |
@@ -207,6 +209,15 @@ Response EmulationHandler::SetDeviceMetricsOverride( |
} |
} |
+ if ((visual_viewport_width && |
+ (*visual_viewport_width < 0 || *visual_viewport_width > max_size)) || |
+ (visual_viewport_height && |
+ (*visual_viewport_height < 0 || *visual_viewport_height > max_size))) { |
+ return Response::InvalidParams( |
+ "Visual viewport dimensions must be positive, not greater than " + |
+ base::IntToString(max_size)); |
+ } |
+ |
blink::WebDeviceEmulationParams params; |
params.screenPosition = mobile ? blink::WebDeviceEmulationParams::Mobile : |
blink::WebDeviceEmulationParams::Desktop; |
@@ -223,6 +234,9 @@ Response EmulationHandler::SetDeviceMetricsOverride( |
optional_offset_y ? *optional_offset_y : 0.f); |
params.screenOrientationType = orientationType; |
params.screenOrientationAngle = orientationAngle; |
+ params.visualViewportSize = |
+ blink::WebSize(visual_viewport_width ? *visual_viewport_width : 0, |
+ visual_viewport_height ? *visual_viewport_height : 0); |
if (device_emulation_enabled_ && params == device_emulation_params_) |
return Response::OK(); |