| 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..d579d659ae669a7b35b0ad02b96957550d66689b 100644
|
| --- a/content/browser/devtools/protocol/emulation_handler.cc
|
| +++ b/content/browser/devtools/protocol/emulation_handler.cc
|
| @@ -146,7 +146,14 @@ 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* scroll_position_x,
|
| + const int* scroll_position_y,
|
| + const int* visual_viewport_width,
|
| + const int* visual_viewport_height,
|
| + const double* visual_viewport_position_x,
|
| + const double* visual_viewport_position_y,
|
| + const double* visual_viewport_scale) {
|
| const static int max_size = 10000000;
|
| const static double max_scale = 10;
|
| const static int max_orientation_angle = 360;
|
| @@ -207,6 +214,44 @@ Response EmulationHandler::SetDeviceMetricsOverride(
|
| }
|
| }
|
|
|
| + if ((scroll_position_x &&
|
| + (*scroll_position_x < 0 || *scroll_position_x > max_size)) ||
|
| + (scroll_position_y &&
|
| + (*scroll_position_y < 0 || *scroll_position_y > max_size))) {
|
| + return Response::InvalidParams(
|
| + "Scroll position coordinates must be non-negative, not greater than " +
|
| + base::IntToString(max_size));
|
| + }
|
| +
|
| + 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 "
|
| + "than " +
|
| + base::IntToString(max_size));
|
| + }
|
| +
|
| + if ((visual_viewport_position_x &&
|
| + (*visual_viewport_position_x < 0 ||
|
| + *visual_viewport_position_x > max_size)) ||
|
| + (visual_viewport_position_y &&
|
| + (*visual_viewport_position_y < 0 ||
|
| + *visual_viewport_position_y > max_size))) {
|
| + return Response::InvalidParams(
|
| + "Visual viewport position coordinates must be non-negative, not "
|
| + "greater than " +
|
| + base::IntToString(max_size));
|
| + }
|
| +
|
| + if (visual_viewport_scale &&
|
| + (*visual_viewport_scale <= 0 || *visual_viewport_scale > max_scale)) {
|
| + return Response::InvalidParams(
|
| + "Scale must be positive and not greater than " +
|
| + base::DoubleToString(max_scale));
|
| + }
|
| +
|
| blink::WebDeviceEmulationParams params;
|
| params.screenPosition = mobile ? blink::WebDeviceEmulationParams::Mobile :
|
| blink::WebDeviceEmulationParams::Desktop;
|
| @@ -223,6 +268,17 @@ Response EmulationHandler::SetDeviceMetricsOverride(
|
| optional_offset_y ? *optional_offset_y : 0.f);
|
| params.screenOrientationType = orientationType;
|
| params.screenOrientationAngle = orientationAngle;
|
| + params.scrollPosition =
|
| + blink::WebPoint(scroll_position_x ? *scroll_position_x : -1,
|
| + scroll_position_y ? *scroll_position_y : -1);
|
| + params.visualViewportSize =
|
| + blink::WebSize(visual_viewport_width ? *visual_viewport_width : 0,
|
| + visual_viewport_height ? *visual_viewport_height : 0);
|
| + params.visualViewportPosition = blink::WebFloatPoint(
|
| + visual_viewport_position_x ? *visual_viewport_position_x : -1,
|
| + visual_viewport_position_y ? *visual_viewport_position_y : -1);
|
| + params.visualViewportScale =
|
| + visual_viewport_scale ? *visual_viewport_scale : 0;
|
|
|
| if (device_emulation_enabled_ && params == device_emulation_params_)
|
| return Response::OK();
|
|
|