| 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/display/display_configuration_controller.h" | 9 #include "ash/display/display_configuration_controller.h" |
| 10 #include "ash/display/resolution_notification_controller.h" | 10 #include "ash/display/resolution_notification_controller.h" |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 "Another touch calibration is already active."; | 438 "Another touch calibration is already active."; |
| 439 | 439 |
| 440 DisplayInfoProviderChromeOS::DisplayInfoProviderChromeOS() {} | 440 DisplayInfoProviderChromeOS::DisplayInfoProviderChromeOS() {} |
| 441 | 441 |
| 442 DisplayInfoProviderChromeOS::~DisplayInfoProviderChromeOS() {} | 442 DisplayInfoProviderChromeOS::~DisplayInfoProviderChromeOS() {} |
| 443 | 443 |
| 444 bool DisplayInfoProviderChromeOS::SetInfo( | 444 bool DisplayInfoProviderChromeOS::SetInfo( |
| 445 const std::string& display_id_str, | 445 const std::string& display_id_str, |
| 446 const system_display::DisplayProperties& info, | 446 const system_display::DisplayProperties& info, |
| 447 std::string* error) { | 447 std::string* error) { |
| 448 if (ash_util::IsRunningInMash()) { | 448 if (IsRunningInMash()) { |
| 449 // TODO(crbug.com/682402): Mash support. | 449 // TODO(crbug.com/682402): Mash support. |
| 450 NOTIMPLEMENTED(); | 450 NOTIMPLEMENTED(); |
| 451 *error = "Not implemented for mash."; | 451 *error = "Not implemented for mash."; |
| 452 return false; | 452 return false; |
| 453 } | 453 } |
| 454 display::DisplayManager* display_manager = | 454 display::DisplayManager* display_manager = |
| 455 ash::Shell::GetInstance()->display_manager(); | 455 ash::Shell::GetInstance()->display_manager(); |
| 456 ash::DisplayConfigurationController* display_configuration_controller = | 456 ash::DisplayConfigurationController* display_configuration_controller = |
| 457 ash::Shell::GetInstance()->display_configuration_controller(); | 457 ash::Shell::GetInstance()->display_configuration_controller(); |
| 458 | 458 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 new_bounds_origin.y() - target.bounds().y()); | 512 new_bounds_origin.y() - target.bounds().y()); |
| 513 UpdateDisplayLayout(primary.bounds(), primary.id(), target_bounds, | 513 UpdateDisplayLayout(primary.bounds(), primary.id(), target_bounds, |
| 514 target.id()); | 514 target.id()); |
| 515 } | 515 } |
| 516 | 516 |
| 517 return true; | 517 return true; |
| 518 } | 518 } |
| 519 | 519 |
| 520 bool DisplayInfoProviderChromeOS::SetDisplayLayout( | 520 bool DisplayInfoProviderChromeOS::SetDisplayLayout( |
| 521 const DisplayLayoutList& layouts) { | 521 const DisplayLayoutList& layouts) { |
| 522 if (ash_util::IsRunningInMash()) { | 522 if (IsRunningInMash()) { |
| 523 // TODO(crbug.com/682402): Mash support. | 523 // TODO(crbug.com/682402): Mash support. |
| 524 NOTIMPLEMENTED(); | 524 NOTIMPLEMENTED(); |
| 525 return false; | 525 return false; |
| 526 } | 526 } |
| 527 display::DisplayManager* display_manager = | 527 display::DisplayManager* display_manager = |
| 528 ash::Shell::GetInstance()->display_manager(); | 528 ash::Shell::GetInstance()->display_manager(); |
| 529 display::DisplayLayoutBuilder builder( | 529 display::DisplayLayoutBuilder builder( |
| 530 display_manager->GetCurrentResolvedDisplayLayout()); | 530 display_manager->GetCurrentResolvedDisplayLayout()); |
| 531 | 531 |
| 532 bool have_root = false; | 532 bool have_root = false; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 559 } | 559 } |
| 560 ash::Shell::GetInstance() | 560 ash::Shell::GetInstance() |
| 561 ->display_configuration_controller() | 561 ->display_configuration_controller() |
| 562 ->SetDisplayLayout(std::move(layout), true /* user_action */); | 562 ->SetDisplayLayout(std::move(layout), true /* user_action */); |
| 563 return true; | 563 return true; |
| 564 } | 564 } |
| 565 | 565 |
| 566 void DisplayInfoProviderChromeOS::UpdateDisplayUnitInfoForPlatform( | 566 void DisplayInfoProviderChromeOS::UpdateDisplayUnitInfoForPlatform( |
| 567 const display::Display& display, | 567 const display::Display& display, |
| 568 system_display::DisplayUnitInfo* unit) { | 568 system_display::DisplayUnitInfo* unit) { |
| 569 if (ash_util::IsRunningInMash()) { | 569 if (IsRunningInMash()) { |
| 570 // TODO(crbug.com/682402): Mash support. | 570 // TODO(crbug.com/682402): Mash support. |
| 571 NOTIMPLEMENTED(); | 571 NOTIMPLEMENTED(); |
| 572 return; | 572 return; |
| 573 } | 573 } |
| 574 display::DisplayManager* display_manager = | 574 display::DisplayManager* display_manager = |
| 575 ash::Shell::GetInstance()->display_manager(); | 575 ash::Shell::GetInstance()->display_manager(); |
| 576 unit->name = display_manager->GetDisplayNameForId(display.id()); | 576 unit->name = display_manager->GetDisplayNameForId(display.id()); |
| 577 if (display_manager->IsInMirrorMode()) { | 577 if (display_manager->IsInMirrorMode()) { |
| 578 unit->mirroring_source_id = | 578 unit->mirroring_source_id = |
| 579 base::Int64ToString(display_manager->mirroring_display_id()); | 579 base::Int64ToString(display_manager->mirroring_display_id()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 595 unit->overscan.bottom = overscan_insets.bottom(); | 595 unit->overscan.bottom = overscan_insets.bottom(); |
| 596 | 596 |
| 597 for (const scoped_refptr<display::ManagedDisplayMode>& display_mode : | 597 for (const scoped_refptr<display::ManagedDisplayMode>& display_mode : |
| 598 display_info.display_modes()) { | 598 display_info.display_modes()) { |
| 599 unit->modes.push_back( | 599 unit->modes.push_back( |
| 600 GetDisplayMode(display_manager, display_info, display_mode)); | 600 GetDisplayMode(display_manager, display_info, display_mode)); |
| 601 } | 601 } |
| 602 } | 602 } |
| 603 | 603 |
| 604 void DisplayInfoProviderChromeOS::EnableUnifiedDesktop(bool enable) { | 604 void DisplayInfoProviderChromeOS::EnableUnifiedDesktop(bool enable) { |
| 605 if (ash_util::IsRunningInMash()) { | 605 if (IsRunningInMash()) { |
| 606 // TODO(crbug.com/682402): Mash support. | 606 // TODO(crbug.com/682402): Mash support. |
| 607 NOTIMPLEMENTED(); | 607 NOTIMPLEMENTED(); |
| 608 return; | 608 return; |
| 609 } | 609 } |
| 610 ash::Shell::GetInstance()->display_manager()->SetUnifiedDesktopEnabled( | 610 ash::Shell::GetInstance()->display_manager()->SetUnifiedDesktopEnabled( |
| 611 enable); | 611 enable); |
| 612 } | 612 } |
| 613 | 613 |
| 614 DisplayInfoProvider::DisplayUnitInfoList | 614 DisplayInfoProvider::DisplayUnitInfoList |
| 615 DisplayInfoProviderChromeOS::GetAllDisplaysInfo() { | 615 DisplayInfoProviderChromeOS::GetAllDisplaysInfo() { |
| 616 if (ash_util::IsRunningInMash()) { | 616 if (IsRunningInMash()) { |
| 617 // TODO(crbug.com/682402): Mash support. | 617 // TODO(crbug.com/682402): Mash support. |
| 618 NOTIMPLEMENTED(); | 618 NOTIMPLEMENTED(); |
| 619 return DisplayInfoProvider::DisplayUnitInfoList(); | 619 return DisplayInfoProvider::DisplayUnitInfoList(); |
| 620 } | 620 } |
| 621 display::DisplayManager* display_manager = | 621 display::DisplayManager* display_manager = |
| 622 ash::Shell::GetInstance()->display_manager(); | 622 ash::Shell::GetInstance()->display_manager(); |
| 623 if (!display_manager->IsInUnifiedMode()) | 623 if (!display_manager->IsInUnifiedMode()) |
| 624 return DisplayInfoProvider::GetAllDisplaysInfo(); | 624 return DisplayInfoProvider::GetAllDisplaysInfo(); |
| 625 | 625 |
| 626 std::vector<display::Display> displays = | 626 std::vector<display::Display> displays = |
| 627 display_manager->software_mirroring_display_list(); | 627 display_manager->software_mirroring_display_list(); |
| 628 CHECK_GT(displays.size(), 0u); | 628 CHECK_GT(displays.size(), 0u); |
| 629 | 629 |
| 630 // Use first display as primary. | 630 // Use first display as primary. |
| 631 int64_t primary_id = displays[0].id(); | 631 int64_t primary_id = displays[0].id(); |
| 632 DisplayUnitInfoList all_displays; | 632 DisplayUnitInfoList all_displays; |
| 633 for (const display::Display& display : displays) { | 633 for (const display::Display& display : displays) { |
| 634 system_display::DisplayUnitInfo unit = | 634 system_display::DisplayUnitInfo unit = |
| 635 CreateDisplayUnitInfo(display, primary_id); | 635 CreateDisplayUnitInfo(display, primary_id); |
| 636 UpdateDisplayUnitInfoForPlatform(display, &unit); | 636 UpdateDisplayUnitInfoForPlatform(display, &unit); |
| 637 all_displays.push_back(std::move(unit)); | 637 all_displays.push_back(std::move(unit)); |
| 638 } | 638 } |
| 639 return all_displays; | 639 return all_displays; |
| 640 } | 640 } |
| 641 | 641 |
| 642 DisplayInfoProvider::DisplayLayoutList | 642 DisplayInfoProvider::DisplayLayoutList |
| 643 DisplayInfoProviderChromeOS::GetDisplayLayout() { | 643 DisplayInfoProviderChromeOS::GetDisplayLayout() { |
| 644 if (ash_util::IsRunningInMash()) { | 644 if (IsRunningInMash()) { |
| 645 // TODO(crbug.com/682402): Mash support. | 645 // TODO(crbug.com/682402): Mash support. |
| 646 NOTIMPLEMENTED(); | 646 NOTIMPLEMENTED(); |
| 647 return DisplayInfoProvider::DisplayLayoutList(); | 647 return DisplayInfoProvider::DisplayLayoutList(); |
| 648 } | 648 } |
| 649 display::DisplayManager* display_manager = | 649 display::DisplayManager* display_manager = |
| 650 ash::Shell::GetInstance()->display_manager(); | 650 ash::Shell::GetInstance()->display_manager(); |
| 651 | 651 |
| 652 if (display_manager->num_connected_displays() < 2) | 652 if (display_manager->num_connected_displays() < 2) |
| 653 return DisplayInfoProvider::DisplayLayoutList(); | 653 return DisplayInfoProvider::DisplayLayoutList(); |
| 654 | 654 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 667 display_layout.parent_id = base::Int64ToString(placement.parent_display_id); | 667 display_layout.parent_id = base::Int64ToString(placement.parent_display_id); |
| 668 display_layout.position = GetLayoutPosition(placement.position); | 668 display_layout.position = GetLayoutPosition(placement.position); |
| 669 display_layout.offset = placement.offset; | 669 display_layout.offset = placement.offset; |
| 670 result.push_back(std::move(display_layout)); | 670 result.push_back(std::move(display_layout)); |
| 671 } | 671 } |
| 672 return result; | 672 return result; |
| 673 } | 673 } |
| 674 | 674 |
| 675 bool DisplayInfoProviderChromeOS::OverscanCalibrationStart( | 675 bool DisplayInfoProviderChromeOS::OverscanCalibrationStart( |
| 676 const std::string& id) { | 676 const std::string& id) { |
| 677 if (ash_util::IsRunningInMash()) { | 677 if (IsRunningInMash()) { |
| 678 // TODO(crbug.com/682402): Mash support. | 678 // TODO(crbug.com/682402): Mash support. |
| 679 NOTIMPLEMENTED(); | 679 NOTIMPLEMENTED(); |
| 680 return false; | 680 return false; |
| 681 } | 681 } |
| 682 VLOG(1) << "OverscanCalibrationStart: " << id; | 682 VLOG(1) << "OverscanCalibrationStart: " << id; |
| 683 const display::Display display = GetDisplay(id); | 683 const display::Display display = GetDisplay(id); |
| 684 if (display.id() == display::kInvalidDisplayId) | 684 if (display.id() == display::kInvalidDisplayId) |
| 685 return false; | 685 return false; |
| 686 auto insets = | 686 auto insets = |
| 687 ash::Shell::GetInstance()->window_tree_host_manager()->GetOverscanInsets( | 687 ash::Shell::GetInstance()->window_tree_host_manager()->GetOverscanInsets( |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 if (!calibrator) | 721 if (!calibrator) |
| 722 return false; | 722 return false; |
| 723 calibrator->Commit(); | 723 calibrator->Commit(); |
| 724 overscan_calibrators_[id].reset(); | 724 overscan_calibrators_[id].reset(); |
| 725 return true; | 725 return true; |
| 726 } | 726 } |
| 727 | 727 |
| 728 bool DisplayInfoProviderChromeOS::ShowNativeTouchCalibration( | 728 bool DisplayInfoProviderChromeOS::ShowNativeTouchCalibration( |
| 729 const std::string& id, std::string* error, | 729 const std::string& id, std::string* error, |
| 730 const DisplayInfoProvider::TouchCalibrationCallback& callback) { | 730 const DisplayInfoProvider::TouchCalibrationCallback& callback) { |
| 731 if (ash_util::IsRunningInMash()) { | 731 if (IsRunningInMash()) { |
| 732 // TODO(crbug.com/682402): Mash support. | 732 // TODO(crbug.com/682402): Mash support. |
| 733 NOTIMPLEMENTED(); | 733 NOTIMPLEMENTED(); |
| 734 return false; | 734 return false; |
| 735 } | 735 } |
| 736 VLOG(1) << "StartNativeTouchCalibration: " << id; | 736 VLOG(1) << "StartNativeTouchCalibration: " << id; |
| 737 | 737 |
| 738 // If a custom calibration is already running, then throw an error. | 738 // If a custom calibration is already running, then throw an error. |
| 739 if (custom_touch_calibration_active_) { | 739 if (custom_touch_calibration_active_) { |
| 740 *error = kCustomTouchCalibrationInProgressError; | 740 *error = kCustomTouchCalibrationInProgressError; |
| 741 return false; | 741 return false; |
| 742 } | 742 } |
| 743 | 743 |
| 744 const display::Display display = GetDisplay(id); | 744 const display::Display display = GetDisplay(id); |
| 745 if (!ValidateParamsForTouchCalibration(id, display, GetTouchCalibrator(), | 745 if (!ValidateParamsForTouchCalibration(id, display, GetTouchCalibrator(), |
| 746 error)) { | 746 error)) { |
| 747 return false; | 747 return false; |
| 748 } | 748 } |
| 749 | 749 |
| 750 GetTouchCalibrator()->StartCalibration(display, callback); | 750 GetTouchCalibrator()->StartCalibration(display, callback); |
| 751 return true; | 751 return true; |
| 752 } | 752 } |
| 753 | 753 |
| 754 bool DisplayInfoProviderChromeOS::StartCustomTouchCalibration( | 754 bool DisplayInfoProviderChromeOS::StartCustomTouchCalibration( |
| 755 const std::string& id, | 755 const std::string& id, |
| 756 std::string* error) { | 756 std::string* error) { |
| 757 if (ash_util::IsRunningInMash()) { | 757 if (IsRunningInMash()) { |
| 758 // TODO(crbug.com/682402): Mash support. | 758 // TODO(crbug.com/682402): Mash support. |
| 759 NOTIMPLEMENTED(); | 759 NOTIMPLEMENTED(); |
| 760 return false; | 760 return false; |
| 761 } | 761 } |
| 762 VLOG(1) << "StartCustomTouchCalibration: " << id; | 762 VLOG(1) << "StartCustomTouchCalibration: " << id; |
| 763 const display::Display display = GetDisplay(id); | 763 const display::Display display = GetDisplay(id); |
| 764 if (!ValidateParamsForTouchCalibration(id, display, GetTouchCalibrator(), | 764 if (!ValidateParamsForTouchCalibration(id, display, GetTouchCalibrator(), |
| 765 error)) { | 765 error)) { |
| 766 return false; | 766 return false; |
| 767 } | 767 } |
| 768 | 768 |
| 769 touch_calibration_target_id_ = id; | 769 touch_calibration_target_id_ = id; |
| 770 custom_touch_calibration_active_ = true; | 770 custom_touch_calibration_active_ = true; |
| 771 | 771 |
| 772 // Enable un-transformed touch input. | 772 // Enable un-transformed touch input. |
| 773 ash::Shell::GetInstance()->touch_transformer_controller()->SetForCalibration( | 773 ash::Shell::GetInstance()->touch_transformer_controller()->SetForCalibration( |
| 774 true); | 774 true); |
| 775 return true; | 775 return true; |
| 776 } | 776 } |
| 777 | 777 |
| 778 bool DisplayInfoProviderChromeOS::CompleteCustomTouchCalibration( | 778 bool DisplayInfoProviderChromeOS::CompleteCustomTouchCalibration( |
| 779 const api::system_display::TouchCalibrationPairQuad& pairs, | 779 const api::system_display::TouchCalibrationPairQuad& pairs, |
| 780 const api::system_display::Bounds& bounds, | 780 const api::system_display::Bounds& bounds, |
| 781 std::string* error) { | 781 std::string* error) { |
| 782 if (ash_util::IsRunningInMash()) { | 782 if (IsRunningInMash()) { |
| 783 // TODO(crbug.com/682402): Mash support. | 783 // TODO(crbug.com/682402): Mash support. |
| 784 NOTIMPLEMENTED(); | 784 NOTIMPLEMENTED(); |
| 785 return false; | 785 return false; |
| 786 } | 786 } |
| 787 VLOG(1) << "CompleteCustomTouchCalibration: " << touch_calibration_target_id_; | 787 VLOG(1) << "CompleteCustomTouchCalibration: " << touch_calibration_target_id_; |
| 788 | 788 |
| 789 ash::Shell::GetInstance()->touch_transformer_controller()->SetForCalibration( | 789 ash::Shell::GetInstance()->touch_transformer_controller()->SetForCalibration( |
| 790 false); | 790 false); |
| 791 | 791 |
| 792 const display::Display display = GetDisplay(touch_calibration_target_id_); | 792 const display::Display display = GetDisplay(touch_calibration_target_id_); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 } | 835 } |
| 836 | 836 |
| 837 gfx::Size display_size(bounds.width, bounds.height); | 837 gfx::Size display_size(bounds.width, bounds.height); |
| 838 ash::Shell::GetInstance()->display_manager()->SetTouchCalibrationData( | 838 ash::Shell::GetInstance()->display_manager()->SetTouchCalibrationData( |
| 839 display.id(), calibration_points, display_size); | 839 display.id(), calibration_points, display_size); |
| 840 return true; | 840 return true; |
| 841 } | 841 } |
| 842 | 842 |
| 843 bool DisplayInfoProviderChromeOS::ClearTouchCalibration(const std::string& id, | 843 bool DisplayInfoProviderChromeOS::ClearTouchCalibration(const std::string& id, |
| 844 std::string* error) { | 844 std::string* error) { |
| 845 if (ash_util::IsRunningInMash()) { | 845 if (IsRunningInMash()) { |
| 846 // TODO(crbug.com/682402): Mash support. | 846 // TODO(crbug.com/682402): Mash support. |
| 847 NOTIMPLEMENTED(); | 847 NOTIMPLEMENTED(); |
| 848 *error = "Not implemented for mash."; | 848 *error = "Not implemented for mash."; |
| 849 return false; | 849 return false; |
| 850 } | 850 } |
| 851 const display::Display display = GetDisplay(id); | 851 const display::Display display = GetDisplay(id); |
| 852 | 852 |
| 853 if (!ValidateParamsForTouchCalibration(id, display, GetTouchCalibrator(), | 853 if (!ValidateParamsForTouchCalibration(id, display, GetTouchCalibrator(), |
| 854 error)) { | 854 error)) { |
| 855 return false; | 855 return false; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 884 touch_calibrator_.reset(new chromeos::TouchCalibratorController); | 884 touch_calibrator_.reset(new chromeos::TouchCalibratorController); |
| 885 return touch_calibrator_.get(); | 885 return touch_calibrator_.get(); |
| 886 } | 886 } |
| 887 | 887 |
| 888 // static | 888 // static |
| 889 DisplayInfoProvider* DisplayInfoProvider::Create() { | 889 DisplayInfoProvider* DisplayInfoProvider::Create() { |
| 890 return new DisplayInfoProviderChromeOS(); | 890 return new DisplayInfoProviderChromeOS(); |
| 891 } | 891 } |
| 892 | 892 |
| 893 } // namespace extensions | 893 } // namespace extensions |
| OLD | NEW |