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

Unified Diff: content/renderer/media/secure_display_link_tracker.h

Issue 1873293002: Report if video capturing meets output protection requirement. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed oshima and nasko's comments, and rebased. Created 4 years, 7 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: content/renderer/media/secure_display_link_tracker.h
diff --git a/content/renderer/media/secure_display_link_tracker.h b/content/renderer/media/secure_display_link_tracker.h
new file mode 100644
index 0000000000000000000000000000000000000000..d1772b48f92865d3f01a6443f9962cceef9f3c89
--- /dev/null
+++ b/content/renderer/media/secure_display_link_tracker.h
@@ -0,0 +1,57 @@
+// 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.
+
+#ifndef CONTENT_RENDERER_MEDIA_SECURE_DISPLAY_LINK_TRACKER_H_
+#define CONTENT_RENDERER_MEDIA_SECURE_DISPLAY_LINK_TRACKER_H_
+
+#include <vector>
+
+// Tracks all connected links (video sinks / tracks), and reports if they are
+// all secure for video capturing.
+template <typename T>
+class SecureDisplayLinkTracker {
+ public:
+ SecureDisplayLinkTracker() {}
+ ~SecureDisplayLinkTracker() {}
+
+ void Add(T* link, bool is_link_secure);
+ void Remove(T* link);
+ void Update(T* link, bool is_link_secure);
+ bool is_capturing_secure() const { return insecure_links_.empty(); }
+
+ private:
+ // Record every insecure links.
+ std::vector<T*> insecure_links_;
+
+ DISALLOW_COPY_AND_ASSIGN(SecureDisplayLinkTracker);
+};
+
+template <typename T>
+void SecureDisplayLinkTracker<T>::Add(T* link, bool is_link_secure) {
+ DCHECK(std::find(insecure_links_.begin(), insecure_links_.end(), link) ==
+ insecure_links_.end());
+
+ if (!is_link_secure)
+ insecure_links_.push_back(link);
+}
+
+template <typename T>
+void SecureDisplayLinkTracker<T>::Remove(T* link) {
+ auto it = std::find(insecure_links_.begin(), insecure_links_.end(), link);
+ if (it != insecure_links_.end())
+ insecure_links_.erase(it);
+}
+
+template <typename T>
+void SecureDisplayLinkTracker<T>::Update(T* link, bool is_link_secure) {
+ auto it = std::find(insecure_links_.begin(), insecure_links_.end(), link);
+ if (it != insecure_links_.end()) {
+ if (is_link_secure)
+ insecure_links_.erase(it);
+ return;
+ }
+ Add(link, is_link_secure);
+}
+
+#endif // CONTENT_RENDERER_MEDIA_SECURE_DISPLAY_LINK_TRACKER_H_
« no previous file with comments | « content/renderer/media/pepper_to_video_track_adapter_unittest.cc ('k') | content/renderer/media/user_media_client_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698