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

Side by Side Diff: content/browser/devtools/protocol/emulation_handler.cc

Issue 2808123004: [devtools] Remove device emulation background color override. (Closed)
Patch Set: . Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/devtools/protocol/emulation_handler.h" 5 #include "content/browser/devtools/protocol/emulation_handler.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 double device_scale_factor, 144 double device_scale_factor,
145 bool mobile, 145 bool mobile,
146 bool fit_window, 146 bool fit_window,
147 Maybe<double> scale, 147 Maybe<double> scale,
148 Maybe<double> offset_x, 148 Maybe<double> offset_x,
149 Maybe<double> offset_y, 149 Maybe<double> offset_y,
150 Maybe<int> screen_width, 150 Maybe<int> screen_width,
151 Maybe<int> screen_height, 151 Maybe<int> screen_height,
152 Maybe<int> position_x, 152 Maybe<int> position_x,
153 Maybe<int> position_y, 153 Maybe<int> position_y,
154 Maybe<Emulation::ScreenOrientation> screen_orientation) { 154 Maybe<Emulation::ScreenOrientation> screen_orientation,
155 Maybe<bool> override_gutter_color) {
155 const static int max_size = 10000000; 156 const static int max_size = 10000000;
156 const static double max_scale = 10; 157 const static double max_scale = 10;
157 const static int max_orientation_angle = 360; 158 const static int max_orientation_angle = 360;
158 159
159 if (!host_) 160 if (!host_)
160 return Response::InternalError(); 161 return Response::InternalError();
161 162
162 if (screen_width.fromMaybe(0) < 0 || screen_height.fromMaybe(0) < 0 || 163 if (screen_width.fromMaybe(0) < 0 || screen_height.fromMaybe(0) < 0 ||
163 screen_width.fromMaybe(0) > max_size || 164 screen_width.fromMaybe(0) > max_size ||
164 screen_height.fromMaybe(0) > max_size) { 165 screen_height.fromMaybe(0) > max_size) {
(...skipping 16 matching lines...) Expand all
181 182
182 if (device_scale_factor < 0) 183 if (device_scale_factor < 0)
183 return Response::InvalidParams("deviceScaleFactor must be non-negative"); 184 return Response::InvalidParams("deviceScaleFactor must be non-negative");
184 185
185 if (scale.fromMaybe(1) <= 0 || scale.fromMaybe(1) > max_scale) { 186 if (scale.fromMaybe(1) <= 0 || scale.fromMaybe(1) > max_scale) {
186 return Response::InvalidParams( 187 return Response::InvalidParams(
187 "scale must be positive, not greater than " + 188 "scale must be positive, not greater than " +
188 base::DoubleToString(max_scale)); 189 base::DoubleToString(max_scale));
189 } 190 }
190 191
191 blink::WebScreenOrientationType orientationType = 192 blink::WebScreenOrientationType orientation_type =
192 blink::kWebScreenOrientationUndefined; 193 blink::kWebScreenOrientationUndefined;
193 int orientationAngle = 0; 194 int orientation_angle = 0;
194 if (screen_orientation.isJust()) { 195 if (screen_orientation.isJust()) {
195 Emulation::ScreenOrientation* orientation = screen_orientation.fromJust(); 196 Emulation::ScreenOrientation* orientation = screen_orientation.fromJust();
196 orientationType = WebScreenOrientationTypeFromString( 197 orientation_type =
197 orientation->GetType()); 198 WebScreenOrientationTypeFromString(orientation->GetType());
198 if (orientationType == blink::kWebScreenOrientationUndefined) 199 if (orientation_type == blink::kWebScreenOrientationUndefined)
199 return Response::InvalidParams("Invalid screen orientation type value"); 200 return Response::InvalidParams("Invalid screen orientation type value");
200 orientationAngle = orientation->GetAngle(); 201 orientation_angle = orientation->GetAngle();
201 if (orientationAngle < 0 || orientationAngle >= max_orientation_angle) { 202 if (orientation_angle < 0 || orientation_angle >= max_orientation_angle) {
202 return Response::InvalidParams( 203 return Response::InvalidParams(
203 "Screen orientation angle must be non-negative, less than " + 204 "Screen orientation angle must be non-negative, less than " +
204 base::IntToString(max_orientation_angle)); 205 base::IntToString(max_orientation_angle));
205 } 206 }
206 } 207 }
207 208
208 blink::WebDeviceEmulationParams params; 209 blink::WebDeviceEmulationParams params;
209 params.screen_position = mobile ? blink::WebDeviceEmulationParams::kMobile 210 params.screen_position = mobile ? blink::WebDeviceEmulationParams::kMobile
210 : blink::WebDeviceEmulationParams::kDesktop; 211 : blink::WebDeviceEmulationParams::kDesktop;
211 params.screen_size = 212 params.screen_size =
212 blink::WebSize(screen_width.fromMaybe(0), screen_height.fromMaybe(0)); 213 blink::WebSize(screen_width.fromMaybe(0), screen_height.fromMaybe(0));
213 params.view_position = 214 params.view_position =
214 blink::WebPoint(position_x.fromMaybe(0), position_y.fromMaybe(0)); 215 blink::WebPoint(position_x.fromMaybe(0), position_y.fromMaybe(0));
215 params.device_scale_factor = device_scale_factor; 216 params.device_scale_factor = device_scale_factor;
216 params.view_size = blink::WebSize(width, height); 217 params.view_size = blink::WebSize(width, height);
217 params.fit_to_view = fit_window; 218 params.fit_to_view = fit_window;
218 params.scale = scale.fromMaybe(1); 219 params.scale = scale.fromMaybe(1);
219 params.screen_orientation_type = orientationType; 220 params.screen_orientation_type = orientation_type;
220 params.screen_orientation_angle = orientationAngle; 221 params.screen_orientation_angle = orientation_angle;
222 params.override_gutter_color =
223 override_gutter_color.fromMaybe(true) && (width || height);
221 224
222 if (device_emulation_enabled_ && params == device_emulation_params_) 225 if (device_emulation_enabled_ && params == device_emulation_params_)
223 return Response::OK(); 226 return Response::OK();
224 227
225 device_emulation_enabled_ = true; 228 device_emulation_enabled_ = true;
226 device_emulation_params_ = params; 229 device_emulation_params_ = params;
227 UpdateDeviceEmulationState(); 230 UpdateDeviceEmulationState();
228 return Response::OK(); 231 return Response::OK();
229 } 232 }
230 233
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 widget_host->Send(new ViewMsg_EnableDeviceEmulation( 282 widget_host->Send(new ViewMsg_EnableDeviceEmulation(
280 widget_host->GetRoutingID(), device_emulation_params_)); 283 widget_host->GetRoutingID(), device_emulation_params_));
281 } else { 284 } else {
282 widget_host->Send(new ViewMsg_DisableDeviceEmulation( 285 widget_host->Send(new ViewMsg_DisableDeviceEmulation(
283 widget_host->GetRoutingID())); 286 widget_host->GetRoutingID()));
284 } 287 }
285 } 288 }
286 289
287 } // namespace protocol 290 } // namespace protocol
288 } // namespace content 291 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698