Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/presentation/presentation_dispatcher.h" | 5 #include "content/renderer/presentation/presentation_dispatcher.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 252 const blink::WebURL& presentationUrl, | 252 const blink::WebURL& presentationUrl, |
| 253 const blink::WebString& presentationId) { | 253 const blink::WebString& presentationId) { |
| 254 ConnectToPresentationServiceIfNeeded(); | 254 ConnectToPresentationServiceIfNeeded(); |
| 255 presentation_service_->CloseConnection(presentationUrl, | 255 presentation_service_->CloseConnection(presentationUrl, |
| 256 presentationId.utf8()); | 256 presentationId.utf8()); |
| 257 } | 257 } |
| 258 | 258 |
| 259 void PresentationDispatcher::terminateSession( | 259 void PresentationDispatcher::terminateSession( |
| 260 const blink::WebURL& presentationUrl, | 260 const blink::WebURL& presentationUrl, |
| 261 const blink::WebString& presentationId) { | 261 const blink::WebString& presentationId) { |
| 262 ConnectToPresentationServiceIfNeeded(); | 262 if (receiver_) { |
| 263 presentation_service_->Terminate(presentationUrl, presentationId.utf8()); | 263 receiver_->closeWindow(); |
|
imcheng
2016/11/28 22:12:01
If the receiver frame calls terminate, how do we e
zhaobin
2017/02/16 00:42:30
closeWindow() closes offscreen tab and MRP will si
| |
| 264 return; | |
| 265 } | |
| 266 | |
| 267 if (controller_) { | |
| 268 ConnectToPresentationServiceIfNeeded(); | |
| 269 presentation_service_->Terminate(presentationUrl, presentationId.utf8()); | |
| 270 return; | |
| 271 } | |
| 264 } | 272 } |
| 265 | 273 |
| 266 void PresentationDispatcher::getAvailability( | 274 void PresentationDispatcher::getAvailability( |
| 267 const blink::WebURL& availabilityUrl, | 275 const blink::WebURL& availabilityUrl, |
| 268 blink::WebPresentationAvailabilityCallbacks* callbacks) { | 276 blink::WebPresentationAvailabilityCallbacks* callbacks) { |
| 269 AvailabilityStatus* status = nullptr; | 277 AvailabilityStatus* status = nullptr; |
| 270 auto status_it = availability_status_.find(availabilityUrl); | 278 auto status_it = availability_status_.find(availabilityUrl); |
| 271 if (status_it == availability_status_.end()) { | 279 if (status_it == availability_status_.end()) { |
| 272 status = new AvailabilityStatus(availabilityUrl); | 280 status = new AvailabilityStatus(availabilityUrl); |
| 273 availability_status_[availabilityUrl] = base::WrapUnique(status); | 281 availability_status_[availabilityUrl] = base::WrapUnique(status); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 442 receiver_connection_proxy->SetTargetConnection(std::move(controller)); | 450 receiver_connection_proxy->SetTargetConnection(std::move(controller)); |
| 443 // Bind receiver_connection_proxy with PresentationConnection | 451 // Bind receiver_connection_proxy with PresentationConnection |
| 444 // in receiver page. | 452 // in receiver page. |
| 445 receiver_->onReceiverConnectionAvailable(new PresentationConnectionClient( | 453 receiver_->onReceiverConnectionAvailable(new PresentationConnectionClient( |
| 446 std::move(session_info), std::move(receiver_connection_proxy))); | 454 std::move(session_info), std::move(receiver_connection_proxy))); |
| 447 } | 455 } |
| 448 | 456 |
| 449 void PresentationDispatcher::OnConnectionStateChanged( | 457 void PresentationDispatcher::OnConnectionStateChanged( |
| 450 blink::mojom::PresentationSessionInfoPtr connection, | 458 blink::mojom::PresentationSessionInfoPtr connection, |
| 451 blink::mojom::PresentationConnectionState state) { | 459 blink::mojom::PresentationConnectionState state) { |
| 452 if (!controller_) | 460 if (!controller_ && !receiver_) |
| 453 return; | 461 return; |
| 454 | 462 |
| 455 DCHECK(!connection.is_null()); | 463 if (receiver_) { |
| 456 controller_->didChangeSessionState( | 464 receiver_->didChangeSessionState( |
| 457 new PresentationConnectionClient(std::move(connection)), | 465 GetWebPresentationConnectionStateFromMojo(state)); |
| 458 GetWebPresentationConnectionStateFromMojo(state)); | 466 return; |
| 467 } | |
| 468 | |
| 469 if (controller_) { | |
| 470 DCHECK(!connection.is_null()); | |
| 471 controller_->didChangeSessionState( | |
| 472 new PresentationConnectionClient(std::move(connection)), | |
| 473 GetWebPresentationConnectionStateFromMojo(state)); | |
| 474 return; | |
| 475 } | |
| 459 } | 476 } |
| 460 | 477 |
| 461 void PresentationDispatcher::OnConnectionClosed( | 478 void PresentationDispatcher::OnConnectionClosed( |
| 462 blink::mojom::PresentationSessionInfoPtr connection, | 479 blink::mojom::PresentationSessionInfoPtr connection, |
| 463 blink::mojom::PresentationConnectionCloseReason reason, | 480 blink::mojom::PresentationConnectionCloseReason reason, |
| 464 const std::string& message) { | 481 const std::string& message) { |
| 465 if (!controller_) | 482 if (!controller_) |
| 466 return; | 483 return; |
| 467 | 484 |
| 468 DCHECK(!connection.is_null()); | 485 DCHECK(!connection.is_null()); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 591 PresentationDispatcher::AvailabilityStatus::AvailabilityStatus( | 608 PresentationDispatcher::AvailabilityStatus::AvailabilityStatus( |
| 592 const GURL& availability_url) | 609 const GURL& availability_url) |
| 593 : url(availability_url), | 610 : url(availability_url), |
| 594 last_known_availability(false), | 611 last_known_availability(false), |
| 595 listening_state(ListeningState::INACTIVE) {} | 612 listening_state(ListeningState::INACTIVE) {} |
| 596 | 613 |
| 597 PresentationDispatcher::AvailabilityStatus::~AvailabilityStatus() { | 614 PresentationDispatcher::AvailabilityStatus::~AvailabilityStatus() { |
| 598 } | 615 } |
| 599 | 616 |
| 600 } // namespace content | 617 } // namespace content |
| OLD | NEW |