| 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 <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 } | 260 } |
| 261 | 261 |
| 262 void PresentationDispatcher::closeSession( | 262 void PresentationDispatcher::closeSession( |
| 263 const blink::WebURL& presentationUrl, | 263 const blink::WebURL& presentationUrl, |
| 264 const blink::WebString& presentationId) { | 264 const blink::WebString& presentationId) { |
| 265 ConnectToPresentationServiceIfNeeded(); | 265 ConnectToPresentationServiceIfNeeded(); |
| 266 presentation_service_->CloseConnection(presentationUrl, | 266 presentation_service_->CloseConnection(presentationUrl, |
| 267 presentationId.utf8()); | 267 presentationId.utf8()); |
| 268 } | 268 } |
| 269 | 269 |
| 270 void PresentationDispatcher::terminateSession( | 270 void PresentationDispatcher::terminateConnection( |
| 271 const blink::WebURL& presentationUrl, | 271 const blink::WebURL& presentationUrl, |
| 272 const blink::WebString& presentationId) { | 272 const blink::WebString& presentationId) { |
| 273 ConnectToPresentationServiceIfNeeded(); | 273 if (receiver_) { |
| 274 presentation_service_->Terminate(presentationUrl, presentationId.utf8()); | 274 receiver_->terminateConnection(); |
| 275 return; |
| 276 } |
| 277 |
| 278 if (controller_) { |
| 279 ConnectToPresentationServiceIfNeeded(); |
| 280 presentation_service_->Terminate(presentationUrl, presentationId.utf8()); |
| 281 return; |
| 282 } |
| 275 } | 283 } |
| 276 | 284 |
| 277 void PresentationDispatcher::getAvailability( | 285 void PresentationDispatcher::getAvailability( |
| 278 const blink::WebVector<blink::WebURL>& availabilityUrls, | 286 const blink::WebVector<blink::WebURL>& availabilityUrls, |
| 279 std::unique_ptr<blink::WebPresentationAvailabilityCallbacks> callback) { | 287 std::unique_ptr<blink::WebPresentationAvailabilityCallbacks> callback) { |
| 280 DCHECK(!availabilityUrls.isEmpty()); | 288 DCHECK(!availabilityUrls.isEmpty()); |
| 281 | 289 |
| 282 std::vector<GURL> urls; | 290 std::vector<GURL> urls; |
| 283 for (const auto& availability_url : availabilityUrls) | 291 for (const auto& availability_url : availabilityUrls) |
| 284 urls.push_back(availability_url); | 292 urls.push_back(availability_url); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 | 389 |
| 382 // Remove all pending send message requests. | 390 // Remove all pending send message requests. |
| 383 MessageRequestQueue empty; | 391 MessageRequestQueue empty; |
| 384 std::swap(message_request_queue_, empty); | 392 std::swap(message_request_queue_, empty); |
| 385 } | 393 } |
| 386 | 394 |
| 387 void PresentationDispatcher::OnDestruct() { | 395 void PresentationDispatcher::OnDestruct() { |
| 388 delete this; | 396 delete this; |
| 389 } | 397 } |
| 390 | 398 |
| 399 void PresentationDispatcher::WidgetWillClose() { |
| 400 if (!receiver_) |
| 401 return; |
| 402 |
| 403 receiver_->didChangeSessionState( |
| 404 blink::WebPresentationConnectionState::Terminated); |
| 405 } |
| 406 |
| 391 void PresentationDispatcher::OnScreenAvailabilityUpdated(const GURL& url, | 407 void PresentationDispatcher::OnScreenAvailabilityUpdated(const GURL& url, |
| 392 bool available) { | 408 bool available) { |
| 393 auto* listening_status = GetListeningStatus(url); | 409 auto* listening_status = GetListeningStatus(url); |
| 394 if (!listening_status) | 410 if (!listening_status) |
| 395 return; | 411 return; |
| 396 | 412 |
| 397 if (listening_status->listening_state == ListeningState::WAITING) | 413 if (listening_status->listening_state == ListeningState::WAITING) |
| 398 listening_status->listening_state = ListeningState::ACTIVE; | 414 listening_status->listening_state = ListeningState::ACTIVE; |
| 399 | 415 |
| 400 auto new_screen_availability = available ? ScreenAvailability::AVAILABLE | 416 auto new_screen_availability = available ? ScreenAvailability::AVAILABLE |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 | 793 |
| 778 PresentationDispatcher::ListeningStatus::ListeningStatus( | 794 PresentationDispatcher::ListeningStatus::ListeningStatus( |
| 779 const GURL& availability_url) | 795 const GURL& availability_url) |
| 780 : url(availability_url), | 796 : url(availability_url), |
| 781 last_known_availability(ScreenAvailability::UNKNOWN), | 797 last_known_availability(ScreenAvailability::UNKNOWN), |
| 782 listening_state(ListeningState::INACTIVE) {} | 798 listening_state(ListeningState::INACTIVE) {} |
| 783 | 799 |
| 784 PresentationDispatcher::ListeningStatus::~ListeningStatus() {} | 800 PresentationDispatcher::ListeningStatus::~ListeningStatus() {} |
| 785 | 801 |
| 786 } // namespace content | 802 } // namespace content |
| OLD | NEW |