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

Side by Side Diff: ui/display/chromeos/query_content_protection_task.cc

Issue 2540313002: Split //ui/display and create //ui/display/manager. (Closed)
Patch Set: Cleanup export header. Created 4 years 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
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/display/chromeos/query_content_protection_task.h"
6
7 #include "ui/display/chromeos/display_layout_manager.h"
8 #include "ui/display/types/display_snapshot.h"
9 #include "ui/display/types/native_display_delegate.h"
10
11 namespace ui {
12
13 QueryContentProtectionTask::QueryContentProtectionTask(
14 DisplayLayoutManager* layout_manager,
15 NativeDisplayDelegate* native_display_delegate,
16 int64_t display_id,
17 const ResponseCallback& callback)
18 : layout_manager_(layout_manager),
19 native_display_delegate_(native_display_delegate),
20 display_id_(display_id),
21 callback_(callback),
22 pending_requests_(0),
23 weak_ptr_factory_(this) {
24 }
25
26 QueryContentProtectionTask::~QueryContentProtectionTask() {
27 }
28
29 void QueryContentProtectionTask::Run() {
30 std::vector<DisplaySnapshot*> hdcp_capable_displays;
31 for (DisplaySnapshot* display : layout_manager_->GetDisplayStates()) {
32 // Query display if it is in mirror mode or client on the same display.
33 if (!layout_manager_->IsMirroring() && display->display_id() != display_id_)
34 continue;
35
36 response_.link_mask |= display->type();
37
38 switch (display->type()) {
39 case DISPLAY_CONNECTION_TYPE_UNKNOWN:
40 callback_.Run(response_);
41 return;
42 case DISPLAY_CONNECTION_TYPE_DISPLAYPORT:
43 case DISPLAY_CONNECTION_TYPE_DVI:
44 case DISPLAY_CONNECTION_TYPE_HDMI:
45 hdcp_capable_displays.push_back(display);
46 break;
47 case DISPLAY_CONNECTION_TYPE_INTERNAL:
48 case DISPLAY_CONNECTION_TYPE_VGA:
49 case DISPLAY_CONNECTION_TYPE_NETWORK:
50 case DISPLAY_CONNECTION_TYPE_VIRTUAL:
51 // No protections for these types. Do nothing.
52 break;
53 case DISPLAY_CONNECTION_TYPE_NONE:
54 NOTREACHED();
55 break;
56 }
57 }
58
59 response_.success = true;
60 pending_requests_ = hdcp_capable_displays.size();
61 if (pending_requests_ != 0) {
62 for (DisplaySnapshot* display : hdcp_capable_displays) {
63 native_display_delegate_->GetHDCPState(
64 *display, base::Bind(&QueryContentProtectionTask::OnHDCPStateUpdate,
65 weak_ptr_factory_.GetWeakPtr()));
66 }
67 } else {
68 callback_.Run(response_);
69 }
70 }
71
72 void QueryContentProtectionTask::OnHDCPStateUpdate(bool success,
73 HDCPState state) {
74 response_.success &= success;
75 if (state == HDCP_STATE_ENABLED)
76 response_.enabled |= CONTENT_PROTECTION_METHOD_HDCP;
77 else
78 response_.unfulfilled |= CONTENT_PROTECTION_METHOD_HDCP;
79
80 pending_requests_--;
81 // Wait for all the requests to finish before invoking the callback.
82 if (pending_requests_ != 0)
83 return;
84
85 callback_.Run(response_);
86 }
87
88 } // namespace ui
OLDNEW
« no previous file with comments | « ui/display/chromeos/query_content_protection_task.h ('k') | ui/display/chromeos/query_content_protection_task_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698