| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> |
| 10 #include <string> | 11 #include <string> |
| 12 #include <utility> |
| 11 | 13 |
| 12 #include "ash/common/strings/grit/ash_strings.h" | 14 #include "ash/common/strings/grit/ash_strings.h" |
| 13 #include "ash/display/display_configuration_controller.h" | 15 #include "ash/display/display_configuration_controller.h" |
| 14 #include "ash/display/display_manager.h" | 16 #include "ash/display/display_manager.h" |
| 15 #include "ash/display/resolution_notification_controller.h" | 17 #include "ash/display/resolution_notification_controller.h" |
| 16 #include "ash/display/window_tree_host_manager.h" | 18 #include "ash/display/window_tree_host_manager.h" |
| 17 #include "ash/screen_util.h" | 19 #include "ash/screen_util.h" |
| 18 #include "ash/shell.h" | 20 #include "ash/shell.h" |
| 19 #include "base/bind.h" | 21 #include "base/bind.h" |
| 20 #include "base/command_line.h" | 22 #include "base/command_line.h" |
| 21 #include "base/logging.h" | 23 #include "base/logging.h" |
| 24 #include "base/memory/ptr_util.h" |
| 22 #include "base/strings/string_number_conversions.h" | 25 #include "base/strings/string_number_conversions.h" |
| 23 #include "base/strings/stringprintf.h" | 26 #include "base/strings/stringprintf.h" |
| 24 #include "base/values.h" | 27 #include "base/values.h" |
| 25 #include "chrome/browser/chromeos/display/display_preferences.h" | 28 #include "chrome/browser/chromeos/display/display_preferences.h" |
| 26 #include "chrome/browser/ui/ash/ash_util.h" | 29 #include "chrome/browser/ui/ash/ash_util.h" |
| 27 #include "chrome/grit/generated_resources.h" | 30 #include "chrome/grit/generated_resources.h" |
| 28 #include "chromeos/chromeos_switches.h" | 31 #include "chromeos/chromeos_switches.h" |
| 29 #include "content/public/browser/user_metrics.h" | 32 #include "content/public/browser/user_metrics.h" |
| 30 #include "content/public/browser/web_ui.h" | 33 #include "content/public/browser/web_ui.h" |
| 31 #include "ui/base/l10n/l10n_util.h" | 34 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 display_mode = ash::DisplayManager::UNIFIED; | 319 display_mode = ash::DisplayManager::UNIFIED; |
| 317 else | 320 else |
| 318 display_mode = ash::DisplayManager::EXTENDED; | 321 display_mode = ash::DisplayManager::EXTENDED; |
| 319 base::FundamentalValue mode(static_cast<int>(display_mode)); | 322 base::FundamentalValue mode(static_cast<int>(display_mode)); |
| 320 | 323 |
| 321 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 324 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| 322 std::unique_ptr<base::ListValue> js_displays(new base::ListValue); | 325 std::unique_ptr<base::ListValue> js_displays(new base::ListValue); |
| 323 for (const display::Display& display : displays) { | 326 for (const display::Display& display : displays) { |
| 324 const display::ManagedDisplayInfo& display_info = | 327 const display::ManagedDisplayInfo& display_info = |
| 325 display_manager->GetDisplayInfo(display.id()); | 328 display_manager->GetDisplayInfo(display.id()); |
| 326 base::DictionaryValue* js_display = new base::DictionaryValue(); | 329 auto js_display = base::MakeUnique<base::DictionaryValue>(); |
| 327 js_display->SetString("id", base::Int64ToString(display.id())); | 330 js_display->SetString("id", base::Int64ToString(display.id())); |
| 328 js_display->SetString("name", | 331 js_display->SetString("name", |
| 329 display_manager->GetDisplayNameForId(display.id())); | 332 display_manager->GetDisplayNameForId(display.id())); |
| 330 base::DictionaryValue* display_bounds = | 333 base::DictionaryValue* display_bounds = |
| 331 ConvertBoundsToValue(display.bounds()); | 334 ConvertBoundsToValue(display.bounds()); |
| 332 js_display->Set("bounds", display_bounds); | 335 js_display->Set("bounds", display_bounds); |
| 333 js_display->SetBoolean("isPrimary", display.id() == primary_id); | 336 js_display->SetBoolean("isPrimary", display.id() == primary_id); |
| 334 js_display->SetBoolean("isInternal", display.IsInternal()); | 337 js_display->SetBoolean("isInternal", display.IsInternal()); |
| 335 js_display->SetInteger("rotation", display.RotationAsDegree()); | 338 js_display->SetInteger("rotation", display.RotationAsDegree()); |
| 336 | 339 |
| 337 base::ListValue* js_resolutions = new base::ListValue(); | 340 base::ListValue* js_resolutions = new base::ListValue(); |
| 338 for (const scoped_refptr<display::ManagedDisplayMode>& display_mode : | 341 for (const scoped_refptr<display::ManagedDisplayMode>& display_mode : |
| 339 display_info.display_modes()) { | 342 display_info.display_modes()) { |
| 340 js_resolutions->Append( | 343 js_resolutions->Append( |
| 341 ConvertDisplayModeToValue(display.id(), display_mode)); | 344 ConvertDisplayModeToValue(display.id(), display_mode)); |
| 342 } | 345 } |
| 343 js_display->Set("resolutions", js_resolutions); | 346 js_display->Set("resolutions", js_resolutions); |
| 344 | 347 |
| 345 js_display->SetInteger("colorProfileId", display_info.color_profile()); | 348 js_display->SetInteger("colorProfileId", display_info.color_profile()); |
| 346 base::ListValue* available_color_profiles = new base::ListValue(); | 349 base::ListValue* available_color_profiles = new base::ListValue(); |
| 347 for (const auto& color_profile : display_info.available_color_profiles()) { | 350 for (const auto& color_profile : display_info.available_color_profiles()) { |
| 348 const base::string16 profile_name = GetColorProfileName(color_profile); | 351 const base::string16 profile_name = GetColorProfileName(color_profile); |
| 349 if (profile_name.empty()) | 352 if (profile_name.empty()) |
| 350 continue; | 353 continue; |
| 351 base::DictionaryValue* color_profile_dict = new base::DictionaryValue(); | 354 auto color_profile_dict = base::MakeUnique<base::DictionaryValue>(); |
| 352 color_profile_dict->SetInteger("profileId", color_profile); | 355 color_profile_dict->SetInteger("profileId", color_profile); |
| 353 color_profile_dict->SetString("name", profile_name); | 356 color_profile_dict->SetString("name", profile_name); |
| 354 available_color_profiles->Append(color_profile_dict); | 357 available_color_profiles->Append(std::move(color_profile_dict)); |
| 355 } | 358 } |
| 356 js_display->Set("availableColorProfiles", available_color_profiles); | 359 js_display->Set("availableColorProfiles", available_color_profiles); |
| 357 | 360 |
| 358 if (display_manager->GetNumDisplays() > 1) { | 361 if (display_manager->GetNumDisplays() > 1) { |
| 359 const display::DisplayPlacement placement = | 362 const display::DisplayPlacement placement = |
| 360 display_manager->GetCurrentDisplayLayout().FindPlacementById( | 363 display_manager->GetCurrentDisplayLayout().FindPlacementById( |
| 361 display.id()); | 364 display.id()); |
| 362 if (placement.display_id != display::Display::kInvalidDisplayID) { | 365 if (placement.display_id != display::Display::kInvalidDisplayID) { |
| 363 js_display->SetString( | 366 js_display->SetString( |
| 364 "parentId", base::Int64ToString(placement.parent_display_id)); | 367 "parentId", base::Int64ToString(placement.parent_display_id)); |
| 365 js_display->SetInteger("layoutType", placement.position); | 368 js_display->SetInteger("layoutType", placement.position); |
| 366 js_display->SetInteger("offset", placement.offset); | 369 js_display->SetInteger("offset", placement.offset); |
| 367 } | 370 } |
| 368 } | 371 } |
| 369 | 372 |
| 370 js_displays->Append(js_display); | 373 js_displays->Append(std::move(js_display)); |
| 371 } | 374 } |
| 372 | 375 |
| 373 web_ui()->CallJavascriptFunctionUnsafe( | 376 web_ui()->CallJavascriptFunctionUnsafe( |
| 374 "options.DisplayOptions.setDisplayInfo", mode, *js_displays); | 377 "options.DisplayOptions.setDisplayInfo", mode, *js_displays); |
| 375 } | 378 } |
| 376 | 379 |
| 377 void DisplayOptionsHandler::UpdateDisplaySettingsEnabled() { | 380 void DisplayOptionsHandler::UpdateDisplaySettingsEnabled() { |
| 378 // TODO(mash) Support Chrome display settings in Mash. crbug.com/548429 | 381 // TODO(mash) Support Chrome display settings in Mash. crbug.com/548429 |
| 379 if (chrome::IsRunningInMash()) | 382 if (chrome::IsRunningInMash()) |
| 380 return; | 383 return; |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 bool enable = false; | 579 bool enable = false; |
| 577 if (!args->GetBoolean(0, &enable)) | 580 if (!args->GetBoolean(0, &enable)) |
| 578 NOTREACHED(); | 581 NOTREACHED(); |
| 579 | 582 |
| 580 GetDisplayManager()->SetDefaultMultiDisplayModeForCurrentDisplays( | 583 GetDisplayManager()->SetDefaultMultiDisplayModeForCurrentDisplays( |
| 581 enable ? ash::DisplayManager::UNIFIED : ash::DisplayManager::EXTENDED); | 584 enable ? ash::DisplayManager::UNIFIED : ash::DisplayManager::EXTENDED); |
| 582 } | 585 } |
| 583 | 586 |
| 584 } // namespace options | 587 } // namespace options |
| 585 } // namespace chromeos | 588 } // namespace chromeos |
| OLD | NEW |