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

Unified Diff: content/browser/renderer_host/media/media_stream_manager.cc

Issue 2424163004: Factor out authorization from AudioRendererHost. (Closed)
Patch Set: Dale's comments. Created 4 years, 1 month 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/browser/renderer_host/media/media_stream_manager.cc
diff --git a/content/browser/renderer_host/media/media_stream_manager.cc b/content/browser/renderer_host/media/media_stream_manager.cc
index 28fd3dfd9da939c95de268b7bff8135763cc41dd..9100ab2eb5a0a5a07c172a40b9d1865dd93fc3d5 100644
--- a/content/browser/renderer_host/media/media_stream_manager.cc
+++ b/content/browser/renderer_host/media/media_stream_manager.cc
@@ -1970,6 +1970,21 @@ bool MediaStreamManager::DoesMediaDeviceIDMatchHMAC(
}
// static
+bool MediaStreamManager::IsValidDeviceId(const std::string& device_id) {
o1ka 2016/11/03 10:07:22 What is the reason for MediaStreaMgr to expose it?
Max Morin 2016/11/10 14:59:52 I figured I'd put it with the rest of the hashing-
+ constexpr int hash_size = 64; // 32 bytes * 2 char/byte hex encoding
+ if (media::AudioDeviceDescription::IsDefaultDevice(device_id) ||
+ device_id == media::AudioDeviceDescription::kCommunicationsDeviceId)
+ return true;
+
+ if (device_id.length() != hash_size)
+ return false;
+
+ return std::all_of(device_id.cbegin(), device_id.cend(), [](const char& c) {
+ return base::IsAsciiLower(c) || base::IsAsciiDigit(c);
+ });
+}
+
+// static
bool MediaStreamManager::IsOriginAllowed(int render_process_id,
const url::Origin& origin) {
if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanRequestURL(

Powered by Google App Engine
This is Rietveld 408576698