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 const std::vector<ash::DisplayMode>& display_modes = |
287 display_info.display_modes(); | 286 display_info.display_modes(); |
288 for (size_t i = 0; i < display_modes.size(); ++i) { | 287 for (const auto& display_mode : display_modes) { |
oshima
2014/12/10 01:37:26
nit: ash::DisplayMode
Jun Mukai
2014/12/10 01:39:48
Done.
| |
289 js_resolutions->Append( | 288 js_resolutions->Append( |
290 ConvertDisplayModeToValue(display.id(), display_modes[i])); | 289 ConvertDisplayModeToValue(display.id(), display_mode)); |
291 } | 290 } |
292 js_display->Set("resolutions", js_resolutions); | 291 js_display->Set("resolutions", js_resolutions); |
293 | 292 |
294 js_display->SetInteger("colorProfile", display_info.color_profile()); | 293 js_display->SetInteger("colorProfile", display_info.color_profile()); |
295 base::ListValue* available_color_profiles = new base::ListValue(); | 294 base::ListValue* available_color_profiles = new base::ListValue(); |
296 for (size_t i = 0; | 295 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); | 296 const base::string16 profile_name = GetColorProfileName(color_profile); |
301 if (profile_name.empty()) | 297 if (profile_name.empty()) |
302 continue; | 298 continue; |
303 base::DictionaryValue* color_profile_dict = new base::DictionaryValue(); | 299 base::DictionaryValue* color_profile_dict = new base::DictionaryValue(); |
304 color_profile_dict->SetInteger("profileId", color_profile); | 300 color_profile_dict->SetInteger("profileId", color_profile); |
305 color_profile_dict->SetString("name", profile_name); | 301 color_profile_dict->SetString("name", profile_name); |
306 available_color_profiles->Append(color_profile_dict); | 302 available_color_profiles->Append(color_profile_dict); |
307 } | 303 } |
308 js_display->Set("availableColorProfiles", available_color_profiles); | 304 js_display->Set("availableColorProfiles", available_color_profiles); |
309 js_displays.Append(js_display); | 305 js_displays.Append(js_display); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
384 static_cast<int>(offset))); | 380 static_cast<int>(offset))); |
385 } | 381 } |
386 | 382 |
387 void DisplayOptionsHandler::HandleSetDisplayMode(const base::ListValue* args) { | 383 void DisplayOptionsHandler::HandleSetDisplayMode(const base::ListValue* args) { |
388 DCHECK(!args->empty()); | 384 DCHECK(!args->empty()); |
389 | 385 |
390 int64 display_id = GetDisplayId(args); | 386 int64 display_id = GetDisplayId(args); |
391 if (display_id == gfx::Display::kInvalidDisplayID) | 387 if (display_id == gfx::Display::kInvalidDisplayID) |
392 return; | 388 return; |
393 | 389 |
394 const base::DictionaryValue* mode_data = NULL; | 390 const base::DictionaryValue* mode_data = nullptr; |
395 if (!args->GetDictionary(1, &mode_data)) { | 391 if (!args->GetDictionary(1, &mode_data)) { |
396 LOG(ERROR) << "Failed to get mode data"; | 392 LOG(ERROR) << "Failed to get mode data"; |
397 return; | 393 return; |
398 } | 394 } |
399 | 395 |
400 ash::DisplayMode mode; | 396 ash::DisplayMode mode; |
401 if (!ConvertValueToDisplayMode(mode_data, &mode)) | 397 if (!ConvertValueToDisplayMode(mode_data, &mode)) |
402 return; | 398 return; |
403 | 399 |
404 content::RecordAction( | 400 content::RecordAction( |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
464 return; | 460 return; |
465 } | 461 } |
466 | 462 |
467 GetDisplayManager()->SetColorCalibrationProfile( | 463 GetDisplayManager()->SetColorCalibrationProfile( |
468 display_id, static_cast<ui::ColorCalibrationProfile>(profile_id)); | 464 display_id, static_cast<ui::ColorCalibrationProfile>(profile_id)); |
469 SendAllDisplayInfo(); | 465 SendAllDisplayInfo(); |
470 } | 466 } |
471 | 467 |
472 } // namespace options | 468 } // namespace options |
473 } // namespace chromeos | 469 } // namespace chromeos |
OLD | NEW |