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..2fa781913e3fd4678d8e2a93faaa873f25a250a9 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,16 @@ 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( |
+ "Visible_width and visible_height values must be positive, not greater " |
dgozman
2016/07/21 20:54:08
Visual viewport dimensions must be positive, not g
Eric Seckler
2016/07/22 14:44:48
Done.
|
+ "than " + |
+ base::IntToString(max_size)); |
+ } |
+ |
blink::WebDeviceEmulationParams params; |
params.screenPosition = mobile ? blink::WebDeviceEmulationParams::Mobile : |
blink::WebDeviceEmulationParams::Desktop; |
@@ -223,6 +235,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(); |