Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: content/renderer/presentation/presentation_dispatcher.cc

Issue 2484273003: [Presentation API] (1-UA) fire PresentationConnection onterminate event if receiver page gets destr… (Closed)
Patch Set: merge with master Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::terminateSession(
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_->closeWindow();
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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 connection->bindProxy(base::WrapUnique(receiver_connection_proxy)); 554 connection->bindProxy(base::WrapUnique(receiver_connection_proxy));
547 555
548 receiver_connection_proxy->Bind(std::move(receiver_connection_request)); 556 receiver_connection_proxy->Bind(std::move(receiver_connection_request));
549 receiver_connection_proxy->BindControllerConnection( 557 receiver_connection_proxy->BindControllerConnection(
550 std::move(controller_connection_ptr)); 558 std::move(controller_connection_ptr));
551 } 559 }
552 560
553 void PresentationDispatcher::OnConnectionStateChanged( 561 void PresentationDispatcher::OnConnectionStateChanged(
554 const PresentationSessionInfo& session_info, 562 const PresentationSessionInfo& session_info,
555 PresentationConnectionState state) { 563 PresentationConnectionState state) {
556 if (!controller_) 564 if (!controller_)
imcheng 2017/02/24 19:20:33 this check no longer needed?
zhaobin 2017/02/25 01:31:03 Done.
557 return; 565 return;
558 566
559 controller_->didChangeSessionState( 567 if (receiver_) {
560 blink::WebPresentationSessionInfo( 568 receiver_->didChangeSessionState(GetWebPresentationConnectionState(state));
561 session_info.presentation_url, 569 return;
562 blink::WebString::fromUTF8(session_info.presentation_id)), 570 }
563 GetWebPresentationConnectionState(state)); 571
572 if (controller_) {
573 controller_->didChangeSessionState(
574 blink::WebPresentationSessionInfo(
575 session_info.presentation_url,
576 blink::WebString::fromUTF8(session_info.presentation_id)),
577 GetWebPresentationConnectionState(state));
578 }
564 } 579 }
565 580
566 void PresentationDispatcher::OnConnectionClosed( 581 void PresentationDispatcher::OnConnectionClosed(
567 const PresentationSessionInfo& session_info, 582 const PresentationSessionInfo& session_info,
568 PresentationConnectionCloseReason reason, 583 PresentationConnectionCloseReason reason,
569 const std::string& message) { 584 const std::string& message) {
570 if (!controller_) 585 if (!controller_)
571 return; 586 return;
572 587
573 controller_->didCloseConnection( 588 controller_->didCloseConnection(
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 792
778 PresentationDispatcher::ListeningStatus::ListeningStatus( 793 PresentationDispatcher::ListeningStatus::ListeningStatus(
779 const GURL& availability_url) 794 const GURL& availability_url)
780 : url(availability_url), 795 : url(availability_url),
781 last_known_availability(ScreenAvailability::UNKNOWN), 796 last_known_availability(ScreenAvailability::UNKNOWN),
782 listening_state(ListeningState::INACTIVE) {} 797 listening_state(ListeningState::INACTIVE) {}
783 798
784 PresentationDispatcher::ListeningStatus::~ListeningStatus() {} 799 PresentationDispatcher::ListeningStatus::~ListeningStatus() {}
785 800
786 } // namespace content 801 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698