#include "content/browser/presentation/presentation_service_impl.h"
#include <stddef.h>
#include <stdint.h>
#include <algorithm>
#include <memory>
#include <utility>
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/presentation_request.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_client.h"
#include "content/public/common/content_switches.h"
PresentationConnectionState;
PresentationError;
PresentationErrorPtr;
PresentationErrorType;
PresentationInfo;
PresentationInfoPtr;
ScreenAvailability;
namespace content {
namespace {
static constexpr int kInvalidRequestId = …;
static constexpr size_t kMaxPresentationIdLength = …;
int GetNextRequestId() { … }
void InvokeNewPresentationCallbackWithError(
PresentationServiceImpl::NewPresentationCallback callback) { … }
}
PresentationServiceImpl::PresentationServiceImpl(
RenderFrameHost* render_frame_host,
WebContents* web_contents,
ControllerPresentationServiceDelegate* controller_delegate,
ReceiverPresentationServiceDelegate* receiver_delegate)
: … { … }
PresentationServiceImpl::~PresentationServiceImpl() { … }
std::unique_ptr<PresentationServiceImpl> PresentationServiceImpl::Create(
RenderFrameHost* render_frame_host) { … }
void PresentationServiceImpl::Bind(
mojo::PendingReceiver<blink::mojom::PresentationService> receiver) { … }
void PresentationServiceImpl::SetController(
mojo::PendingRemote<blink::mojom::PresentationController>
presentation_controller_remote) { … }
void PresentationServiceImpl::SetReceiver(
mojo::PendingRemote<blink::mojom::PresentationReceiver>
presentation_receiver_remote) { … }
void PresentationServiceImpl::ListenForScreenAvailability(const GURL& url) { … }
void PresentationServiceImpl::StopListeningForScreenAvailability(
const GURL& url) { … }
void PresentationServiceImpl::StartPresentation(
const std::vector<GURL>& presentation_urls,
NewPresentationCallback callback) { … }
void PresentationServiceImpl::ReconnectPresentation(
const std::vector<GURL>& presentation_urls,
const std::string& presentation_id,
NewPresentationCallback callback) { … }
int PresentationServiceImpl::RegisterReconnectPresentationCallback(
NewPresentationCallback* callback) { … }
void PresentationServiceImpl::ListenForConnectionStateChange(
const PresentationInfo& connection) { … }
void PresentationServiceImpl::OnStartPresentationSucceeded(
int request_id,
blink::mojom::PresentationConnectionResultPtr result) { … }
void PresentationServiceImpl::OnStartPresentationError(
int request_id,
const blink::mojom::PresentationError& error) { … }
void PresentationServiceImpl::OnReconnectPresentationSucceeded(
int request_id,
blink::mojom::PresentationConnectionResultPtr result) { … }
void PresentationServiceImpl::OnReconnectPresentationError(
int request_id,
const blink::mojom::PresentationError& error) { … }
bool PresentationServiceImpl::RunAndEraseReconnectPresentationMojoCallback(
int request_id,
blink::mojom::PresentationConnectionResultPtr result,
blink::mojom::PresentationErrorPtr error) { … }
void PresentationServiceImpl::SetDefaultPresentationUrls(
const std::vector<GURL>& presentation_urls) { … }
void PresentationServiceImpl::CloseConnection(
const GURL& presentation_url,
const std::string& presentation_id) { … }
void PresentationServiceImpl::Terminate(const GURL& presentation_url,
const std::string& presentation_id) { … }
void PresentationServiceImpl::SetControllerDelegateForTesting(
ControllerPresentationServiceDelegate* controller_delegate) { … }
void PresentationServiceImpl::OnConnectionStateChanged(
const PresentationInfo& connection,
const PresentationConnectionStateChangeInfo& info) { … }
bool PresentationServiceImpl::FrameMatches(
content::RenderFrameHost* render_frame_host) const { … }
void PresentationServiceImpl::OnConnectionError() { … }
PresentationServiceDelegate*
PresentationServiceImpl::GetPresentationServiceDelegate() { … }
void PresentationServiceImpl::OnReceiverConnectionAvailable(
blink::mojom::PresentationConnectionResultPtr result) { … }
void PresentationServiceImpl::DidFinishNavigation(
NavigationHandle* navigation_handle) { … }
void PresentationServiceImpl::Reset() { … }
void PresentationServiceImpl::OnDelegateDestroyed() { … }
void PresentationServiceImpl::OnDefaultPresentationStarted(
blink::mojom::PresentationConnectionResultPtr result) { … }
PresentationServiceImpl::ScreenAvailabilityListenerImpl::
ScreenAvailabilityListenerImpl(const GURL& availability_url,
PresentationServiceImpl* service)
: … { … }
PresentationServiceImpl::ScreenAvailabilityListenerImpl::
~ScreenAvailabilityListenerImpl() = default;
GURL PresentationServiceImpl::ScreenAvailabilityListenerImpl::
GetAvailabilityUrl() { … }
void PresentationServiceImpl::ScreenAvailabilityListenerImpl::
OnScreenAvailabilityChanged(blink::mojom::ScreenAvailability availability) { … }
PresentationServiceImpl::NewPresentationCallbackWrapper::
NewPresentationCallbackWrapper(NewPresentationCallback callback)
: … { … }
PresentationServiceImpl::NewPresentationCallbackWrapper::
~NewPresentationCallbackWrapper() { … }
void PresentationServiceImpl::NewPresentationCallbackWrapper::Run(
blink::mojom::PresentationConnectionResultPtr result,
blink::mojom::PresentationErrorPtr error) { … }
}