Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/extensions/display_info_provider_chromeos.h" | 5 #include "chrome/browser/extensions/display_info_provider_chromeos.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | 9 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
| 10 #include "ash/display/display_configuration_controller.h" | 10 #include "ash/display/display_configuration_controller.h" |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 234 // error message. | 234 // error message. |
| 235 bool ValidateParamsForDisplay(const system_display::DisplayProperties& info, | 235 bool ValidateParamsForDisplay(const system_display::DisplayProperties& info, |
| 236 const display::Display& display, | 236 const display::Display& display, |
| 237 display::DisplayManager* display_manager, | 237 display::DisplayManager* display_manager, |
| 238 int64_t primary_display_id, | 238 int64_t primary_display_id, |
| 239 std::string* error) { | 239 std::string* error) { |
| 240 int64_t id = display.id(); | 240 int64_t id = display.id(); |
| 241 bool is_primary = | 241 bool is_primary = |
| 242 id == primary_display_id || (info.is_primary && *info.is_primary); | 242 id == primary_display_id || (info.is_primary && *info.is_primary); |
| 243 | 243 |
| 244 if (info.is_unified) { | |
| 245 if (!is_primary) { | |
| 246 *error = "Unified desktop mode can only be set for the primary display."; | |
| 247 return false; | |
| 248 } | |
| 249 if (info.mirroring_source_id) { | |
| 250 *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
| |
| 251 return false; | |
| 252 } | |
| 253 return true; | |
| 254 } | |
| 255 | |
| 244 // If mirroring source id is set, a display with the given id should exist, | 256 // If mirroring source id is set, a display with the given id should exist, |
| 245 // and if should not be the same as the target display's id. | 257 // and if should not be the same as the target display's id. |
| 246 if (info.mirroring_source_id && !info.mirroring_source_id->empty()) { | 258 if (info.mirroring_source_id && !info.mirroring_source_id->empty()) { |
| 247 int64_t mirroring_id = GetDisplay(*info.mirroring_source_id).id(); | 259 int64_t mirroring_id = GetDisplay(*info.mirroring_source_id).id(); |
| 248 if (mirroring_id == display::kInvalidDisplayId) { | 260 if (mirroring_id == display::kInvalidDisplayId) { |
| 249 *error = "Display " + *info.mirroring_source_id + " not found."; | 261 *error = "Display " + *info.mirroring_source_id + " not found."; |
| 250 return false; | 262 return false; |
| 251 } | 263 } |
| 252 | 264 |
| 253 if (*info.mirroring_source_id == base::Int64ToString(id)) { | 265 if (*info.mirroring_source_id == base::Int64ToString(id)) { |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 452 bool DisplayInfoProviderChromeOS::SetInfo( | 464 bool DisplayInfoProviderChromeOS::SetInfo( |
| 453 const std::string& display_id_str, | 465 const std::string& display_id_str, |
| 454 const system_display::DisplayProperties& info, | 466 const system_display::DisplayProperties& info, |
| 455 std::string* error) { | 467 std::string* error) { |
| 456 if (ash_util::IsRunningInMash()) { | 468 if (ash_util::IsRunningInMash()) { |
| 457 // TODO(crbug.com/682402): Mash support. | 469 // TODO(crbug.com/682402): Mash support. |
| 458 NOTIMPLEMENTED(); | 470 NOTIMPLEMENTED(); |
| 459 *error = "Not implemented for mash."; | 471 *error = "Not implemented for mash."; |
| 460 return false; | 472 return false; |
| 461 } | 473 } |
| 474 | |
| 462 display::DisplayManager* display_manager = | 475 display::DisplayManager* display_manager = |
| 463 ash::Shell::GetInstance()->display_manager(); | 476 ash::Shell::GetInstance()->display_manager(); |
| 464 ash::DisplayConfigurationController* display_configuration_controller = | 477 ash::DisplayConfigurationController* display_configuration_controller = |
| 465 ash::Shell::GetInstance()->display_configuration_controller(); | 478 ash::Shell::GetInstance()->display_configuration_controller(); |
| 466 | 479 |
| 467 const display::Display target = GetDisplay(display_id_str); | 480 const display::Display target = GetDisplay(display_id_str); |
| 468 | 481 |
| 469 if (target.id() == display::kInvalidDisplayId) { | 482 if (target.id() == display::kInvalidDisplayId) { |
| 470 *error = "Display not found:" + display_id_str; | 483 *error = "Display not found:" + display_id_str; |
| 471 return false; | 484 return false; |
| 472 } | 485 } |
| 473 | 486 |
| 474 int64_t display_id = target.id(); | 487 int64_t display_id = target.id(); |
| 475 const display::Display& primary = | 488 const display::Display& primary = |
| 476 display::Screen::GetScreen()->GetPrimaryDisplay(); | 489 display::Screen::GetScreen()->GetPrimaryDisplay(); |
| 477 | 490 |
| 478 if (!ValidateParamsForDisplay(info, target, display_manager, primary.id(), | 491 if (!ValidateParamsForDisplay(info, target, display_manager, primary.id(), |
| 479 error)) { | 492 error)) { |
| 480 return false; | 493 return false; |
| 481 } | 494 } |
| 482 | 495 |
| 496 // Process 'isUnified' parameter if set. | |
| 497 if (info.is_unified) { | |
| 498 display_manager->SetDefaultMultiDisplayModeForCurrentDisplays( | |
| 499 *info.is_unified ? display::DisplayManager::UNIFIED | |
| 500 : display::DisplayManager::EXTENDED); | |
| 501 } | |
| 502 | |
| 483 // Process 'isPrimary' parameter. | 503 // Process 'isPrimary' parameter. |
| 484 if (info.is_primary && *info.is_primary && target.id() != primary.id()) | 504 if (info.is_primary && *info.is_primary && target.id() != primary.id()) |
| 485 display_configuration_controller->SetPrimaryDisplayId(display_id); | 505 display_configuration_controller->SetPrimaryDisplayId(display_id); |
| 486 | 506 |
| 487 // Process 'mirroringSourceId' parameter. | 507 // Process 'mirroringSourceId' parameter. |
| 488 if (info.mirroring_source_id) { | 508 if (info.mirroring_source_id) { |
| 489 bool mirror = !info.mirroring_source_id->empty(); | 509 bool mirror = !info.mirroring_source_id->empty(); |
| 490 display_configuration_controller->SetMirrorMode(mirror); | 510 display_configuration_controller->SetMirrorMode(mirror); |
| 491 } | 511 } |
| 492 | 512 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 617 if (ash_util::IsRunningInMash()) { | 637 if (ash_util::IsRunningInMash()) { |
| 618 // TODO(crbug.com/682402): Mash support. | 638 // TODO(crbug.com/682402): Mash support. |
| 619 NOTIMPLEMENTED(); | 639 NOTIMPLEMENTED(); |
| 620 return; | 640 return; |
| 621 } | 641 } |
| 622 ash::Shell::GetInstance()->display_manager()->SetUnifiedDesktopEnabled( | 642 ash::Shell::GetInstance()->display_manager()->SetUnifiedDesktopEnabled( |
| 623 enable); | 643 enable); |
| 624 } | 644 } |
| 625 | 645 |
| 626 DisplayInfoProvider::DisplayUnitInfoList | 646 DisplayInfoProvider::DisplayUnitInfoList |
| 627 DisplayInfoProviderChromeOS::GetAllDisplaysInfo() { | 647 DisplayInfoProviderChromeOS::GetAllDisplaysInfo(bool single_unified) { |
| 628 if (ash_util::IsRunningInMash()) { | 648 if (ash_util::IsRunningInMash()) { |
| 629 // TODO(crbug.com/682402): Mash support. | 649 // TODO(crbug.com/682402): Mash support. |
| 630 NOTIMPLEMENTED(); | 650 NOTIMPLEMENTED(); |
| 631 return DisplayInfoProvider::DisplayUnitInfoList(); | 651 return DisplayInfoProvider::DisplayUnitInfoList(); |
| 632 } | 652 } |
| 633 display::DisplayManager* display_manager = | 653 display::DisplayManager* display_manager = |
| 634 ash::Shell::GetInstance()->display_manager(); | 654 ash::Shell::GetInstance()->display_manager(); |
| 655 | |
| 635 if (!display_manager->IsInUnifiedMode()) | 656 if (!display_manager->IsInUnifiedMode()) |
| 636 return DisplayInfoProvider::GetAllDisplaysInfo(); | 657 return DisplayInfoProvider::GetAllDisplaysInfo(single_unified); |
| 637 | 658 |
| 638 std::vector<display::Display> displays = | 659 // Chrome OS specific: get displays for unified mode. |
| 639 display_manager->software_mirroring_display_list(); | 660 std::vector<display::Display> displays; |
| 640 CHECK_GT(displays.size(), 0u); | 661 int64_t primary_id; |
| 662 if (single_unified) { | |
| 663 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) | |
| 664 displays.push_back(display_manager->GetDisplayAt(i)); | |
| 665 primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | |
| 666 } else { | |
| 667 displays = display_manager->software_mirroring_display_list(); | |
| 668 CHECK_GT(displays.size(), 0u); | |
| 669 // Use first display as primary. | |
| 670 primary_id = displays[0].id(); | |
| 671 } | |
| 641 | 672 |
| 642 // Use first display as primary. | |
| 643 int64_t primary_id = displays[0].id(); | |
| 644 DisplayUnitInfoList all_displays; | 673 DisplayUnitInfoList all_displays; |
| 645 for (const display::Display& display : displays) { | 674 for (const display::Display& display : displays) { |
| 646 system_display::DisplayUnitInfo unit = | 675 system_display::DisplayUnitInfo unit_info = |
| 647 CreateDisplayUnitInfo(display, primary_id); | 676 CreateDisplayUnitInfo(display, primary_id); |
| 648 UpdateDisplayUnitInfoForPlatform(display, &unit); | 677 UpdateDisplayUnitInfoForPlatform(display, &unit_info); |
| 649 all_displays.push_back(std::move(unit)); | 678 unit_info.is_unified = true; |
| 679 all_displays.push_back(std::move(unit_info)); | |
| 650 } | 680 } |
| 651 return all_displays; | 681 return all_displays; |
| 652 } | 682 } |
| 653 | 683 |
| 654 DisplayInfoProvider::DisplayLayoutList | 684 DisplayInfoProvider::DisplayLayoutList |
| 655 DisplayInfoProviderChromeOS::GetDisplayLayout() { | 685 DisplayInfoProviderChromeOS::GetDisplayLayout() { |
| 656 if (ash_util::IsRunningInMash()) { | 686 if (ash_util::IsRunningInMash()) { |
| 657 // TODO(crbug.com/682402): Mash support. | 687 // TODO(crbug.com/682402): Mash support. |
| 658 NOTIMPLEMENTED(); | 688 NOTIMPLEMENTED(); |
| 659 return DisplayInfoProvider::DisplayLayoutList(); | 689 return DisplayInfoProvider::DisplayLayoutList(); |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 896 touch_calibrator_.reset(new chromeos::TouchCalibratorController); | 926 touch_calibrator_.reset(new chromeos::TouchCalibratorController); |
| 897 return touch_calibrator_.get(); | 927 return touch_calibrator_.get(); |
| 898 } | 928 } |
| 899 | 929 |
| 900 // static | 930 // static |
| 901 DisplayInfoProvider* DisplayInfoProvider::Create() { | 931 DisplayInfoProvider* DisplayInfoProvider::Create() { |
| 902 return new DisplayInfoProviderChromeOS(); | 932 return new DisplayInfoProviderChromeOS(); |
| 903 } | 933 } |
| 904 | 934 |
| 905 } // namespace extensions | 935 } // namespace extensions |
| OLD | NEW |