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

Unified Diff: content/public/browser/media_device_id.cc

Issue 2424163004: Factor out authorization from AudioRendererHost. (Closed)
Patch Set: const& 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
« no previous file with comments | « content/public/browser/media_device_id.h ('k') | content/test/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/browser/media_device_id.cc
diff --git a/content/public/browser/media_device_id.cc b/content/public/browser/media_device_id.cc
index 97faa1e1a40ec9476959b9458e1d1e4345c98909..e7a3ac970274857163f759239bea0cc6d5b2a677 100644
--- a/content/public/browser/media_device_id.cc
+++ b/content/public/browser/media_device_id.cc
@@ -3,8 +3,10 @@
// found in the LICENSE file.
#include "content/public/browser/media_device_id.h"
+#include "base/strings/string_util.h"
#include "content/browser/browser_main_loop.h"
#include "content/browser/renderer_host/media/media_stream_manager.h"
+#include "media/audio/audio_device_description.h"
namespace content {
@@ -36,4 +38,18 @@ bool GetMediaDeviceIDForHMAC(MediaStreamType stream_type,
device_id);
}
+bool IsValidDeviceId(const std::string& device_id) {
+ 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);
+ });
+}
+
} // namespace content
« no previous file with comments | « content/public/browser/media_device_id.h ('k') | content/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698