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

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

Issue 1711083002: [DevTools] Move screen orientation override to RenderWidgetScreenMetricsEmulator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 10 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
« no previous file with comments | « content/browser/devtools/protocol/emulation_handler.h ('k') | content/common/view_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 f5945d713214f6604c2bf9640739f85847f7d62b..6b124e37131dc66c0de5ec67f551117388bf4e4f 100644
--- a/content/browser/devtools/protocol/emulation_handler.cc
+++ b/content/browser/devtools/protocol/emulation_handler.cc
@@ -23,6 +23,19 @@ using Response = DevToolsProtocolClient::Response;
namespace {
+blink::WebScreenOrientationType WebScreenOrientationTypeFromString(
+ const std::string& type) {
+ if (type == screen_orientation::kTypePortraitPrimary)
+ return blink::WebScreenOrientationPortraitPrimary;
+ if (type == screen_orientation::kTypePortraitSecondary)
+ return blink::WebScreenOrientationPortraitSecondary;
+ if (type == screen_orientation::kTypeLandscapePrimary)
+ return blink::WebScreenOrientationLandscapePrimary;
+ if (type == screen_orientation::kTypeLandscapeSecondary)
+ return blink::WebScreenOrientationLandscapeSecondary;
+ return blink::WebScreenOrientationUndefined;
+}
+
ui::GestureProviderConfigType TouchEmulationConfigurationToType(
const std::string& protocol_value) {
ui::GestureProviderConfigType result =
@@ -132,9 +145,11 @@ Response EmulationHandler::SetDeviceMetricsOverride(
const int* screen_width,
const int* screen_height,
const int* position_x,
- const int* position_y) {
+ const int* position_y,
+ const scoped_ptr<base::DictionaryValue>& screen_orientation) {
const static int max_size = 10000000;
const static double max_scale = 10;
+ const static int max_orientation_angle = 360;
if (!host_)
return Response::InternalError("Could not connect to view");
@@ -168,6 +183,30 @@ Response EmulationHandler::SetDeviceMetricsOverride(
base::DoubleToString(max_scale));
}
+ blink::WebScreenOrientationType orientationType =
+ blink::WebScreenOrientationUndefined;
+ int orientationAngle = 0;
+ if (screen_orientation) {
+ std::string orientationTypeString;
+ if (!screen_orientation->GetString("type", &orientationTypeString)) {
+ return Response::InvalidParams(
+ "Screen orientation type must be a string");
+ }
+ orientationType = WebScreenOrientationTypeFromString(orientationTypeString);
+ if (orientationType == blink::WebScreenOrientationUndefined)
+ return Response::InvalidParams("Invalid screen orientation type value");
+
+ if (!screen_orientation->GetInteger("angle", &orientationAngle)) {
+ return Response::InvalidParams(
+ "Screen orientation angle must be a number");
+ }
+ if (orientationAngle < 0 || orientationAngle >= max_orientation_angle) {
+ return Response::InvalidParams(
+ "Screen orientation angle must be non-negative, less than " +
+ base::IntToString(max_orientation_angle));
+ }
+ }
+
blink::WebDeviceEmulationParams params;
params.screenPosition = mobile ? blink::WebDeviceEmulationParams::Mobile :
blink::WebDeviceEmulationParams::Desktop;
@@ -182,6 +221,8 @@ Response EmulationHandler::SetDeviceMetricsOverride(
params.offset = blink::WebFloatPoint(
optional_offset_x ? *optional_offset_x : 0.f,
optional_offset_y ? *optional_offset_y : 0.f);
+ params.screenOrientationType = orientationType;
+ params.screenOrientationAngle = orientationAngle;
if (device_emulation_enabled_ && params == device_emulation_params_)
return Response::OK();
« no previous file with comments | « content/browser/devtools/protocol/emulation_handler.h ('k') | content/common/view_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698