| 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
|
|
|