Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: chrome/browser/extensions/display_info_provider_chromeos.cc

Issue 2692043006: mash: Work around startup crash in extensions::DisplayInfoProviderChromeOS (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "ash/shell.h" 11 #include "ash/shell.h"
12 #include "ash/touch/ash_touch_transform_controller.h" 12 #include "ash/touch/ash_touch_transform_controller.h"
13 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "chrome/browser/chromeos/display/display_preferences.h" 14 #include "chrome/browser/chromeos/display/display_preferences.h"
15 #include "chrome/browser/chromeos/display/overscan_calibrator.h" 15 #include "chrome/browser/chromeos/display/overscan_calibrator.h"
16 #include "chrome/browser/chromeos/display/touch_calibrator/touch_calibrator_cont roller.h" 16 #include "chrome/browser/chromeos/display/touch_calibrator/touch_calibrator_cont roller.h"
17 #include "chrome/browser/ui/ash/ash_util.h"
17 #include "extensions/common/api/system_display.h" 18 #include "extensions/common/api/system_display.h"
18 #include "ui/display/display.h" 19 #include "ui/display/display.h"
19 #include "ui/display/display_layout.h" 20 #include "ui/display/display_layout.h"
20 #include "ui/display/display_layout_builder.h" 21 #include "ui/display/display_layout_builder.h"
21 #include "ui/display/manager/display_manager.h" 22 #include "ui/display/manager/display_manager.h"
22 #include "ui/display/types/display_constants.h" 23 #include "ui/display/types/display_constants.h"
23 #include "ui/gfx/geometry/point.h" 24 #include "ui/gfx/geometry/point.h"
24 #include "ui/gfx/geometry/rect.h" 25 #include "ui/gfx/geometry/rect.h"
25 26
26 namespace extensions { 27 namespace extensions {
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 "Another touch calibration is already active."; 438 "Another touch calibration is already active.";
438 439
439 DisplayInfoProviderChromeOS::DisplayInfoProviderChromeOS() {} 440 DisplayInfoProviderChromeOS::DisplayInfoProviderChromeOS() {}
440 441
441 DisplayInfoProviderChromeOS::~DisplayInfoProviderChromeOS() {} 442 DisplayInfoProviderChromeOS::~DisplayInfoProviderChromeOS() {}
442 443
443 bool DisplayInfoProviderChromeOS::SetInfo( 444 bool DisplayInfoProviderChromeOS::SetInfo(
444 const std::string& display_id_str, 445 const std::string& display_id_str,
445 const system_display::DisplayProperties& info, 446 const system_display::DisplayProperties& info,
446 std::string* error) { 447 std::string* error) {
448 if (chrome::IsRunningInMash()) {
449 // TODO(crbug.com/682402): Mash support.
450 NOTIMPLEMENTED();
451 *error = "Not implemented for mash.";
452 return false;
453 }
447 display::DisplayManager* display_manager = 454 display::DisplayManager* display_manager =
448 ash::Shell::GetInstance()->display_manager(); 455 ash::Shell::GetInstance()->display_manager();
449 ash::DisplayConfigurationController* display_configuration_controller = 456 ash::DisplayConfigurationController* display_configuration_controller =
450 ash::Shell::GetInstance()->display_configuration_controller(); 457 ash::Shell::GetInstance()->display_configuration_controller();
451 458
452 const display::Display target = GetDisplay(display_id_str); 459 const display::Display target = GetDisplay(display_id_str);
453 460
454 if (target.id() == display::kInvalidDisplayId) { 461 if (target.id() == display::kInvalidDisplayId) {
455 *error = "Display not found."; 462 *error = "Display not found.";
456 return false; 463 return false;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 new_bounds_origin.y() - target.bounds().y()); 512 new_bounds_origin.y() - target.bounds().y());
506 UpdateDisplayLayout(primary.bounds(), primary.id(), target_bounds, 513 UpdateDisplayLayout(primary.bounds(), primary.id(), target_bounds,
507 target.id()); 514 target.id());
508 } 515 }
509 516
510 return true; 517 return true;
511 } 518 }
512 519
513 bool DisplayInfoProviderChromeOS::SetDisplayLayout( 520 bool DisplayInfoProviderChromeOS::SetDisplayLayout(
514 const DisplayLayoutList& layouts) { 521 const DisplayLayoutList& layouts) {
522 if (chrome::IsRunningInMash()) {
523 // TODO(crbug.com/682402): Mash support.
524 NOTIMPLEMENTED();
525 return false;
526 }
515 display::DisplayManager* display_manager = 527 display::DisplayManager* display_manager =
516 ash::Shell::GetInstance()->display_manager(); 528 ash::Shell::GetInstance()->display_manager();
517 display::DisplayLayoutBuilder builder( 529 display::DisplayLayoutBuilder builder(
518 display_manager->GetCurrentResolvedDisplayLayout()); 530 display_manager->GetCurrentResolvedDisplayLayout());
519 531
520 bool have_root = false; 532 bool have_root = false;
521 builder.ClearPlacements(); 533 builder.ClearPlacements();
522 for (const system_display::DisplayLayout& layout : layouts) { 534 for (const system_display::DisplayLayout& layout : layouts) {
523 display::Display display = GetDisplay(layout.id); 535 display::Display display = GetDisplay(layout.id);
524 if (display.id() == display::kInvalidDisplayId) { 536 if (display.id() == display::kInvalidDisplayId) {
(...skipping 22 matching lines...) Expand all
547 } 559 }
548 ash::Shell::GetInstance() 560 ash::Shell::GetInstance()
549 ->display_configuration_controller() 561 ->display_configuration_controller()
550 ->SetDisplayLayout(std::move(layout), true /* user_action */); 562 ->SetDisplayLayout(std::move(layout), true /* user_action */);
551 return true; 563 return true;
552 } 564 }
553 565
554 void DisplayInfoProviderChromeOS::UpdateDisplayUnitInfoForPlatform( 566 void DisplayInfoProviderChromeOS::UpdateDisplayUnitInfoForPlatform(
555 const display::Display& display, 567 const display::Display& display,
556 system_display::DisplayUnitInfo* unit) { 568 system_display::DisplayUnitInfo* unit) {
569 if (chrome::IsRunningInMash()) {
570 // TODO(crbug.com/682402): Mash support.
571 NOTIMPLEMENTED();
572 return;
573 }
557 display::DisplayManager* display_manager = 574 display::DisplayManager* display_manager =
558 ash::Shell::GetInstance()->display_manager(); 575 ash::Shell::GetInstance()->display_manager();
559 unit->name = display_manager->GetDisplayNameForId(display.id()); 576 unit->name = display_manager->GetDisplayNameForId(display.id());
560 if (display_manager->IsInMirrorMode()) { 577 if (display_manager->IsInMirrorMode()) {
561 unit->mirroring_source_id = 578 unit->mirroring_source_id =
562 base::Int64ToString(display_manager->mirroring_display_id()); 579 base::Int64ToString(display_manager->mirroring_display_id());
563 } 580 }
564 581
565 const display::ManagedDisplayInfo& display_info = 582 const display::ManagedDisplayInfo& display_info =
566 display_manager->GetDisplayInfo(display.id()); 583 display_manager->GetDisplayInfo(display.id());
(...skipping 11 matching lines...) Expand all
578 unit->overscan.bottom = overscan_insets.bottom(); 595 unit->overscan.bottom = overscan_insets.bottom();
579 596
580 for (const scoped_refptr<display::ManagedDisplayMode>& display_mode : 597 for (const scoped_refptr<display::ManagedDisplayMode>& display_mode :
581 display_info.display_modes()) { 598 display_info.display_modes()) {
582 unit->modes.push_back( 599 unit->modes.push_back(
583 GetDisplayMode(display_manager, display_info, display_mode)); 600 GetDisplayMode(display_manager, display_info, display_mode));
584 } 601 }
585 } 602 }
586 603
587 void DisplayInfoProviderChromeOS::EnableUnifiedDesktop(bool enable) { 604 void DisplayInfoProviderChromeOS::EnableUnifiedDesktop(bool enable) {
605 if (chrome::IsRunningInMash()) {
606 // TODO(crbug.com/682402): Mash support.
607 NOTIMPLEMENTED();
608 return;
609 }
588 ash::Shell::GetInstance()->display_manager()->SetUnifiedDesktopEnabled( 610 ash::Shell::GetInstance()->display_manager()->SetUnifiedDesktopEnabled(
589 enable); 611 enable);
590 } 612 }
591 613
592 DisplayInfoProvider::DisplayUnitInfoList 614 DisplayInfoProvider::DisplayUnitInfoList
593 DisplayInfoProviderChromeOS::GetAllDisplaysInfo() { 615 DisplayInfoProviderChromeOS::GetAllDisplaysInfo() {
616 if (chrome::IsRunningInMash()) {
617 // TODO(crbug.com/682402): Mash support.
618 NOTIMPLEMENTED();
619 return DisplayInfoProvider::DisplayUnitInfoList();
620 }
594 display::DisplayManager* display_manager = 621 display::DisplayManager* display_manager =
595 ash::Shell::GetInstance()->display_manager(); 622 ash::Shell::GetInstance()->display_manager();
596 if (!display_manager->IsInUnifiedMode()) 623 if (!display_manager->IsInUnifiedMode())
597 return DisplayInfoProvider::GetAllDisplaysInfo(); 624 return DisplayInfoProvider::GetAllDisplaysInfo();
598 625
599 std::vector<display::Display> displays = 626 std::vector<display::Display> displays =
600 display_manager->software_mirroring_display_list(); 627 display_manager->software_mirroring_display_list();
601 CHECK_GT(displays.size(), 0u); 628 CHECK_GT(displays.size(), 0u);
602 629
603 // Use first display as primary. 630 // Use first display as primary.
604 int64_t primary_id = displays[0].id(); 631 int64_t primary_id = displays[0].id();
605 DisplayUnitInfoList all_displays; 632 DisplayUnitInfoList all_displays;
606 for (const display::Display& display : displays) { 633 for (const display::Display& display : displays) {
607 system_display::DisplayUnitInfo unit = 634 system_display::DisplayUnitInfo unit =
608 CreateDisplayUnitInfo(display, primary_id); 635 CreateDisplayUnitInfo(display, primary_id);
609 UpdateDisplayUnitInfoForPlatform(display, &unit); 636 UpdateDisplayUnitInfoForPlatform(display, &unit);
610 all_displays.push_back(std::move(unit)); 637 all_displays.push_back(std::move(unit));
611 } 638 }
612 return all_displays; 639 return all_displays;
613 } 640 }
614 641
615 DisplayInfoProvider::DisplayLayoutList 642 DisplayInfoProvider::DisplayLayoutList
616 DisplayInfoProviderChromeOS::GetDisplayLayout() { 643 DisplayInfoProviderChromeOS::GetDisplayLayout() {
644 if (chrome::IsRunningInMash()) {
645 // TODO(crbug.com/682402): Mash support.
646 NOTIMPLEMENTED();
647 return DisplayInfoProvider::DisplayLayoutList();
648 }
617 display::DisplayManager* display_manager = 649 display::DisplayManager* display_manager =
618 ash::Shell::GetInstance()->display_manager(); 650 ash::Shell::GetInstance()->display_manager();
619 651
620 if (display_manager->num_connected_displays() < 2) 652 if (display_manager->num_connected_displays() < 2)
621 return DisplayInfoProvider::DisplayLayoutList(); 653 return DisplayInfoProvider::DisplayLayoutList();
622 654
623 display::Screen* screen = display::Screen::GetScreen(); 655 display::Screen* screen = display::Screen::GetScreen();
624 std::vector<display::Display> displays = screen->GetAllDisplays(); 656 std::vector<display::Display> displays = screen->GetAllDisplays();
625 657
626 DisplayLayoutList result; 658 DisplayLayoutList result;
627 for (const display::Display& display : displays) { 659 for (const display::Display& display : displays) {
628 const display::DisplayPlacement placement = 660 const display::DisplayPlacement placement =
629 display_manager->GetCurrentResolvedDisplayLayout().FindPlacementById( 661 display_manager->GetCurrentResolvedDisplayLayout().FindPlacementById(
630 display.id()); 662 display.id());
631 if (placement.display_id == display::kInvalidDisplayId) 663 if (placement.display_id == display::kInvalidDisplayId)
632 continue; 664 continue;
633 system_display::DisplayLayout display_layout; 665 system_display::DisplayLayout display_layout;
634 display_layout.id = base::Int64ToString(placement.display_id); 666 display_layout.id = base::Int64ToString(placement.display_id);
635 display_layout.parent_id = base::Int64ToString(placement.parent_display_id); 667 display_layout.parent_id = base::Int64ToString(placement.parent_display_id);
636 display_layout.position = GetLayoutPosition(placement.position); 668 display_layout.position = GetLayoutPosition(placement.position);
637 display_layout.offset = placement.offset; 669 display_layout.offset = placement.offset;
638 result.push_back(std::move(display_layout)); 670 result.push_back(std::move(display_layout));
639 } 671 }
640 return result; 672 return result;
641 } 673 }
642 674
643 bool DisplayInfoProviderChromeOS::OverscanCalibrationStart( 675 bool DisplayInfoProviderChromeOS::OverscanCalibrationStart(
644 const std::string& id) { 676 const std::string& id) {
677 if (chrome::IsRunningInMash()) {
678 // TODO(crbug.com/682402): Mash support.
679 NOTIMPLEMENTED();
680 return false;
681 }
645 VLOG(1) << "OverscanCalibrationStart: " << id; 682 VLOG(1) << "OverscanCalibrationStart: " << id;
646 const display::Display display = GetDisplay(id); 683 const display::Display display = GetDisplay(id);
647 if (display.id() == display::kInvalidDisplayId) 684 if (display.id() == display::kInvalidDisplayId)
648 return false; 685 return false;
649 auto insets = 686 auto insets =
650 ash::Shell::GetInstance()->window_tree_host_manager()->GetOverscanInsets( 687 ash::Shell::GetInstance()->window_tree_host_manager()->GetOverscanInsets(
651 display.id()); 688 display.id());
652 overscan_calibrators_[id].reset( 689 overscan_calibrators_[id].reset(
653 new chromeos::OverscanCalibrator(display, insets)); 690 new chromeos::OverscanCalibrator(display, insets));
654 return true; 691 return true;
(...skipping 29 matching lines...) Expand all
684 if (!calibrator) 721 if (!calibrator)
685 return false; 722 return false;
686 calibrator->Commit(); 723 calibrator->Commit();
687 overscan_calibrators_[id].reset(); 724 overscan_calibrators_[id].reset();
688 return true; 725 return true;
689 } 726 }
690 727
691 bool DisplayInfoProviderChromeOS::ShowNativeTouchCalibration( 728 bool DisplayInfoProviderChromeOS::ShowNativeTouchCalibration(
692 const std::string& id, std::string* error, 729 const std::string& id, std::string* error,
693 const DisplayInfoProvider::TouchCalibrationCallback& callback) { 730 const DisplayInfoProvider::TouchCalibrationCallback& callback) {
731 if (chrome::IsRunningInMash()) {
732 // TODO(crbug.com/682402): Mash support.
733 NOTIMPLEMENTED();
734 return false;
735 }
694 VLOG(1) << "StartNativeTouchCalibration: " << id; 736 VLOG(1) << "StartNativeTouchCalibration: " << id;
695 737
696 // If a custom calibration is already running, then throw an error. 738 // If a custom calibration is already running, then throw an error.
697 if (custom_touch_calibration_active_) { 739 if (custom_touch_calibration_active_) {
698 *error = kCustomTouchCalibrationInProgressError; 740 *error = kCustomTouchCalibrationInProgressError;
699 return false; 741 return false;
700 } 742 }
701 743
702 const display::Display display = GetDisplay(id); 744 const display::Display display = GetDisplay(id);
703 if (!ValidateParamsForTouchCalibration(id, display, GetTouchCalibrator(), 745 if (!ValidateParamsForTouchCalibration(id, display, GetTouchCalibrator(),
704 error)) { 746 error)) {
705 return false; 747 return false;
706 } 748 }
707 749
708 GetTouchCalibrator()->StartCalibration(display, callback); 750 GetTouchCalibrator()->StartCalibration(display, callback);
709 return true; 751 return true;
710 } 752 }
711 753
712 bool DisplayInfoProviderChromeOS::StartCustomTouchCalibration( 754 bool DisplayInfoProviderChromeOS::StartCustomTouchCalibration(
713 const std::string& id, 755 const std::string& id,
714 std::string* error) { 756 std::string* error) {
757 if (chrome::IsRunningInMash()) {
758 // TODO(crbug.com/682402): Mash support.
759 NOTIMPLEMENTED();
760 return false;
761 }
715 VLOG(1) << "StartCustomTouchCalibration: " << id; 762 VLOG(1) << "StartCustomTouchCalibration: " << id;
716 const display::Display display = GetDisplay(id); 763 const display::Display display = GetDisplay(id);
717 if (!ValidateParamsForTouchCalibration(id, display, GetTouchCalibrator(), 764 if (!ValidateParamsForTouchCalibration(id, display, GetTouchCalibrator(),
718 error)) { 765 error)) {
719 return false; 766 return false;
720 } 767 }
721 768
722 touch_calibration_target_id_ = id; 769 touch_calibration_target_id_ = id;
723 custom_touch_calibration_active_ = true; 770 custom_touch_calibration_active_ = true;
724 771
725 // Enable un-transformed touch input. 772 // Enable un-transformed touch input.
726 ash::Shell::GetInstance()->touch_transformer_controller()->SetForCalibration( 773 ash::Shell::GetInstance()->touch_transformer_controller()->SetForCalibration(
727 true); 774 true);
728 return true; 775 return true;
729 } 776 }
730 777
731 bool DisplayInfoProviderChromeOS::CompleteCustomTouchCalibration( 778 bool DisplayInfoProviderChromeOS::CompleteCustomTouchCalibration(
732 const api::system_display::TouchCalibrationPairQuad& pairs, 779 const api::system_display::TouchCalibrationPairQuad& pairs,
733 const api::system_display::Bounds& bounds, 780 const api::system_display::Bounds& bounds,
734 std::string* error) { 781 std::string* error) {
782 if (chrome::IsRunningInMash()) {
783 // TODO(crbug.com/682402): Mash support.
784 NOTIMPLEMENTED();
785 return false;
786 }
735 VLOG(1) << "CompleteCustomTouchCalibration: " << touch_calibration_target_id_; 787 VLOG(1) << "CompleteCustomTouchCalibration: " << touch_calibration_target_id_;
736 788
737 ash::Shell::GetInstance()->touch_transformer_controller()->SetForCalibration( 789 ash::Shell::GetInstance()->touch_transformer_controller()->SetForCalibration(
738 false); 790 false);
739 791
740 const display::Display display = GetDisplay(touch_calibration_target_id_); 792 const display::Display display = GetDisplay(touch_calibration_target_id_);
741 touch_calibration_target_id_.clear(); 793 touch_calibration_target_id_.clear();
742 794
743 // If Complete() is called before calling Start(), throw an error. 795 // If Complete() is called before calling Start(), throw an error.
744 if (!custom_touch_calibration_active_) { 796 if (!custom_touch_calibration_active_) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 } 835 }
784 836
785 gfx::Size display_size(bounds.width, bounds.height); 837 gfx::Size display_size(bounds.width, bounds.height);
786 ash::Shell::GetInstance()->display_manager()->SetTouchCalibrationData( 838 ash::Shell::GetInstance()->display_manager()->SetTouchCalibrationData(
787 display.id(), calibration_points, display_size); 839 display.id(), calibration_points, display_size);
788 return true; 840 return true;
789 } 841 }
790 842
791 bool DisplayInfoProviderChromeOS::ClearTouchCalibration(const std::string& id, 843 bool DisplayInfoProviderChromeOS::ClearTouchCalibration(const std::string& id,
792 std::string* error) { 844 std::string* error) {
845 if (chrome::IsRunningInMash()) {
846 // TODO(crbug.com/682402): Mash support.
847 NOTIMPLEMENTED();
848 *error = "Not implemented for mash.";
849 return false;
850 }
793 const display::Display display = GetDisplay(id); 851 const display::Display display = GetDisplay(id);
794 852
795 if (!ValidateParamsForTouchCalibration(id, display, GetTouchCalibrator(), 853 if (!ValidateParamsForTouchCalibration(id, display, GetTouchCalibrator(),
796 error)) { 854 error)) {
797 return false; 855 return false;
798 } 856 }
799 857
800 ash::Shell::GetInstance()->display_manager()->ClearTouchCalibrationData( 858 ash::Shell::GetInstance()->display_manager()->ClearTouchCalibrationData(
801 display.id()); 859 display.id());
802 return true; 860 return true;
(...skipping 23 matching lines...) Expand all
826 touch_calibrator_.reset(new chromeos::TouchCalibratorController); 884 touch_calibrator_.reset(new chromeos::TouchCalibratorController);
827 return touch_calibrator_.get(); 885 return touch_calibrator_.get();
828 } 886 }
829 887
830 // static 888 // static
831 DisplayInfoProvider* DisplayInfoProvider::Create() { 889 DisplayInfoProvider* DisplayInfoProvider::Create() {
832 return new DisplayInfoProviderChromeOS(); 890 return new DisplayInfoProviderChromeOS();
833 } 891 }
834 892
835 } // namespace extensions 893 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698