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 "ui/display/chromeos/display_configurator.h" | 5 #include "ui/display/chromeos/display_configurator.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/sys_info.h" | 10 #include "base/sys_info.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "ui/display/chromeos/apply_content_protection_task.h" | 12 #include "ui/display/chromeos/apply_content_protection_task.h" |
| 13 #include "ui/display/chromeos/display_layout_manager.h" | 13 #include "ui/display/chromeos/display_layout_manager.h" |
| 14 #include "ui/display/chromeos/display_snapshot_virtual.h" | |
| 14 #include "ui/display/chromeos/display_util.h" | 15 #include "ui/display/chromeos/display_util.h" |
| 15 #include "ui/display/chromeos/update_display_configuration_task.h" | 16 #include "ui/display/chromeos/update_display_configuration_task.h" |
| 16 #include "ui/display/display_switches.h" | 17 #include "ui/display/display_switches.h" |
| 17 #include "ui/display/types/display_mode.h" | 18 #include "ui/display/types/display_mode.h" |
| 18 #include "ui/display/types/display_snapshot.h" | 19 #include "ui/display/types/display_snapshot.h" |
| 19 #include "ui/display/types/native_display_delegate.h" | 20 #include "ui/display/types/native_display_delegate.h" |
| 20 | 21 |
| 21 namespace ui { | 22 namespace ui { |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| (...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 654 enable_protection_callbacks_.pop(); | 655 enable_protection_callbacks_.pop(); |
| 655 | 656 |
| 656 if (!content_protection_tasks_.empty()) | 657 if (!content_protection_tasks_.empty()) |
| 657 content_protection_tasks_.front().Run(); | 658 content_protection_tasks_.front().Run(); |
| 658 } | 659 } |
| 659 | 660 |
| 660 void DisplayConfigurator::QueryContentProtectionStatus( | 661 void DisplayConfigurator::QueryContentProtectionStatus( |
| 661 ContentProtectionClientId client_id, | 662 ContentProtectionClientId client_id, |
| 662 int64_t display_id, | 663 int64_t display_id, |
| 663 const QueryProtectionCallback& callback) { | 664 const QueryProtectionCallback& callback) { |
| 665 // Exclude virtual displays. | |
|
oshima
2015/11/24 22:19:27
I believe this is not to cast the protected conten
robert.bradford
2015/11/26 16:29:40
My aim was to prevent protected content from being
oshima
2015/12/02 20:34:27
Can you add comment?
| |
| 666 for (const DisplaySnapshot* display : cached_displays_) { | |
| 667 if (display->display_id() == display_id && | |
| 668 !IsPhysicalDisplayType(display->type())) { | |
| 669 callback.Run(QueryProtectionResponse()); | |
| 670 return; | |
| 671 } | |
| 672 } | |
| 673 | |
| 664 if (!configure_display_ || display_externally_controlled_) { | 674 if (!configure_display_ || display_externally_controlled_) { |
| 665 callback.Run(QueryProtectionResponse()); | 675 callback.Run(QueryProtectionResponse()); |
| 666 return; | 676 return; |
| 667 } | 677 } |
| 668 | 678 |
| 669 query_protection_callbacks_.push(callback); | 679 query_protection_callbacks_.push(callback); |
| 670 QueryContentProtectionTask* task = new QueryContentProtectionTask( | 680 QueryContentProtectionTask* task = new QueryContentProtectionTask( |
| 671 layout_manager_.get(), native_display_delegate_.get(), display_id, | 681 layout_manager_.get(), native_display_delegate_.get(), display_id, |
| 672 base::Bind(&DisplayConfigurator::OnContentProtectionQueried, | 682 base::Bind(&DisplayConfigurator::OnContentProtectionQueried, |
| 673 weak_ptr_factory_.GetWeakPtr(), client_id, display_id)); | 683 weak_ptr_factory_.GetWeakPtr(), client_id, display_id)); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 772 callback.Run(true); | 782 callback.Run(true); |
| 773 if (!content_protection_tasks_.empty()) | 783 if (!content_protection_tasks_.empty()) |
| 774 content_protection_tasks_.front().Run(); | 784 content_protection_tasks_.front().Run(); |
| 775 } | 785 } |
| 776 | 786 |
| 777 std::vector<ui::ColorCalibrationProfile> | 787 std::vector<ui::ColorCalibrationProfile> |
| 778 DisplayConfigurator::GetAvailableColorCalibrationProfiles(int64_t display_id) { | 788 DisplayConfigurator::GetAvailableColorCalibrationProfiles(int64_t display_id) { |
| 779 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 789 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 780 switches::kDisableDisplayColorCalibration)) { | 790 switches::kDisableDisplayColorCalibration)) { |
| 781 for (const DisplaySnapshot* display : cached_displays_) { | 791 for (const DisplaySnapshot* display : cached_displays_) { |
| 782 if (display->display_id() == display_id) { | 792 if (display->display_id() == display_id && |
| 793 IsPhysicalDisplayType(display->type())) { | |
| 783 return native_display_delegate_->GetAvailableColorCalibrationProfiles( | 794 return native_display_delegate_->GetAvailableColorCalibrationProfiles( |
| 784 *display); | 795 *display); |
| 785 } | 796 } |
| 786 } | 797 } |
| 787 } | 798 } |
| 788 | 799 |
| 789 return std::vector<ui::ColorCalibrationProfile>(); | 800 return std::vector<ui::ColorCalibrationProfile>(); |
| 790 } | 801 } |
| 791 | 802 |
| 792 bool DisplayConfigurator::SetColorCalibrationProfile( | 803 bool DisplayConfigurator::SetColorCalibrationProfile( |
| 793 int64_t display_id, | 804 int64_t display_id, |
| 794 ui::ColorCalibrationProfile new_profile) { | 805 ui::ColorCalibrationProfile new_profile) { |
| 795 for (const DisplaySnapshot* display : cached_displays_) { | 806 for (const DisplaySnapshot* display : cached_displays_) { |
| 796 if (display->display_id() == display_id) { | 807 if (display->display_id() == display_id && |
| 808 IsPhysicalDisplayType(display->type())) { | |
| 797 return native_display_delegate_->SetColorCalibrationProfile(*display, | 809 return native_display_delegate_->SetColorCalibrationProfile(*display, |
| 798 new_profile); | 810 new_profile); |
| 799 } | 811 } |
| 800 } | 812 } |
| 801 | 813 |
| 802 return false; | 814 return false; |
| 803 } | 815 } |
| 804 | 816 |
| 805 bool DisplayConfigurator::SetGammaRamp( | 817 bool DisplayConfigurator::SetGammaRamp( |
| 806 int64_t display_id, | 818 int64_t display_id, |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 957 " requested"; | 969 " requested"; |
| 958 CallAndClearQueuedCallbacks(true); | 970 CallAndClearQueuedCallbacks(true); |
| 959 return; | 971 return; |
| 960 } | 972 } |
| 961 | 973 |
| 962 configuration_task_.reset(new UpdateDisplayConfigurationTask( | 974 configuration_task_.reset(new UpdateDisplayConfigurationTask( |
| 963 native_display_delegate_.get(), layout_manager_.get(), | 975 native_display_delegate_.get(), layout_manager_.get(), |
| 964 requested_display_state_, requested_power_state_, requested_power_flags_, | 976 requested_display_state_, requested_power_state_, requested_power_flags_, |
| 965 0, force_configure_, base::Bind(&DisplayConfigurator::OnConfigured, | 977 0, force_configure_, base::Bind(&DisplayConfigurator::OnConfigured, |
| 966 weak_ptr_factory_.GetWeakPtr()))); | 978 weak_ptr_factory_.GetWeakPtr()))); |
| 979 configuration_task_->set_virtual_display_snapshots( | |
| 980 virtual_display_snapshots_.get()); | |
| 967 | 981 |
| 968 // Reset the flags before running the task; otherwise it may end up scheduling | 982 // Reset the flags before running the task; otherwise it may end up scheduling |
| 969 // another configuration. | 983 // another configuration. |
| 970 force_configure_ = false; | 984 force_configure_ = false; |
| 971 requested_power_flags_ = kSetDisplayPowerNoFlags; | 985 requested_power_flags_ = kSetDisplayPowerNoFlags; |
| 972 requested_power_state_change_ = false; | 986 requested_power_state_change_ = false; |
| 973 requested_display_state_ = MULTIPLE_DISPLAY_STATE_INVALID; | 987 requested_display_state_ = MULTIPLE_DISPLAY_STATE_INVALID; |
| 974 | 988 |
| 975 DCHECK(in_progress_configuration_callbacks_.empty()); | 989 DCHECK(in_progress_configuration_callbacks_.empty()); |
| 976 in_progress_configuration_callbacks_.swap(queued_configuration_callbacks_); | 990 in_progress_configuration_callbacks_.swap(queued_configuration_callbacks_); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1072 if (success) { | 1086 if (success) { |
| 1073 FOR_EACH_OBSERVER( | 1087 FOR_EACH_OBSERVER( |
| 1074 Observer, observers_, OnDisplayModeChanged(cached_displays_)); | 1088 Observer, observers_, OnDisplayModeChanged(cached_displays_)); |
| 1075 } else { | 1089 } else { |
| 1076 FOR_EACH_OBSERVER( | 1090 FOR_EACH_OBSERVER( |
| 1077 Observer, observers_, OnDisplayModeChangeFailed(cached_displays_, | 1091 Observer, observers_, OnDisplayModeChangeFailed(cached_displays_, |
| 1078 attempted_state)); | 1092 attempted_state)); |
| 1079 } | 1093 } |
| 1080 } | 1094 } |
| 1081 | 1095 |
| 1096 int64_t DisplayConfigurator::AddVirtualDisplay(gfx::Size display_size) { | |
| 1097 DisplaySnapshotVirtual* virtual_snapshot = | |
| 1098 new DisplaySnapshotVirtual(++last_virtual_display_id_, display_size); | |
| 1099 virtual_display_snapshots_.push_back(virtual_snapshot); | |
| 1100 ConfigureDisplays(); | |
| 1101 | |
| 1102 return virtual_snapshot->display_id(); | |
| 1103 } | |
| 1104 | |
| 1105 bool DisplayConfigurator::RemoveVirtualDisplay(int64_t display_id) { | |
| 1106 for (auto it = virtual_display_snapshots_.begin(); | |
| 1107 it != virtual_display_snapshots_.end(); ++it) { | |
| 1108 if ((*it)->display_id() == display_id) { | |
| 1109 if (display_id == last_virtual_display_id_) | |
| 1110 last_virtual_display_id_--; | |
| 1111 virtual_display_snapshots_.erase(it); | |
|
oshima
2015/11/24 22:19:27
where are DisplaySnapshotVirtual objects deleted?
robert.bradford
2015/11/26 16:29:40
I'm using a base::ScopedVector. This means that I
| |
| 1112 ConfigureDisplays(); | |
| 1113 return true; | |
| 1114 } | |
| 1115 } | |
| 1116 return false; | |
| 1117 } | |
| 1118 | |
| 1082 } // namespace ui | 1119 } // namespace ui |
| OLD | NEW |