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

Side by Side Diff: chrome/browser/media/output_protection_proxy.cc

Issue 2085063002: media: Add OutputProtectionProxy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix windows compile error Created 4 years, 6 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
(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/browser_thread.h"
10 #include "content/public/browser/render_frame_host.h"
11 #include "content/public/browser/web_contents.h"
12 #include "ui/display/types/display_constants.h"
13
14 namespace chrome {
15
16 OutputProtectionProxy::OutputProtectionProxy(int render_process_id,
17 int render_frame_id)
18 : render_process_id_(render_process_id),
19 render_frame_id_(render_frame_id),
20 #if defined(OS_CHROMEOS)
21 output_protection_delegate_(render_process_id, render_frame_id),
22 #endif // defined(OS_CHROMEOS)
23 weak_ptr_factory_(this) {
24 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
25 }
26
27 OutputProtectionProxy::~OutputProtectionProxy() {
28 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
29 }
30
31 void OutputProtectionProxy::QueryStatus(const QueryStatusCallback& callback) {
32 DVLOG(1) << __FUNCTION__;
33 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
34
35 content::RenderFrameHost* rfh =
36 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_);
jrummell 2016/06/23 18:07:57 It appears you just copied the code, but why check
xhwang 2016/06/23 20:53:49 Makes sense. Done.
37 if (!rfh) {
38 LOG(WARNING) << "RenderFrameHost is not alive.";
39 callback.Run(false, 0, 0);
40 return;
41 }
42
43 #if defined(OS_CHROMEOS)
44 output_protection_delegate_.QueryStatus(
45 base::Bind(&OutputProtectionProxy::QueryStatusComplete,
46 weak_ptr_factory_.GetWeakPtr(), callback));
47 #else // defined(OS_CHROMEOS)
48 QueryStatusComplete(callback, true, 0, 0);
49 #endif // defined(OS_CHROMEOS)
50 }
51
52 void OutputProtectionProxy::EnableProtection(
53 uint32_t desired_method_mask,
54 const EnableProtectionCallback& callback) {
55 DVLOG(1) << __FUNCTION__;
56 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
57
58 #if defined(OS_CHROMEOS)
59 output_protection_delegate_.EnableProtection(desired_method_mask, callback);
60 #else // defined(OS_CHROMEOS)
61 callback.Run(false);
ddorwin 2016/06/23 19:24:28 NOTIMPLEMENTED()?
xhwang 2016/06/23 20:53:49 Done.
62 #endif // defined(OS_CHROMEOS)
63 }
64
65 void OutputProtectionProxy::QueryStatusComplete(
66 const QueryStatusCallback& callback,
67 bool success,
68 uint32_t link_mask,
69 uint32_t protection_mask) {
70 DVLOG(1) << __FUNCTION__ << ": " << success << ", " << link_mask;
71 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
72
73 content::RenderFrameHost* rfh =
74 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_);
75 // TODO(xjz): Investigate whether this check (and the other one above) should
ddorwin 2016/06/23 19:24:28 It definitely seems weird that we have to protect
xhwang 2016/06/23 20:53:49 Agreed. But I'd like to keep this TODO here and ad
76 // be removed.
77 if (!rfh) {
78 LOG(WARNING) << "RenderFrameHost is not alive.";
79 callback.Run(false, 0, 0);
80 return;
81 }
82
83 uint32_t new_link_mask = link_mask;
84 // If we successfully retrieved the device level status, check for capturers.
85 if (success) {
86 const bool insecure_capture_detected =
ddorwin 2016/06/23 19:24:28 nit: is_...
xhwang 2016/06/23 20:53:49 Done.
87 MediaCaptureDevicesDispatcher::GetInstance()
88 ->IsInsecureCapturingInProgress(render_process_id_,
89 render_frame_id_);
90 if (insecure_capture_detected)
91 new_link_mask |= ui::DISPLAY_CONNECTION_TYPE_NETWORK;
92 }
93
94 callback.Run(success, new_link_mask, protection_mask);
95 }
96
97 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698