OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 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 "chrome/browser/media/output_protection_proxy.h" | |
6 | |
7 #include "build/build_config.h" | |
8 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | |
9 #include "content/public/browser/render_frame_host.h" | |
10 #include "content/public/browser/web_contents.h" | |
11 #include "ui/display/types/display_constants.h" | |
12 | |
13 namespace chrome { | |
14 | |
15 OutputProtectionProxy::OutputProtectionProxy(int render_process_id, | |
16 int render_frame_id) | |
17 : render_process_id_(render_process_id), | |
18 render_frame_id_(render_frame_id), | |
19 #if defined(OS_CHROMEOS) | |
20 output_protection_delegate_(render_process_id, render_frame_id), | |
21 #endif // defined(OS_CHROMEOS) | |
22 weak_ptr_factory_(this) { | |
23 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | |
24 } | |
25 | |
26 OutputProtectionProxy::~OutputProtectionProxy() { | |
27 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
28 } | |
29 | |
30 void OutputProtectionProxy::QueryStatus(const QueryStatusCallback& callback) { | |
31 DVLOG(1) << __FUNCTION__; | |
32 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
33 | |
34 #if defined(OS_CHROMEOS) | |
35 output_protection_delegate_.QueryStatus( | |
36 base::Bind(&OutputProtectionProxy::ProcessQueryStatusResult, | |
37 weak_ptr_factory_.GetWeakPtr(), callback)); | |
38 #else // defined(OS_CHROMEOS) | |
39 ProcessQueryStatusResult(callback, true, 0, 0); | |
40 #endif // defined(OS_CHROMEOS) | |
41 } | |
42 | |
43 void OutputProtectionProxy::EnableProtection( | |
44 uint32_t desired_method_mask, | |
45 const EnableProtectionCallback& callback) { | |
46 DVLOG(1) << __FUNCTION__; | |
47 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
48 | |
49 #if defined(OS_CHROMEOS) | |
50 output_protection_delegate_.EnableProtection(desired_method_mask, callback); | |
51 #else // defined(OS_CHROMEOS) | |
52 NOTIMPLEMENTED(); | |
53 callback.Run(false); | |
54 #endif // defined(OS_CHROMEOS) | |
55 } | |
56 | |
57 void OutputProtectionProxy::ProcessQueryStatusResult( | |
58 const QueryStatusCallback& callback, | |
59 bool success, | |
60 uint32_t link_mask, | |
61 uint32_t protection_mask) { | |
62 DVLOG(1) << __FUNCTION__ << ": " << success << ", " << link_mask; | |
63 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
64 | |
65 content::RenderFrameHost* rfh = | |
66 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); | |
67 // TODO(xjz): Investigate whether this check (and the other one above) should | |
ddorwin
2016/06/23 21:36:35
You removed the one above per jrummell's comment.
xhwang
2016/06/23 21:52:35
Yeah, this class is just a proxy, output_protectio
| |
68 // be removed. | |
69 if (!rfh) { | |
70 LOG(WARNING) << "RenderFrameHost is not alive."; | |
71 callback.Run(false, 0, 0); | |
72 return; | |
73 } | |
74 | |
75 uint32_t new_link_mask = link_mask; | |
76 // If we successfully retrieved the device level status, check for capturers. | |
77 if (success) { | |
78 const bool is_insecure_capture_detected = | |
79 MediaCaptureDevicesDispatcher::GetInstance() | |
80 ->IsInsecureCapturingInProgress(render_process_id_, | |
81 render_frame_id_); | |
82 if (is_insecure_capture_detected) | |
83 new_link_mask |= ui::DISPLAY_CONNECTION_TYPE_NETWORK; | |
84 } | |
85 | |
86 callback.Run(success, new_link_mask, protection_mask); | |
87 } | |
88 | |
89 } // namespace chrome | |
OLD | NEW |