#include "chrome/browser/media/webrtc/media_stream_capture_indicator.h"
#include <stddef.h>
#include <memory>
#include <string>
#include <utility>
#include "base/check_op.h"
#include "base/containers/contains.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/notreached.h"
#include "base/observer_list.h"
#include "build/build_config.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/content_settings/chrome_content_settings_utils.h"
#include "chrome/browser/status_icons/status_icon.h"
#include "chrome/browser/status_icons/status_tray.h"
#include "chrome/browser/tab_contents/tab_util.h"
#include "components/url_formatter/elide_url.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/browser/web_contents_observer.h"
#include "extensions/buildflags/buildflags.h"
#include "third_party/blink/public/mojom/mediastream/media_stream.mojom.h"
#include "ui/gfx/image/image_skia.h"
#if !BUILDFLAG(IS_ANDROID)
#include "chrome/browser/media/webrtc/media_stream_focus_delegate.h"
#include "chrome/grit/branded_strings.h"
#include "components/vector_icons/vector_icons.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/paint_vector_icon.h"
#endif
#if BUILDFLAG(ENABLE_EXTENSIONS)
#include "base/strings/utf_string_conversions.h"
#include "chrome/common/extensions/extension_constants.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/common/extension.h"
#endif
#if BUILDFLAG(IS_CHROMEOS)
#include "chrome/browser/chromeos/policy/dlp/dlp_content_manager.h"
#endif
BrowserThread;
WebContents;
namespace {
#if BUILDFLAG(ENABLE_EXTENSIONS)
const extensions::Extension* GetExtension(WebContents* web_contents) { … }
#endif
std::u16string GetTitle(WebContents* web_contents) { … }
bool IsDeviceCapturingDisplay(const blink::MediaStreamDevice& device) { … }
ObserverMethod;
ObserverMethod GetObserverMethodToCall(const blink::MediaStreamDevice& device) { … }
}
class MediaStreamCaptureIndicator::WebContentsDeviceUsage
: public content::WebContentsObserver { … };
class MediaStreamCaptureIndicator::UIDelegate : public content::MediaStreamUI { … };
std::unique_ptr<content::MediaStreamUI>
MediaStreamCaptureIndicator::WebContentsDeviceUsage::RegisterMediaStream(
const blink::mojom::StreamDevices& devices,
std::unique_ptr<MediaStreamUI> ui,
const std::u16string application_title) { … }
void MediaStreamCaptureIndicator::WebContentsDeviceUsage::AddDevices(
const blink::mojom::StreamDevices& devices,
base::OnceClosure stop_callback,
int stop_callback_id) { … }
void MediaStreamCaptureIndicator::WebContentsDeviceUsage::RemoveDevices(
const blink::mojom::StreamDevices& devices,
int stop_callback_id) { … }
void MediaStreamCaptureIndicator::WebContentsDeviceUsage::StopMediaCapturing(
int media_type) { … }
void MediaStreamCaptureIndicator::WebContentsDeviceUsage::StopCallbacks(
std::map<int, base::OnceClosure>& stop_callbacks) { … }
int& MediaStreamCaptureIndicator::WebContentsDeviceUsage::GetStreamCount(
const blink::MediaStreamDevice& device) { … }
void MediaStreamCaptureIndicator::WebContentsDeviceUsage::AddDevice(
const blink::MediaStreamDevice& device) { … }
void MediaStreamCaptureIndicator::WebContentsDeviceUsage::RemoveDevice(
const blink::MediaStreamDevice& device) { … }
MediaStreamCaptureIndicator::MediaType
MediaStreamCaptureIndicator::GetMediaType(blink::mojom::MediaStreamType type) { … }
MediaStreamCaptureIndicator::Observer::~Observer() { … }
int MediaStreamCaptureIndicator::g_stop_callback_id_ = …;
MediaStreamCaptureIndicator::MediaStreamCaptureIndicator() = default;
MediaStreamCaptureIndicator::~MediaStreamCaptureIndicator() { … }
std::unique_ptr<content::MediaStreamUI>
MediaStreamCaptureIndicator::RegisterMediaStream(
content::WebContents* web_contents,
const blink::mojom::StreamDevices& devices,
std::unique_ptr<MediaStreamUI> ui,
const std::u16string application_title) { … }
void MediaStreamCaptureIndicator::ExecuteCommand(int command_id,
int event_flags) { … }
bool MediaStreamCaptureIndicator::CheckUsage(
content::WebContents* web_contents,
const WebContentsDeviceUsagePredicate& pred) const { … }
bool MediaStreamCaptureIndicator::IsCapturingUserMedia(
content::WebContents* web_contents) const { … }
bool MediaStreamCaptureIndicator::IsCapturingVideo(
content::WebContents* web_contents) const { … }
bool MediaStreamCaptureIndicator::IsCapturingAudio(
content::WebContents* web_contents) const { … }
bool MediaStreamCaptureIndicator::IsBeingMirrored(
content::WebContents* web_contents) const { … }
bool MediaStreamCaptureIndicator::IsCapturingWindow(
content::WebContents* web_contents) const { … }
bool MediaStreamCaptureIndicator::IsCapturingDisplay(
content::WebContents* web_contents) const { … }
void MediaStreamCaptureIndicator::StopMediaCapturing(
content::WebContents* web_contents,
int media_type) const { … }
void MediaStreamCaptureIndicator::UnregisterWebContents(
WebContents* web_contents) { … }
void MediaStreamCaptureIndicator::MaybeCreateStatusTrayIcon(bool audio,
bool video) { … }
void MediaStreamCaptureIndicator::MaybeDestroyStatusTrayIcon() { … }
void MediaStreamCaptureIndicator::UpdateNotificationUserInterface() { … }
void MediaStreamCaptureIndicator::GetStatusTrayIconInfo(
bool audio,
bool video,
gfx::ImageSkia* image,
std::u16string* tool_tip) { … }