#include "chrome/browser/devtools/protocol/cast_handler.h"
#include <utility>
#include "base/functional/bind.h"
#include "base/ranges/algorithm.h"
#include "chrome/browser/media/router/media_router_feature.h"
#include "chrome/browser/ui/media_router/media_router_ui_helper.h"
#include "components/media_router/browser/media_router.h"
#include "components/media_router/browser/media_router_factory.h"
#include "components/media_router/browser/presentation/presentation_service_delegate_impl.h"
#include "components/media_router/common/media_source.h"
#include "components/media_router/common/mojom/media_router.mojom.h"
#include "components/sessions/content/session_tab_helper.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/web_contents.h"
MediaRoute;
Response;
Sink;
namespace {
constexpr char kMediaRouterErrorMessage[] = …;
media_router::MediaRouter* GetMediaRouter(content::WebContents* web_contents) { … }
}
class CastHandler::MediaRoutesObserver
: public media_router::MediaRoutesObserver { … };
class CastHandler::IssuesObserver : public media_router::IssuesObserver { … };
CastHandler::CastHandler(content::WebContents* web_contents,
protocol::UberDispatcher* dispatcher)
: … { … }
CastHandler::~CastHandler() = default;
Response CastHandler::SetSinkToUse(const std::string& in_sink_name) { … }
void CastHandler::StartDesktopMirroring(
const std::string& in_sink_name,
std::unique_ptr<StartDesktopMirroringCallback> callback) { … }
void CastHandler::StartTabMirroring(
const std::string& in_sink_name,
std::unique_ptr<StartTabMirroringCallback> callback) { … }
Response CastHandler::StopCasting(const std::string& in_sink_name) { … }
Response CastHandler::Enable(protocol::Maybe<std::string> in_presentation_url) { … }
Response CastHandler::Disable() { … }
void CastHandler::OnSinksUpdated(
const std::vector<media_router::MediaSinkWithCastModes>& sinks) { … }
CastHandler::CastHandler(content::WebContents* web_contents)
: … { … }
Response CastHandler::EnsureInitialized() { … }
void CastHandler::StartPresentation(
const std::string& sink_name,
std::unique_ptr<media_router::StartPresentationContext> context) { … }
media_router::MediaSink::Id CastHandler::GetSinkIdByName(
const std::string& sink_name) const { … }
MediaRoute::Id CastHandler::GetRouteIdForSink(
const media_router::MediaSink::Id& sink_id) const { … }
void CastHandler::StartObservingForSinks(
protocol::Maybe<std::string> presentation_url) { … }
void CastHandler::SendSinkUpdate() { … }
void CastHandler::OnDesktopMirroringStarted(
std::unique_ptr<StartDesktopMirroringCallback> callback,
media_router::mojom::RoutePresentationConnectionPtr connection,
const media_router::RouteRequestResult& result) { … }
void CastHandler::OnTabMirroringStarted(
std::unique_ptr<StartTabMirroringCallback> callback,
media_router::mojom::RoutePresentationConnectionPtr connection,
const media_router::RouteRequestResult& result) { … }
void CastHandler::OnPresentationStarted(
std::unique_ptr<media_router::StartPresentationContext> context,
media_router::mojom::RoutePresentationConnectionPtr connection,
const media_router::RouteRequestResult& result) { … }
void CastHandler::OnIssue(const std::string& issue) { … }