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

Side by Side Diff: ui/display/manager/chromeos/display_configurator.cc

Issue 2675743002: PPAPI: Make output protection API work with mus+ash (Closed)
Patch Set: Update 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
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 "ui/display/manager/chromeos/display_configurator.h" 5 #include "ui/display/manager/chromeos/display_configurator.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 weak_ptr_factory_(this) {} 483 weak_ptr_factory_(this) {}
484 484
485 DisplayConfigurator::~DisplayConfigurator() { 485 DisplayConfigurator::~DisplayConfigurator() {
486 if (native_display_delegate_) 486 if (native_display_delegate_)
487 native_display_delegate_->RemoveObserver(this); 487 native_display_delegate_->RemoveObserver(this);
488 488
489 CallAndClearInProgressCallbacks(false); 489 CallAndClearInProgressCallbacks(false);
490 CallAndClearQueuedCallbacks(false); 490 CallAndClearQueuedCallbacks(false);
491 491
492 while (!query_protection_callbacks_.empty()) { 492 while (!query_protection_callbacks_.empty()) {
493 query_protection_callbacks_.front().Run(QueryProtectionResponse()); 493 query_protection_callbacks_.front().Run(false, 0, 0);
494 query_protection_callbacks_.pop(); 494 query_protection_callbacks_.pop();
495 } 495 }
496 496
497 while (!enable_protection_callbacks_.empty()) { 497 while (!enable_protection_callbacks_.empty()) {
498 enable_protection_callbacks_.front().Run(false); 498 enable_protection_callbacks_.front().Run(false);
499 enable_protection_callbacks_.pop(); 499 enable_protection_callbacks_.pop();
500 } 500 }
501 } 501 }
502 502
503 void DisplayConfigurator::SetDelegateForTesting( 503 void DisplayConfigurator::SetDelegateForTesting(
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 686
687 void DisplayConfigurator::QueryContentProtectionStatus( 687 void DisplayConfigurator::QueryContentProtectionStatus(
688 ContentProtectionClientId client_id, 688 ContentProtectionClientId client_id,
689 int64_t display_id, 689 int64_t display_id,
690 const QueryProtectionCallback& callback) { 690 const QueryProtectionCallback& callback) {
691 // Exclude virtual displays so that protected content will not be recaptured 691 // Exclude virtual displays so that protected content will not be recaptured
692 // through the cast stream. 692 // through the cast stream.
693 for (const DisplaySnapshot* display : cached_displays_) { 693 for (const DisplaySnapshot* display : cached_displays_) {
694 if (display->display_id() == display_id && 694 if (display->display_id() == display_id &&
695 !IsPhysicalDisplayType(display->type())) { 695 !IsPhysicalDisplayType(display->type())) {
696 callback.Run(QueryProtectionResponse()); 696 callback.Run(false, 0, 0);
697 return; 697 return;
698 } 698 }
699 } 699 }
700 700
701 if (!configure_display_ || display_externally_controlled_) { 701 if (!configure_display_ || display_externally_controlled_) {
702 callback.Run(QueryProtectionResponse()); 702 callback.Run(false, 0, 0);
703 return; 703 return;
704 } 704 }
705 705
706 query_protection_callbacks_.push(callback); 706 query_protection_callbacks_.push(callback);
707 QueryContentProtectionTask* task = new QueryContentProtectionTask( 707 QueryContentProtectionTask* task = new QueryContentProtectionTask(
708 layout_manager_.get(), native_display_delegate_.get(), display_id, 708 layout_manager_.get(), native_display_delegate_.get(), display_id,
709 base::Bind(&DisplayConfigurator::OnContentProtectionQueried, 709 base::Bind(&DisplayConfigurator::OnContentProtectionQueried,
710 weak_ptr_factory_.GetWeakPtr(), client_id, display_id)); 710 weak_ptr_factory_.GetWeakPtr(), client_id, display_id));
711 content_protection_tasks_.push( 711 content_protection_tasks_.push(
712 base::Bind(&QueryContentProtectionTask::Run, base::Owned(task))); 712 base::Bind(&QueryContentProtectionTask::Run, base::Owned(task)));
713 if (content_protection_tasks_.size() == 1) 713 if (content_protection_tasks_.size() == 1)
714 content_protection_tasks_.front().Run(); 714 content_protection_tasks_.front().Run();
715 } 715 }
716 716
717 void DisplayConfigurator::OnContentProtectionQueried( 717 void DisplayConfigurator::OnContentProtectionQueried(
718 ContentProtectionClientId client_id, 718 ContentProtectionClientId client_id,
719 int64_t display_id, 719 int64_t display_id,
720 QueryContentProtectionTask::Response task_response) { 720 QueryContentProtectionTask::Response task_response) {
721 QueryProtectionResponse response; 721 bool success = task_response.success;
722 response.success = task_response.success; 722 uint32_t link_mask = task_response.link_mask;
723 response.link_mask = task_response.link_mask; 723 uint32_t protection_mask = 0;
724 724
725 // Don't reveal protections requested by other clients. 725 // Don't reveal protections requested by other clients.
726 ProtectionRequests::iterator it = client_protection_requests_.find(client_id); 726 ProtectionRequests::iterator it = client_protection_requests_.find(client_id);
727 if (response.success && it != client_protection_requests_.end()) { 727 if (success && it != client_protection_requests_.end()) {
728 uint32_t requested_mask = 0; 728 uint32_t requested_mask = 0;
729 if (it->second.find(display_id) != it->second.end()) 729 if (it->second.find(display_id) != it->second.end())
730 requested_mask = it->second[display_id]; 730 requested_mask = it->second[display_id];
731 response.protection_mask = 731 protection_mask =
732 task_response.enabled & ~task_response.unfulfilled & requested_mask; 732 task_response.enabled & ~task_response.unfulfilled & requested_mask;
733 } 733 }
734 734
735 DCHECK(!content_protection_tasks_.empty()); 735 DCHECK(!content_protection_tasks_.empty());
736 content_protection_tasks_.pop(); 736 content_protection_tasks_.pop();
737 737
738 DCHECK(!query_protection_callbacks_.empty()); 738 DCHECK(!query_protection_callbacks_.empty());
739 QueryProtectionCallback callback = query_protection_callbacks_.front(); 739 QueryProtectionCallback callback = query_protection_callbacks_.front();
740 query_protection_callbacks_.pop(); 740 query_protection_callbacks_.pop();
741 callback.Run(response); 741 callback.Run(success, link_mask, protection_mask);
742 742
743 if (!content_protection_tasks_.empty()) 743 if (!content_protection_tasks_.empty())
744 content_protection_tasks_.front().Run(); 744 content_protection_tasks_.front().Run();
745 } 745 }
746 746
747 void DisplayConfigurator::EnableContentProtection( 747 void DisplayConfigurator::EnableContentProtection(
748 ContentProtectionClientId client_id, 748 ContentProtectionClientId client_id,
749 int64_t display_id, 749 int64_t display_id,
750 uint32_t desired_method_mask, 750 uint32_t desired_method_mask,
751 const EnableProtectionCallback& callback) { 751 const EnableProtectionCallback& callback) {
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 last_virtual_display_id_ = max_display_id & 0xff; 1192 last_virtual_display_id_ = max_display_id & 0xff;
1193 1193
1194 return true; 1194 return true;
1195 } 1195 }
1196 1196
1197 bool DisplayConfigurator::IsDisplayOn() const { 1197 bool DisplayConfigurator::IsDisplayOn() const {
1198 return current_power_state_ != chromeos::DISPLAY_POWER_ALL_OFF; 1198 return current_power_state_ != chromeos::DISPLAY_POWER_ALL_OFF;
1199 } 1199 }
1200 1200
1201 } // namespace display 1201 } // namespace display
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698