Chromium Code Reviews| Index: chrome/browser/extensions/display_info_provider_chromeos.cc |
| diff --git a/chrome/browser/extensions/display_info_provider_chromeos.cc b/chrome/browser/extensions/display_info_provider_chromeos.cc |
| index a5a37a74f93a246a19855aaf45ad1c1d57b846b3..bc480cdec6281cc7bf491ded56a949560cd71bda 100644 |
| --- a/chrome/browser/extensions/display_info_provider_chromeos.cc |
| +++ b/chrome/browser/extensions/display_info_provider_chromeos.cc |
| @@ -241,6 +241,18 @@ bool ValidateParamsForDisplay(const system_display::DisplayProperties& info, |
| bool is_primary = |
| id == primary_display_id || (info.is_primary && *info.is_primary); |
| + if (info.is_unified) { |
| + if (!is_primary) { |
| + *error = "Unified desktop mode can only be set for the primary display."; |
| + return false; |
| + } |
| + if (info.mirroring_source_id) { |
| + *error = "Unified desktop mode can not be set with mirroringSourceId."; |
|
malaykeshav
2017/04/11 17:29:12
What does this error mean?
It cannot be set when
stevenjb
2017/04/11 17:34:38
We disallow setting both 'is_unified' and 'mirrori
|
| + return false; |
| + } |
| + return true; |
| + } |
| + |
| // If mirroring source id is set, a display with the given id should exist, |
| // and if should not be the same as the target display's id. |
| if (info.mirroring_source_id && !info.mirroring_source_id->empty()) { |
| @@ -459,6 +471,7 @@ bool DisplayInfoProviderChromeOS::SetInfo( |
| *error = "Not implemented for mash."; |
| return false; |
| } |
| + |
| display::DisplayManager* display_manager = |
| ash::Shell::GetInstance()->display_manager(); |
| ash::DisplayConfigurationController* display_configuration_controller = |
| @@ -480,6 +493,13 @@ bool DisplayInfoProviderChromeOS::SetInfo( |
| return false; |
| } |
| + // Process 'isUnified' parameter if set. |
| + if (info.is_unified) { |
| + display_manager->SetDefaultMultiDisplayModeForCurrentDisplays( |
| + *info.is_unified ? display::DisplayManager::UNIFIED |
| + : display::DisplayManager::EXTENDED); |
| + } |
| + |
| // Process 'isPrimary' parameter. |
| if (info.is_primary && *info.is_primary && target.id() != primary.id()) |
| display_configuration_controller->SetPrimaryDisplayId(display_id); |
| @@ -624,7 +644,7 @@ void DisplayInfoProviderChromeOS::EnableUnifiedDesktop(bool enable) { |
| } |
| DisplayInfoProvider::DisplayUnitInfoList |
| -DisplayInfoProviderChromeOS::GetAllDisplaysInfo() { |
| +DisplayInfoProviderChromeOS::GetAllDisplaysInfo(bool single_unified) { |
| if (ash_util::IsRunningInMash()) { |
| // TODO(crbug.com/682402): Mash support. |
| NOTIMPLEMENTED(); |
| @@ -632,21 +652,31 @@ DisplayInfoProviderChromeOS::GetAllDisplaysInfo() { |
| } |
| display::DisplayManager* display_manager = |
| ash::Shell::GetInstance()->display_manager(); |
| - if (!display_manager->IsInUnifiedMode()) |
| - return DisplayInfoProvider::GetAllDisplaysInfo(); |
| - std::vector<display::Display> displays = |
| - display_manager->software_mirroring_display_list(); |
| - CHECK_GT(displays.size(), 0u); |
| + if (!display_manager->IsInUnifiedMode()) |
| + return DisplayInfoProvider::GetAllDisplaysInfo(single_unified); |
| + |
| + // Chrome OS specific: get displays for unified mode. |
| + std::vector<display::Display> displays; |
| + int64_t primary_id; |
| + if (single_unified) { |
| + for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) |
| + displays.push_back(display_manager->GetDisplayAt(i)); |
| + primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| + } else { |
| + displays = display_manager->software_mirroring_display_list(); |
| + CHECK_GT(displays.size(), 0u); |
| + // Use first display as primary. |
| + primary_id = displays[0].id(); |
| + } |
| - // Use first display as primary. |
| - int64_t primary_id = displays[0].id(); |
| DisplayUnitInfoList all_displays; |
| for (const display::Display& display : displays) { |
| - system_display::DisplayUnitInfo unit = |
| + system_display::DisplayUnitInfo unit_info = |
| CreateDisplayUnitInfo(display, primary_id); |
| - UpdateDisplayUnitInfoForPlatform(display, &unit); |
| - all_displays.push_back(std::move(unit)); |
| + UpdateDisplayUnitInfoForPlatform(display, &unit_info); |
| + unit_info.is_unified = true; |
| + all_displays.push_back(std::move(unit_info)); |
| } |
| return all_displays; |
| } |