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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/media/output_protection_proxy.cc
diff --git a/chrome/browser/media/output_protection_proxy.cc b/chrome/browser/media/output_protection_proxy.cc
new file mode 100644
index 0000000000000000000000000000000000000000..49fdefd69ef2989ea435e9ab2f00fd158f03533e
--- /dev/null
+++ b/chrome/browser/media/output_protection_proxy.cc
@@ -0,0 +1,97 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/media/output_protection_proxy.h"
+
+#include "build/build_config.h"
+#include "chrome/browser/media/media_capture_devices_dispatcher.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/render_frame_host.h"
+#include "content/public/browser/web_contents.h"
+#include "ui/display/types/display_constants.h"
+
+namespace chrome {
+
+OutputProtectionProxy::OutputProtectionProxy(int render_process_id,
+ int render_frame_id)
+ : render_process_id_(render_process_id),
+ render_frame_id_(render_frame_id),
+#if defined(OS_CHROMEOS)
+ output_protection_delegate_(render_process_id, render_frame_id),
+#endif // defined(OS_CHROMEOS)
+ weak_ptr_factory_(this) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+}
+
+OutputProtectionProxy::~OutputProtectionProxy() {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+}
+
+void OutputProtectionProxy::QueryStatus(const QueryStatusCallback& callback) {
+ DVLOG(1) << __FUNCTION__;
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+
+ content::RenderFrameHost* rfh =
+ 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.
+ if (!rfh) {
+ LOG(WARNING) << "RenderFrameHost is not alive.";
+ callback.Run(false, 0, 0);
+ return;
+ }
+
+#if defined(OS_CHROMEOS)
+ output_protection_delegate_.QueryStatus(
+ base::Bind(&OutputProtectionProxy::QueryStatusComplete,
+ weak_ptr_factory_.GetWeakPtr(), callback));
+#else // defined(OS_CHROMEOS)
+ QueryStatusComplete(callback, true, 0, 0);
+#endif // defined(OS_CHROMEOS)
+}
+
+void OutputProtectionProxy::EnableProtection(
+ uint32_t desired_method_mask,
+ const EnableProtectionCallback& callback) {
+ DVLOG(1) << __FUNCTION__;
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+
+#if defined(OS_CHROMEOS)
+ output_protection_delegate_.EnableProtection(desired_method_mask, callback);
+#else // defined(OS_CHROMEOS)
+ callback.Run(false);
ddorwin 2016/06/23 19:24:28 NOTIMPLEMENTED()?
xhwang 2016/06/23 20:53:49 Done.
+#endif // defined(OS_CHROMEOS)
+}
+
+void OutputProtectionProxy::QueryStatusComplete(
+ const QueryStatusCallback& callback,
+ bool success,
+ uint32_t link_mask,
+ uint32_t protection_mask) {
+ DVLOG(1) << __FUNCTION__ << ": " << success << ", " << link_mask;
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+
+ content::RenderFrameHost* rfh =
+ content::RenderFrameHost::FromID(render_process_id_, render_frame_id_);
+ // 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
+ // be removed.
+ if (!rfh) {
+ LOG(WARNING) << "RenderFrameHost is not alive.";
+ callback.Run(false, 0, 0);
+ return;
+ }
+
+ uint32_t new_link_mask = link_mask;
+ // If we successfully retrieved the device level status, check for capturers.
+ if (success) {
+ const bool insecure_capture_detected =
ddorwin 2016/06/23 19:24:28 nit: is_...
xhwang 2016/06/23 20:53:49 Done.
+ MediaCaptureDevicesDispatcher::GetInstance()
+ ->IsInsecureCapturingInProgress(render_process_id_,
+ render_frame_id_);
+ if (insecure_capture_detected)
+ new_link_mask |= ui::DISPLAY_CONNECTION_TYPE_NETWORK;
+ }
+
+ callback.Run(success, new_link_mask, protection_mask);
+}
+
+} // namespace chrome

Powered by Google App Engine
This is Rietveld 408576698