OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ui/webui/options/chromeos/display_options_handler.h" | 5 #include "chrome/browser/ui/webui/options/chromeos/display_options_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "ash/display/display_configurator_animation.h" | 9 #include "ash/display/display_configurator_animation.h" |
10 #include "ash/display/display_controller.h" | 10 #include "ash/display/display_controller.h" |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 SendDisplayInfo(displays); | 257 SendDisplayInfo(displays); |
258 } | 258 } |
259 | 259 |
260 void DisplayOptionsHandler::SendDisplayInfo( | 260 void DisplayOptionsHandler::SendDisplayInfo( |
261 const std::vector<gfx::Display>& displays) { | 261 const std::vector<gfx::Display>& displays) { |
262 DisplayManager* display_manager = GetDisplayManager(); | 262 DisplayManager* display_manager = GetDisplayManager(); |
263 base::FundamentalValue mirroring(display_manager->IsMirrored()); | 263 base::FundamentalValue mirroring(display_manager->IsMirrored()); |
264 | 264 |
265 int64 primary_id = ash::Shell::GetScreen()->GetPrimaryDisplay().id(); | 265 int64 primary_id = ash::Shell::GetScreen()->GetPrimaryDisplay().id(); |
266 base::ListValue js_displays; | 266 base::ListValue js_displays; |
267 for (size_t i = 0; i < displays.size(); ++i) { | 267 for (const gfx::Display& display : displays) { |
268 const gfx::Display& display = displays[i]; | |
269 const ash::DisplayInfo& display_info = | 268 const ash::DisplayInfo& display_info = |
270 display_manager->GetDisplayInfo(display.id()); | 269 display_manager->GetDisplayInfo(display.id()); |
271 const gfx::Rect& bounds = display.bounds(); | 270 const gfx::Rect& bounds = display.bounds(); |
272 base::DictionaryValue* js_display = new base::DictionaryValue(); | 271 base::DictionaryValue* js_display = new base::DictionaryValue(); |
273 js_display->SetString("id", base::Int64ToString(display.id())); | 272 js_display->SetString("id", base::Int64ToString(display.id())); |
274 js_display->SetInteger("x", bounds.x()); | 273 js_display->SetInteger("x", bounds.x()); |
275 js_display->SetInteger("y", bounds.y()); | 274 js_display->SetInteger("y", bounds.y()); |
276 js_display->SetInteger("width", bounds.width()); | 275 js_display->SetInteger("width", bounds.width()); |
277 js_display->SetInteger("height", bounds.height()); | 276 js_display->SetInteger("height", bounds.height()); |
278 js_display->SetString("name", | 277 js_display->SetString("name", |
279 display_manager->GetDisplayNameForId(display.id())); | 278 display_manager->GetDisplayNameForId(display.id())); |
280 js_display->SetBoolean("isPrimary", display.id() == primary_id); | 279 js_display->SetBoolean("isPrimary", display.id() == primary_id); |
281 js_display->SetBoolean("isInternal", display.IsInternal()); | 280 js_display->SetBoolean("isInternal", display.IsInternal()); |
282 js_display->SetInteger("orientation", | 281 js_display->SetInteger("orientation", |
283 static_cast<int>(display_info.rotation())); | 282 static_cast<int>(display_info.rotation())); |
284 | 283 |
285 base::ListValue* js_resolutions = new base::ListValue(); | 284 base::ListValue* js_resolutions = new base::ListValue(); |
286 const std::vector<ash::DisplayMode>& display_modes = | 285 for (const ash::DisplayMode& display_mode : display_info.display_modes()) { |
287 display_info.display_modes(); | |
288 for (size_t i = 0; i < display_modes.size(); ++i) { | |
289 js_resolutions->Append( | 286 js_resolutions->Append( |
290 ConvertDisplayModeToValue(display.id(), display_modes[i])); | 287 ConvertDisplayModeToValue(display.id(), display_mode)); |
291 } | 288 } |
292 js_display->Set("resolutions", js_resolutions); | 289 js_display->Set("resolutions", js_resolutions); |
293 | 290 |
294 js_display->SetInteger("colorProfile", display_info.color_profile()); | 291 js_display->SetInteger("colorProfile", display_info.color_profile()); |
295 base::ListValue* available_color_profiles = new base::ListValue(); | 292 base::ListValue* available_color_profiles = new base::ListValue(); |
296 for (size_t i = 0; | 293 for (const auto& color_profile : display_info.available_color_profiles()) { |
297 i < display_info.available_color_profiles().size(); ++i) { | |
298 ui::ColorCalibrationProfile color_profile = | |
299 display_info.available_color_profiles()[i]; | |
300 const base::string16 profile_name = GetColorProfileName(color_profile); | 294 const base::string16 profile_name = GetColorProfileName(color_profile); |
301 if (profile_name.empty()) | 295 if (profile_name.empty()) |
302 continue; | 296 continue; |
303 base::DictionaryValue* color_profile_dict = new base::DictionaryValue(); | 297 base::DictionaryValue* color_profile_dict = new base::DictionaryValue(); |
304 color_profile_dict->SetInteger("profileId", color_profile); | 298 color_profile_dict->SetInteger("profileId", color_profile); |
305 color_profile_dict->SetString("name", profile_name); | 299 color_profile_dict->SetString("name", profile_name); |
306 available_color_profiles->Append(color_profile_dict); | 300 available_color_profiles->Append(color_profile_dict); |
307 } | 301 } |
308 js_display->Set("availableColorProfiles", available_color_profiles); | 302 js_display->Set("availableColorProfiles", available_color_profiles); |
309 js_displays.Append(js_display); | 303 js_displays.Append(js_display); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 static_cast<int>(offset))); | 378 static_cast<int>(offset))); |
385 } | 379 } |
386 | 380 |
387 void DisplayOptionsHandler::HandleSetDisplayMode(const base::ListValue* args) { | 381 void DisplayOptionsHandler::HandleSetDisplayMode(const base::ListValue* args) { |
388 DCHECK(!args->empty()); | 382 DCHECK(!args->empty()); |
389 | 383 |
390 int64 display_id = GetDisplayId(args); | 384 int64 display_id = GetDisplayId(args); |
391 if (display_id == gfx::Display::kInvalidDisplayID) | 385 if (display_id == gfx::Display::kInvalidDisplayID) |
392 return; | 386 return; |
393 | 387 |
394 const base::DictionaryValue* mode_data = NULL; | 388 const base::DictionaryValue* mode_data = nullptr; |
395 if (!args->GetDictionary(1, &mode_data)) { | 389 if (!args->GetDictionary(1, &mode_data)) { |
396 LOG(ERROR) << "Failed to get mode data"; | 390 LOG(ERROR) << "Failed to get mode data"; |
397 return; | 391 return; |
398 } | 392 } |
399 | 393 |
400 ash::DisplayMode mode; | 394 ash::DisplayMode mode; |
401 if (!ConvertValueToDisplayMode(mode_data, &mode)) | 395 if (!ConvertValueToDisplayMode(mode_data, &mode)) |
402 return; | 396 return; |
403 | 397 |
404 content::RecordAction( | 398 content::RecordAction( |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 return; | 458 return; |
465 } | 459 } |
466 | 460 |
467 GetDisplayManager()->SetColorCalibrationProfile( | 461 GetDisplayManager()->SetColorCalibrationProfile( |
468 display_id, static_cast<ui::ColorCalibrationProfile>(profile_id)); | 462 display_id, static_cast<ui::ColorCalibrationProfile>(profile_id)); |
469 SendAllDisplayInfo(); | 463 SendAllDisplayInfo(); |
470 } | 464 } |
471 | 465 |
472 } // namespace options | 466 } // namespace options |
473 } // namespace chromeos | 467 } // namespace chromeos |
OLD | NEW |