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

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

Issue 2802603005: MD Settings: Display: Add unified desktop control and modify api (Closed)
Patch Set: Rebase Created 3 years, 8 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
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"
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 // error message. 232 // error message.
233 bool ValidateParamsForDisplay(const system_display::DisplayProperties& info, 233 bool ValidateParamsForDisplay(const system_display::DisplayProperties& info,
234 const display::Display& display, 234 const display::Display& display,
235 display::DisplayManager* display_manager, 235 display::DisplayManager* display_manager,
236 int64_t primary_display_id, 236 int64_t primary_display_id,
237 std::string* error) { 237 std::string* error) {
238 int64_t id = display.id(); 238 int64_t id = display.id();
239 bool is_primary = 239 bool is_primary =
240 id == primary_display_id || (info.is_primary && *info.is_primary); 240 id == primary_display_id || (info.is_primary && *info.is_primary);
241 241
242 if (info.is_unified) {
243 if (!is_primary) {
244 *error = "Unified desktop mode can only be set for the primary display.";
245 return false;
246 }
247 if (info.mirroring_source_id) {
248 *error = "Unified desktop mode can not be set with mirroringSourceId.";
249 return false;
250 }
251 return true;
252 }
253
242 // If mirroring source id is set, a display with the given id should exist, 254 // If mirroring source id is set, a display with the given id should exist,
243 // and if should not be the same as the target display's id. 255 // and if should not be the same as the target display's id.
244 if (info.mirroring_source_id && !info.mirroring_source_id->empty()) { 256 if (info.mirroring_source_id && !info.mirroring_source_id->empty()) {
245 int64_t mirroring_id = GetDisplay(*info.mirroring_source_id).id(); 257 int64_t mirroring_id = GetDisplay(*info.mirroring_source_id).id();
246 if (mirroring_id == display::kInvalidDisplayId) { 258 if (mirroring_id == display::kInvalidDisplayId) {
247 *error = "Display " + *info.mirroring_source_id + " not found."; 259 *error = "Display " + *info.mirroring_source_id + " not found.";
248 return false; 260 return false;
249 } 261 }
250 262
251 if (*info.mirroring_source_id == base::Int64ToString(id)) { 263 if (*info.mirroring_source_id == base::Int64ToString(id)) {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 422
411 bool IsMaximizeModeWindowManagerEnabled() { 423 bool IsMaximizeModeWindowManagerEnabled() {
412 return ash::Shell::Get() 424 return ash::Shell::Get()
413 ->maximize_mode_controller() 425 ->maximize_mode_controller()
414 ->IsMaximizeModeWindowManagerEnabled(); 426 ->IsMaximizeModeWindowManagerEnabled();
415 } 427 }
416 428
417 } // namespace 429 } // namespace
418 430
419 // static 431 // static
420 const char DisplayInfoProviderChromeOS:: 432 const char
421 kCustomTouchCalibrationInProgressError[] = 433 DisplayInfoProviderChromeOS::kCustomTouchCalibrationInProgressError[] =
422 "Another custom touch calibration already under progress."; 434 "Another custom touch calibration already under progress.";
423 435
424 // static 436 // static
425 const char DisplayInfoProviderChromeOS:: 437 const char
426 kCompleteCalibrationCalledBeforeStartError[] = 438 DisplayInfoProviderChromeOS::kCompleteCalibrationCalledBeforeStartError[] =
427 "system.display.completeCustomTouchCalibration called before " 439 "system.display.completeCustomTouchCalibration called before "
428 "system.display.startCustomTouchCalibration before."; 440 "system.display.startCustomTouchCalibration before.";
429 441
430 // static 442 // static
431 const char DisplayInfoProviderChromeOS::kTouchBoundsNegativeError[] = 443 const char DisplayInfoProviderChromeOS::kTouchBoundsNegativeError[] =
432 "Bounds cannot have negative values."; 444 "Bounds cannot have negative values.";
433 445
434 // static 446 // static
435 const char DisplayInfoProviderChromeOS::kTouchCalibrationPointsNegativeError[] = 447 const char DisplayInfoProviderChromeOS::kTouchCalibrationPointsNegativeError[] =
436 "Display points and touch points cannot have negative coordinates"; 448 "Display points and touch points cannot have negative coordinates";
437 449
438 // static 450 // static
(...skipping 11 matching lines...) Expand all
450 bool DisplayInfoProviderChromeOS::SetInfo( 462 bool DisplayInfoProviderChromeOS::SetInfo(
451 const std::string& display_id_str, 463 const std::string& display_id_str,
452 const system_display::DisplayProperties& info, 464 const system_display::DisplayProperties& info,
453 std::string* error) { 465 std::string* error) {
454 if (ash_util::IsRunningInMash()) { 466 if (ash_util::IsRunningInMash()) {
455 // TODO(crbug.com/682402): Mash support. 467 // TODO(crbug.com/682402): Mash support.
456 NOTIMPLEMENTED(); 468 NOTIMPLEMENTED();
457 *error = "Not implemented for mash."; 469 *error = "Not implemented for mash.";
458 return false; 470 return false;
459 } 471 }
472
460 display::DisplayManager* display_manager = 473 display::DisplayManager* display_manager =
461 ash::Shell::Get()->display_manager(); 474 ash::Shell::Get()->display_manager();
462 ash::DisplayConfigurationController* display_configuration_controller = 475 ash::DisplayConfigurationController* display_configuration_controller =
463 ash::Shell::Get()->display_configuration_controller(); 476 ash::Shell::Get()->display_configuration_controller();
464 477
465 const display::Display target = GetDisplay(display_id_str); 478 const display::Display target = GetDisplay(display_id_str);
466 479
467 if (target.id() == display::kInvalidDisplayId) { 480 if (target.id() == display::kInvalidDisplayId) {
468 *error = "Display not found:" + display_id_str; 481 *error = "Display not found:" + display_id_str;
469 return false; 482 return false;
470 } 483 }
471 484
472 int64_t display_id = target.id(); 485 int64_t display_id = target.id();
473 const display::Display& primary = 486 const display::Display& primary =
474 display::Screen::GetScreen()->GetPrimaryDisplay(); 487 display::Screen::GetScreen()->GetPrimaryDisplay();
475 488
476 if (!ValidateParamsForDisplay(info, target, display_manager, primary.id(), 489 if (!ValidateParamsForDisplay(info, target, display_manager, primary.id(),
477 error)) { 490 error)) {
478 return false; 491 return false;
479 } 492 }
480 493
494 // Process 'isUnified' parameter if set.
495 if (info.is_unified) {
496 display_manager->SetDefaultMultiDisplayModeForCurrentDisplays(
497 *info.is_unified ? display::DisplayManager::UNIFIED
498 : display::DisplayManager::EXTENDED);
499 }
500
481 // Process 'isPrimary' parameter. 501 // Process 'isPrimary' parameter.
482 if (info.is_primary && *info.is_primary && target.id() != primary.id()) 502 if (info.is_primary && *info.is_primary && target.id() != primary.id())
483 display_configuration_controller->SetPrimaryDisplayId(display_id); 503 display_configuration_controller->SetPrimaryDisplayId(display_id);
484 504
485 // Process 'mirroringSourceId' parameter. 505 // Process 'mirroringSourceId' parameter.
486 if (info.mirroring_source_id) { 506 if (info.mirroring_source_id) {
487 bool mirror = !info.mirroring_source_id->empty(); 507 bool mirror = !info.mirroring_source_id->empty();
488 display_configuration_controller->SetMirrorMode(mirror); 508 display_configuration_controller->SetMirrorMode(mirror);
489 } 509 }
490 510
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 GetDisplayMode(display_manager, display_info, display_mode)); 628 GetDisplayMode(display_manager, display_info, display_mode));
609 } 629 }
610 } 630 }
611 631
612 void DisplayInfoProviderChromeOS::EnableUnifiedDesktop(bool enable) { 632 void DisplayInfoProviderChromeOS::EnableUnifiedDesktop(bool enable) {
613 if (ash_util::IsRunningInMash()) { 633 if (ash_util::IsRunningInMash()) {
614 // TODO(crbug.com/682402): Mash support. 634 // TODO(crbug.com/682402): Mash support.
615 NOTIMPLEMENTED(); 635 NOTIMPLEMENTED();
616 return; 636 return;
617 } 637 }
618 ash::Shell::Get()->display_manager()->SetUnifiedDesktopEnabled(enable); 638 ash::Shell::Get()->display_manager()->SetUnifiedDesktopEnabled(
639 enable);
619 } 640 }
620 641
621 DisplayInfoProvider::DisplayUnitInfoList 642 DisplayInfoProvider::DisplayUnitInfoList
622 DisplayInfoProviderChromeOS::GetAllDisplaysInfo() { 643 DisplayInfoProviderChromeOS::GetAllDisplaysInfo(bool single_unified) {
623 if (ash_util::IsRunningInMash()) { 644 if (ash_util::IsRunningInMash()) {
624 // TODO(crbug.com/682402): Mash support. 645 // TODO(crbug.com/682402): Mash support.
625 NOTIMPLEMENTED(); 646 NOTIMPLEMENTED();
626 return DisplayInfoProvider::DisplayUnitInfoList(); 647 return DisplayInfoProvider::DisplayUnitInfoList();
627 } 648 }
628 display::DisplayManager* display_manager = 649 display::DisplayManager* display_manager =
629 ash::Shell::Get()->display_manager(); 650 ash::Shell::Get()->display_manager();
651
630 if (!display_manager->IsInUnifiedMode()) 652 if (!display_manager->IsInUnifiedMode())
631 return DisplayInfoProvider::GetAllDisplaysInfo(); 653 return DisplayInfoProvider::GetAllDisplaysInfo(single_unified);
632 654
633 std::vector<display::Display> displays = 655 // Chrome OS specific: get displays for unified mode.
634 display_manager->software_mirroring_display_list(); 656 std::vector<display::Display> displays;
635 CHECK_GT(displays.size(), 0u); 657 int64_t primary_id;
658 if (single_unified) {
659 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i)
660 displays.push_back(display_manager->GetDisplayAt(i));
661 primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
662 } else {
663 displays = display_manager->software_mirroring_display_list();
664 CHECK_GT(displays.size(), 0u);
665 // Use first display as primary.
666 primary_id = displays[0].id();
667 }
636 668
637 // Use first display as primary.
638 int64_t primary_id = displays[0].id();
639 DisplayUnitInfoList all_displays; 669 DisplayUnitInfoList all_displays;
640 for (const display::Display& display : displays) { 670 for (const display::Display& display : displays) {
641 system_display::DisplayUnitInfo unit = 671 system_display::DisplayUnitInfo unit_info =
642 CreateDisplayUnitInfo(display, primary_id); 672 CreateDisplayUnitInfo(display, primary_id);
643 UpdateDisplayUnitInfoForPlatform(display, &unit); 673 UpdateDisplayUnitInfoForPlatform(display, &unit_info);
644 all_displays.push_back(std::move(unit)); 674 unit_info.is_unified = true;
675 all_displays.push_back(std::move(unit_info));
645 } 676 }
646 return all_displays; 677 return all_displays;
647 } 678 }
648 679
649 DisplayInfoProvider::DisplayLayoutList 680 DisplayInfoProvider::DisplayLayoutList
650 DisplayInfoProviderChromeOS::GetDisplayLayout() { 681 DisplayInfoProviderChromeOS::GetDisplayLayout() {
651 if (ash_util::IsRunningInMash()) { 682 if (ash_util::IsRunningInMash()) {
652 // TODO(crbug.com/682402): Mash support. 683 // TODO(crbug.com/682402): Mash support.
653 NOTIMPLEMENTED(); 684 NOTIMPLEMENTED();
654 return DisplayInfoProvider::DisplayLayoutList(); 685 return DisplayInfoProvider::DisplayLayoutList();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 VLOG(1) << "OverscanCalibrationComplete: " << id; 757 VLOG(1) << "OverscanCalibrationComplete: " << id;
727 chromeos::OverscanCalibrator* calibrator = GetOverscanCalibrator(id); 758 chromeos::OverscanCalibrator* calibrator = GetOverscanCalibrator(id);
728 if (!calibrator) 759 if (!calibrator)
729 return false; 760 return false;
730 calibrator->Commit(); 761 calibrator->Commit();
731 overscan_calibrators_[id].reset(); 762 overscan_calibrators_[id].reset();
732 return true; 763 return true;
733 } 764 }
734 765
735 bool DisplayInfoProviderChromeOS::ShowNativeTouchCalibration( 766 bool DisplayInfoProviderChromeOS::ShowNativeTouchCalibration(
736 const std::string& id, std::string* error, 767 const std::string& id,
768 std::string* error,
737 const DisplayInfoProvider::TouchCalibrationCallback& callback) { 769 const DisplayInfoProvider::TouchCalibrationCallback& callback) {
738 if (ash_util::IsRunningInMash()) { 770 if (ash_util::IsRunningInMash()) {
739 // TODO(crbug.com/682402): Mash support. 771 // TODO(crbug.com/682402): Mash support.
740 NOTIMPLEMENTED(); 772 NOTIMPLEMENTED();
741 return false; 773 return false;
742 } 774 }
743 VLOG(1) << "StartNativeTouchCalibration: " << id; 775 VLOG(1) << "StartNativeTouchCalibration: " << id;
744 776
745 // If a custom calibration is already running, then throw an error. 777 // If a custom calibration is already running, then throw an error.
746 if (custom_touch_calibration_active_) { 778 if (custom_touch_calibration_active_) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 touch_calibration_target_id_.clear(); 830 touch_calibration_target_id_.clear();
799 831
800 // If Complete() is called before calling Start(), throw an error. 832 // If Complete() is called before calling Start(), throw an error.
801 if (!custom_touch_calibration_active_) { 833 if (!custom_touch_calibration_active_) {
802 *error = kCompleteCalibrationCalledBeforeStartError; 834 *error = kCompleteCalibrationCalledBeforeStartError;
803 return false; 835 return false;
804 } 836 }
805 837
806 custom_touch_calibration_active_ = false; 838 custom_touch_calibration_active_ = false;
807 839
808 if (!ValidateParamsForTouchCalibration( 840 if (!ValidateParamsForTouchCalibration(touch_calibration_target_id_, display,
809 touch_calibration_target_id_, display, GetTouchCalibrator(), error)) { 841 GetTouchCalibrator(), error)) {
810 return false; 842 return false;
811 } 843 }
812 844
813 display::TouchCalibrationData::CalibrationPointPairQuad calibration_points; 845 display::TouchCalibrationData::CalibrationPointPairQuad calibration_points;
814 calibration_points[0] = GetCalibrationPair(pairs.pair1); 846 calibration_points[0] = GetCalibrationPair(pairs.pair1);
815 calibration_points[1] = GetCalibrationPair(pairs.pair2); 847 calibration_points[1] = GetCalibrationPair(pairs.pair2);
816 calibration_points[2] = GetCalibrationPair(pairs.pair3); 848 calibration_points[2] = GetCalibrationPair(pairs.pair3);
817 calibration_points[3] = GetCalibrationPair(pairs.pair4); 849 calibration_points[3] = GetCalibrationPair(pairs.pair4);
818 850
819 // The display bounds cannot have negative values. 851 // The display bounds cannot have negative values.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 touch_calibrator_.reset(new chromeos::TouchCalibratorController); 920 touch_calibrator_.reset(new chromeos::TouchCalibratorController);
889 return touch_calibrator_.get(); 921 return touch_calibrator_.get();
890 } 922 }
891 923
892 // static 924 // static
893 DisplayInfoProvider* DisplayInfoProvider::Create() { 925 DisplayInfoProvider* DisplayInfoProvider::Create() {
894 return new DisplayInfoProviderChromeOS(); 926 return new DisplayInfoProviderChromeOS();
895 } 927 }
896 928
897 } // namespace extensions 929 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698