| 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" |
| (...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 ContentProtections protections; | 615 ContentProtections protections; |
| 616 for (const auto& requests_pair : client_protection_requests_) { | 616 for (const auto& requests_pair : client_protection_requests_) { |
| 617 for (const auto& protections_pair : requests_pair.second) { | 617 for (const auto& protections_pair : requests_pair.second) { |
| 618 protections[protections_pair.first] |= protections_pair.second; | 618 protections[protections_pair.first] |= protections_pair.second; |
| 619 } | 619 } |
| 620 } | 620 } |
| 621 | 621 |
| 622 ApplyProtections(protections); | 622 ApplyProtections(protections); |
| 623 } | 623 } |
| 624 | 624 |
| 625 bool DisplayConfigurator::QueryContentProtectionStatus( | 625 void DisplayConfigurator::QueryContentProtectionStatus( |
| 626 ContentProtectionClientId client_id, | 626 ContentProtectionClientId client_id, |
| 627 int64_t display_id, | 627 int64_t display_id, |
| 628 uint32_t* link_mask, | 628 const QueryProtectionCallback& callback) { |
| 629 uint32_t* protection_mask) { | 629 QueryProtectionResponse response; |
| 630 if (!configure_display_ || display_externally_controlled_) | 630 if (!configure_display_ || display_externally_controlled_) { |
| 631 return false; | 631 callback.Run(response); |
| 632 return; |
| 633 } |
| 632 | 634 |
| 633 uint32_t enabled = 0; | 635 uint32_t enabled = 0; |
| 634 uint32_t unfulfilled = 0; | 636 uint32_t unfulfilled = 0; |
| 635 *link_mask = 0; | 637 uint32_t link_mask = 0; |
| 636 for (const DisplaySnapshot* display : cached_displays_) { | 638 for (const DisplaySnapshot* display : cached_displays_) { |
| 637 // Query display if it is in mirror mode or client on the same display. | 639 // Query display if it is in mirror mode or client on the same display. |
| 638 if (!IsMirroring() && display->display_id() != display_id) | 640 if (!IsMirroring() && display->display_id() != display_id) |
| 639 continue; | 641 continue; |
| 640 | 642 |
| 641 *link_mask |= display->type(); | 643 link_mask |= display->type(); |
| 642 switch (display->type()) { | 644 switch (display->type()) { |
| 643 case DISPLAY_CONNECTION_TYPE_UNKNOWN: | 645 case DISPLAY_CONNECTION_TYPE_UNKNOWN: |
| 644 return false; | 646 callback.Run(response); |
| 647 return; |
| 645 // DisplayPort, DVI, and HDMI all support HDCP. | 648 // DisplayPort, DVI, and HDMI all support HDCP. |
| 646 case DISPLAY_CONNECTION_TYPE_DISPLAYPORT: | 649 case DISPLAY_CONNECTION_TYPE_DISPLAYPORT: |
| 647 case DISPLAY_CONNECTION_TYPE_DVI: | 650 case DISPLAY_CONNECTION_TYPE_DVI: |
| 648 case DISPLAY_CONNECTION_TYPE_HDMI: { | 651 case DISPLAY_CONNECTION_TYPE_HDMI: { |
| 649 HDCPState state; | 652 HDCPState state; |
| 650 if (!native_display_delegate_->GetHDCPState(*display, &state)) | 653 if (!native_display_delegate_->GetHDCPState(*display, &state)) { |
| 651 return false; | 654 callback.Run(response); |
| 655 return; |
| 656 } |
| 657 |
| 652 if (state == HDCP_STATE_ENABLED) | 658 if (state == HDCP_STATE_ENABLED) |
| 653 enabled |= CONTENT_PROTECTION_METHOD_HDCP; | 659 enabled |= CONTENT_PROTECTION_METHOD_HDCP; |
| 654 else | 660 else |
| 655 unfulfilled |= CONTENT_PROTECTION_METHOD_HDCP; | 661 unfulfilled |= CONTENT_PROTECTION_METHOD_HDCP; |
| 656 break; | 662 break; |
| 657 } | 663 } |
| 658 case DISPLAY_CONNECTION_TYPE_INTERNAL: | 664 case DISPLAY_CONNECTION_TYPE_INTERNAL: |
| 659 case DISPLAY_CONNECTION_TYPE_VGA: | 665 case DISPLAY_CONNECTION_TYPE_VGA: |
| 660 case DISPLAY_CONNECTION_TYPE_NETWORK: | 666 case DISPLAY_CONNECTION_TYPE_NETWORK: |
| 661 // No protections for these types. Do nothing. | 667 // No protections for these types. Do nothing. |
| 662 break; | 668 break; |
| 663 case DISPLAY_CONNECTION_TYPE_NONE: | 669 case DISPLAY_CONNECTION_TYPE_NONE: |
| 664 NOTREACHED(); | 670 NOTREACHED(); |
| 665 break; | 671 break; |
| 666 } | 672 } |
| 667 } | 673 } |
| 668 | 674 |
| 669 // Don't reveal protections requested by other clients. | 675 // Don't reveal protections requested by other clients. |
| 670 ProtectionRequests::iterator it = client_protection_requests_.find(client_id); | 676 ProtectionRequests::iterator it = client_protection_requests_.find(client_id); |
| 671 if (it != client_protection_requests_.end()) { | 677 if (it != client_protection_requests_.end()) { |
| 672 uint32_t requested_mask = 0; | 678 uint32_t requested_mask = 0; |
| 673 if (it->second.find(display_id) != it->second.end()) | 679 if (it->second.find(display_id) != it->second.end()) |
| 674 requested_mask = it->second[display_id]; | 680 requested_mask = it->second[display_id]; |
| 675 *protection_mask = enabled & ~unfulfilled & requested_mask; | 681 response.protection_mask = enabled & ~unfulfilled & requested_mask; |
| 676 } else { | |
| 677 *protection_mask = 0; | |
| 678 } | 682 } |
| 679 return true; | 683 |
| 684 response.success = true; |
| 685 response.link_mask = link_mask; |
| 686 callback.Run(response); |
| 680 } | 687 } |
| 681 | 688 |
| 682 bool DisplayConfigurator::EnableContentProtection( | 689 void DisplayConfigurator::EnableContentProtection( |
| 683 ContentProtectionClientId client_id, | 690 ContentProtectionClientId client_id, |
| 684 int64_t display_id, | 691 int64_t display_id, |
| 685 uint32_t desired_method_mask) { | 692 uint32_t desired_method_mask, |
| 686 if (!configure_display_ || display_externally_controlled_) | 693 const EnableProtectionCallback& callback) { |
| 687 return false; | 694 if (!configure_display_ || display_externally_controlled_) { |
| 695 callback.Run(false); |
| 696 return; |
| 697 } |
| 688 | 698 |
| 689 ContentProtections protections; | 699 ContentProtections protections; |
| 690 for (const auto& requests_pair : client_protection_requests_) { | 700 for (const auto& requests_pair : client_protection_requests_) { |
| 691 for (const auto& protections_pair : requests_pair.second) { | 701 for (const auto& protections_pair : requests_pair.second) { |
| 692 if (requests_pair.first == client_id && | 702 if (requests_pair.first == client_id && |
| 693 protections_pair.first == display_id) | 703 protections_pair.first == display_id) |
| 694 continue; | 704 continue; |
| 695 | 705 |
| 696 protections[protections_pair.first] |= protections_pair.second; | 706 protections[protections_pair.first] |= protections_pair.second; |
| 697 } | 707 } |
| 698 } | 708 } |
| 699 protections[display_id] |= desired_method_mask; | 709 protections[display_id] |= desired_method_mask; |
| 700 | 710 |
| 701 if (!ApplyProtections(protections)) | 711 if (!ApplyProtections(protections)) { |
| 702 return false; | 712 callback.Run(false); |
| 713 return; |
| 714 } |
| 703 | 715 |
| 704 if (desired_method_mask == CONTENT_PROTECTION_METHOD_NONE) { | 716 if (desired_method_mask == CONTENT_PROTECTION_METHOD_NONE) { |
| 705 if (client_protection_requests_.find(client_id) != | 717 if (client_protection_requests_.find(client_id) != |
| 706 client_protection_requests_.end()) { | 718 client_protection_requests_.end()) { |
| 707 client_protection_requests_[client_id].erase(display_id); | 719 client_protection_requests_[client_id].erase(display_id); |
| 708 if (client_protection_requests_[client_id].size() == 0) | 720 if (client_protection_requests_[client_id].size() == 0) |
| 709 client_protection_requests_.erase(client_id); | 721 client_protection_requests_.erase(client_id); |
| 710 } | 722 } |
| 711 } else { | 723 } else { |
| 712 client_protection_requests_[client_id][display_id] = desired_method_mask; | 724 client_protection_requests_[client_id][display_id] = desired_method_mask; |
| 713 } | 725 } |
| 714 | 726 |
| 715 return true; | 727 callback.Run(true); |
| 716 } | 728 } |
| 717 | 729 |
| 718 std::vector<ui::ColorCalibrationProfile> | 730 std::vector<ui::ColorCalibrationProfile> |
| 719 DisplayConfigurator::GetAvailableColorCalibrationProfiles(int64_t display_id) { | 731 DisplayConfigurator::GetAvailableColorCalibrationProfiles(int64_t display_id) { |
| 720 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 732 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 721 switches::kDisableDisplayColorCalibration)) { | 733 switches::kDisableDisplayColorCalibration)) { |
| 722 for (const DisplaySnapshot* display : cached_displays_) { | 734 for (const DisplaySnapshot* display : cached_displays_) { |
| 723 if (display->display_id() == display_id) { | 735 if (display->display_id() == display_id) { |
| 724 return native_display_delegate_->GetAvailableColorCalibrationProfiles( | 736 return native_display_delegate_->GetAvailableColorCalibrationProfiles( |
| 725 *display); | 737 *display); |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1001 FOR_EACH_OBSERVER( | 1013 FOR_EACH_OBSERVER( |
| 1002 Observer, observers_, OnDisplayModeChanged(cached_displays_)); | 1014 Observer, observers_, OnDisplayModeChanged(cached_displays_)); |
| 1003 } else { | 1015 } else { |
| 1004 FOR_EACH_OBSERVER( | 1016 FOR_EACH_OBSERVER( |
| 1005 Observer, observers_, OnDisplayModeChangeFailed(cached_displays_, | 1017 Observer, observers_, OnDisplayModeChangeFailed(cached_displays_, |
| 1006 attempted_state)); | 1018 attempted_state)); |
| 1007 } | 1019 } |
| 1008 } | 1020 } |
| 1009 | 1021 |
| 1010 } // namespace ui | 1022 } // namespace ui |
| OLD | NEW |