| Index: content/renderer/presentation/presentation_dispatcher.cc
|
| diff --git a/content/renderer/presentation/presentation_dispatcher.cc b/content/renderer/presentation/presentation_dispatcher.cc
|
| index 34a1cfe1286da2772e792a59fc4924c14c7c162d..f88a82ee856dc6a27b9a2d1fd29d7f89145ed552 100644
|
| --- a/content/renderer/presentation/presentation_dispatcher.cc
|
| +++ b/content/renderer/presentation/presentation_dispatcher.cc
|
| @@ -259,8 +259,16 @@ void PresentationDispatcher::closeSession(
|
| void PresentationDispatcher::terminateSession(
|
| const blink::WebURL& presentationUrl,
|
| const blink::WebString& presentationId) {
|
| - ConnectToPresentationServiceIfNeeded();
|
| - presentation_service_->Terminate(presentationUrl, presentationId.utf8());
|
| + if (receiver_) {
|
| + receiver_->closeWindow();
|
| + return;
|
| + }
|
| +
|
| + if (controller_) {
|
| + ConnectToPresentationServiceIfNeeded();
|
| + presentation_service_->Terminate(presentationUrl, presentationId.utf8());
|
| + return;
|
| + }
|
| }
|
|
|
| void PresentationDispatcher::getAvailability(
|
| @@ -449,13 +457,22 @@ void PresentationDispatcher::OnReceiverConnectionAvailable(
|
| void PresentationDispatcher::OnConnectionStateChanged(
|
| blink::mojom::PresentationSessionInfoPtr connection,
|
| blink::mojom::PresentationConnectionState state) {
|
| - if (!controller_)
|
| + if (!controller_ && !receiver_)
|
| return;
|
|
|
| - DCHECK(!connection.is_null());
|
| - controller_->didChangeSessionState(
|
| - new PresentationConnectionClient(std::move(connection)),
|
| - GetWebPresentationConnectionStateFromMojo(state));
|
| + if (receiver_) {
|
| + receiver_->didChangeSessionState(
|
| + GetWebPresentationConnectionStateFromMojo(state));
|
| + return;
|
| + }
|
| +
|
| + if (controller_) {
|
| + DCHECK(!connection.is_null());
|
| + controller_->didChangeSessionState(
|
| + new PresentationConnectionClient(std::move(connection)),
|
| + GetWebPresentationConnectionStateFromMojo(state));
|
| + return;
|
| + }
|
| }
|
|
|
| void PresentationDispatcher::OnConnectionClosed(
|
|
|