#include "content/browser/media/media_devices_util.h"
#include <utility>
#include <vector>
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/strings/strcat.h"
#include "base/strings/string_split.h"
#include "base/strings/string_tokenizer.h"
#include "content/browser/browser_main_loop.h"
#include "content/browser/renderer_host/frame_tree.h"
#include "content/browser/renderer_host/frame_tree_node.h"
#include "content/browser/renderer_host/media/media_stream_manager.h"
#include "content/browser/renderer_host/render_frame_host_delegate.h"
#include "content/browser/renderer_host/render_frame_host_impl.h"
#include "content/common/features.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/common/content_client.h"
#include "crypto/hmac.h"
#include "media/base/media_switches.h"
#include "media/capture/video/video_capture_device_descriptor.h"
#include "net/cookies/site_for_cookies.h"
#include "url/origin.h"
namespace content {
MediaDeviceType;
MediaStreamType;
namespace {
void GotSalt(const std::string& frame_salt,
const url::Origin& origin,
bool has_focus,
bool is_background,
std::optional<ukm::SourceId> source_id,
MediaDeviceSaltAndOriginCallback callback,
bool are_persistent_device_ids_allowed,
const std::string& salt) { … }
void FinalizeGetRawMediaDeviceIDForHMAC(
MediaDeviceType type,
const MediaDeviceSaltAndOrigin& salt_and_origin,
const std::string& source_id,
scoped_refptr<base::SequencedTaskRunner> task_runner,
base::OnceCallback<void(const std::optional<std::string>&)> callback,
const MediaDeviceEnumeration& enumeration) { … }
MediaDeviceType ConvertToMediaDeviceType(MediaStreamType stream_type) { … }
}
MediaDeviceSaltAndOrigin::MediaDeviceSaltAndOrigin(
std::string device_id_salt,
url::Origin origin,
std::string group_id_salt,
bool has_focus,
bool is_background,
std::optional<ukm::SourceId> ukm_source_id)
: … { … }
MediaDeviceSaltAndOrigin::MediaDeviceSaltAndOrigin(
const MediaDeviceSaltAndOrigin& other) = default;
MediaDeviceSaltAndOrigin& MediaDeviceSaltAndOrigin::operator=(
const MediaDeviceSaltAndOrigin& other) = default;
MediaDeviceSaltAndOrigin::MediaDeviceSaltAndOrigin(
MediaDeviceSaltAndOrigin&& other) = default;
MediaDeviceSaltAndOrigin& MediaDeviceSaltAndOrigin::operator=(
MediaDeviceSaltAndOrigin&& other) = default;
MediaDeviceSaltAndOrigin::~MediaDeviceSaltAndOrigin() = default;
MediaDeviceSaltAndOrigin MediaDeviceSaltAndOrigin::Empty() { … }
void GetMediaDeviceSaltAndOrigin(GlobalRenderFrameHostId render_frame_host_id,
MediaDeviceSaltAndOriginCallback callback) { … }
blink::WebMediaDeviceInfo TranslateMediaDeviceInfo(
bool has_permission,
const MediaDeviceSaltAndOrigin& salt_and_origin,
const blink::WebMediaDeviceInfo& device_info) { … }
blink::WebMediaDeviceInfoArray TranslateMediaDeviceInfoArray(
bool has_permission,
const MediaDeviceSaltAndOrigin& salt_and_origin,
const blink::WebMediaDeviceInfoArray& device_infos) { … }
std::string CreateRandomMediaDeviceIDSalt() { … }
void GetHMACFromRawDeviceId(GlobalRenderFrameHostId render_frame_host_id,
const std::string& raw_device_id,
DeviceIdCallback hmac_device_id_callback) { … }
void GetRawDeviceIdFromHMAC(GlobalRenderFrameHostId render_frame_host_id,
const std::string& hmac_device_id,
MediaDeviceType media_device_type,
OptionalDeviceIdCallback raw_device_id_callback) { … }
std::string GetHMACForRawMediaDeviceID(
const MediaDeviceSaltAndOrigin& salt_and_origin,
const std::string& raw_device_id,
bool use_group_salt) { … }
bool DoesRawMediaDeviceIDMatchHMAC(
const MediaDeviceSaltAndOrigin& salt_and_origin,
const std::string& hmac_device_id,
const std::string& raw_device_id) { … }
void GetRawDeviceIDForMediaStreamHMAC(
MediaStreamType stream_type,
MediaDeviceSaltAndOrigin salt_and_origin,
std::string hmac_device_id,
scoped_refptr<base::SequencedTaskRunner> task_runner,
OptionalDeviceIdCallback callback) { … }
void GetRawDeviceIDForMediaDeviceHMAC(
MediaDeviceType device_type,
MediaDeviceSaltAndOrigin salt_and_origin,
std::string hmac_device_id,
scoped_refptr<base::SequencedTaskRunner> task_runner,
OptionalDeviceIdCallback callback) { … }
}