OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/chromeos/display/output_protection_delegate.h" | 5 #include "chrome/browser/chromeos/display/output_protection_delegate.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/shell_delegate.h" | 8 #include "ash/shell_delegate.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | 10 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 desired_method_mask_ = desired_method_mask; | 117 desired_method_mask_ = desired_method_mask; |
118 } | 118 } |
119 | 119 |
120 void OutputProtectionDelegate::QueryStatusComplete( | 120 void OutputProtectionDelegate::QueryStatusComplete( |
121 const QueryStatusCallback& callback, | 121 const QueryStatusCallback& callback, |
122 const ui::DisplayConfigurator::QueryProtectionResponse& response) { | 122 const ui::DisplayConfigurator::QueryProtectionResponse& response) { |
123 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 123 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
124 | 124 |
125 content::RenderFrameHost* rfh = | 125 content::RenderFrameHost* rfh = |
126 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); | 126 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); |
| 127 // TODO(xjz): Investigate whether this check (and the other one above) should |
| 128 // be removed. |
127 if (!rfh) { | 129 if (!rfh) { |
128 LOG(WARNING) << "RenderFrameHost is not alive."; | 130 LOG(WARNING) << "RenderFrameHost is not alive."; |
129 callback.Run(false, 0, 0); | 131 callback.Run(false, 0, 0); |
130 return; | 132 return; |
131 } | 133 } |
132 | 134 |
133 uint32_t link_mask = response.link_mask; | 135 uint32_t link_mask = response.link_mask; |
134 // If we successfully retrieved the device level status, check for capturers. | 136 // If we successfully retrieved the device level status, check for capturers. |
135 if (response.success) { | 137 if (response.success) { |
136 const bool capture_detected = | 138 const bool insecure_capture_detected = |
137 // Check for tab capture on the current tab. | |
138 content::WebContents::FromRenderFrameHost(rfh)->GetCapturerCount() > | |
139 0 || | |
140 // Check for desktop capture. | |
141 MediaCaptureDevicesDispatcher::GetInstance() | 139 MediaCaptureDevicesDispatcher::GetInstance() |
142 ->IsDesktopCaptureInProgress(); | 140 ->IsInsecureCapturingInProgress(render_process_id_, |
143 if (capture_detected) | 141 render_frame_id_); |
| 142 if (insecure_capture_detected) |
144 link_mask |= ui::DISPLAY_CONNECTION_TYPE_NETWORK; | 143 link_mask |= ui::DISPLAY_CONNECTION_TYPE_NETWORK; |
145 } | 144 } |
146 | 145 |
147 callback.Run(response.success, link_mask, response.protection_mask); | 146 callback.Run(response.success, link_mask, response.protection_mask); |
148 } | 147 } |
149 | 148 |
150 void OutputProtectionDelegate::EnableProtectionComplete( | 149 void OutputProtectionDelegate::EnableProtectionComplete( |
151 const EnableProtectionCallback& callback, | 150 const EnableProtectionCallback& callback, |
152 bool success) { | 151 bool success) { |
153 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 152 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
(...skipping 30 matching lines...) Expand all Loading... |
184 display_id_ = new_display_id; | 183 display_id_ = new_display_id; |
185 } | 184 } |
186 | 185 |
187 void OutputProtectionDelegate::OnWindowDestroying(aura::Window* window) { | 186 void OutputProtectionDelegate::OnWindowDestroying(aura::Window* window) { |
188 DCHECK_EQ(window, window_); | 187 DCHECK_EQ(window, window_); |
189 window_->RemoveObserver(this); | 188 window_->RemoveObserver(this); |
190 window_ = nullptr; | 189 window_ = nullptr; |
191 } | 190 } |
192 | 191 |
193 } // namespace chromeos | 192 } // namespace chromeos |
OLD | NEW |