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 "chrome/browser/media/router/presentation_service_delegate_impl.h" | 5 #include "chrome/browser/media/router/presentation_service_delegate_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <unordered_map> | 8 #include <unordered_map> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 724 } else { | 724 } else { |
| 725 // TODO(crbug.com/627655): Handle multiple URLs. | 725 // TODO(crbug.com/627655): Handle multiple URLs. |
| 726 frame_manager_->SetDefaultPresentationUrl( | 726 frame_manager_->SetDefaultPresentationUrl( |
| 727 render_frame_host_id, default_presentation_urls[0], callback); | 727 render_frame_host_id, default_presentation_urls[0], callback); |
| 728 } | 728 } |
| 729 } | 729 } |
| 730 | 730 |
| 731 void PresentationServiceDelegateImpl::OnJoinRouteResponse( | 731 void PresentationServiceDelegateImpl::OnJoinRouteResponse( |
| 732 int render_process_id, | 732 int render_process_id, |
| 733 int render_frame_id, | 733 int render_frame_id, |
| 734 const content::PresentationSessionInfo& session, | 734 const GURL& presentation_url, |
|
mark a. foltz
2016/11/09 19:28:23
Thanks for doing this; it is necessary for support
zhaobin
2016/11/11 18:41:51
Done.
| |
| 735 const content::PresentationSessionStartedCallback& success_cb, | 735 const content::PresentationSessionStartedCallback& success_cb, |
| 736 const content::PresentationSessionErrorCallback& error_cb, | 736 const content::PresentationSessionErrorCallback& error_cb, |
| 737 const RouteRequestResult& result) { | 737 const RouteRequestResult& result) { |
| 738 if (!result.route()) { | 738 if (!result.route()) { |
| 739 error_cb.Run(content::PresentationError( | 739 error_cb.Run(content::PresentationError( |
| 740 content::PRESENTATION_ERROR_NO_PRESENTATION_FOUND, result.error())); | 740 content::PRESENTATION_ERROR_NO_PRESENTATION_FOUND, result.error())); |
| 741 } else { | 741 } else { |
| 742 DVLOG(1) << "OnJoinRouteResponse: " | 742 DVLOG(1) << "OnJoinRouteResponse: " |
| 743 << "route_id: " << result.route()->media_route_id() | 743 << "route_id: " << result.route()->media_route_id() |
| 744 << ", presentation URL: " << session.presentation_url | 744 << ", presentation URL: " << presentation_url |
| 745 << ", presentation ID: " << session.presentation_id; | 745 << ", presentation ID: " << result.presentation_id(); |
| 746 DCHECK_EQ(session.presentation_id, result.presentation_id()); | 746 content::PresentationSessionInfo session( |
| 747 presentation_url, result.presentation_id(), | |
| 748 result.route()->is_offscreen_presentation()); | |
| 747 frame_manager_->OnPresentationSessionStarted( | 749 frame_manager_->OnPresentationSessionStarted( |
| 748 RenderFrameHostId(render_process_id, render_frame_id), session, | 750 RenderFrameHostId(render_process_id, render_frame_id), session, |
| 749 result.route()->media_route_id()); | 751 result.route()->media_route_id()); |
| 750 success_cb.Run(session); | 752 success_cb.Run(session); |
| 751 } | 753 } |
| 752 } | 754 } |
| 753 | 755 |
| 754 void PresentationServiceDelegateImpl::OnStartSessionSucceeded( | 756 void PresentationServiceDelegateImpl::OnStartSessionSucceeded( |
| 755 int render_process_id, | 757 int render_process_id, |
| 756 int render_frame_id, | 758 int render_frame_id, |
| 757 const content::PresentationSessionStartedCallback& success_cb, | 759 const content::PresentationSessionStartedCallback& success_cb, |
| 758 const content::PresentationSessionInfo& new_session, | 760 const content::PresentationSessionInfo& new_session, |
| 759 const MediaRoute::Id& route_id) { | 761 const MediaRoute& route) { |
| 762 const MediaRoute::Id& route_id = route.media_route_id(); | |
| 760 DVLOG(1) << "OnStartSessionSucceeded: " | 763 DVLOG(1) << "OnStartSessionSucceeded: " |
| 761 << "route_id: " << route_id | 764 << "route_id: " << route_id |
| 762 << ", presentation URL: " << new_session.presentation_url | 765 << ", presentation URL: " << new_session.presentation_url |
| 763 << ", presentation ID: " << new_session.presentation_id; | 766 << ", presentation ID: " << new_session.presentation_id |
| 767 << ", is_offscreen_presentation: " << new_session.is_offscreen; | |
| 764 frame_manager_->OnPresentationSessionStarted( | 768 frame_manager_->OnPresentationSessionStarted( |
| 765 RenderFrameHostId(render_process_id, render_frame_id), new_session, | 769 RenderFrameHostId(render_process_id, render_frame_id), new_session, |
| 766 route_id); | 770 route_id); |
| 767 success_cb.Run(new_session); | 771 success_cb.Run(new_session); |
| 768 } | 772 } |
| 769 | 773 |
| 770 void PresentationServiceDelegateImpl::StartSession( | 774 void PresentationServiceDelegateImpl::StartSession( |
| 771 int render_process_id, | 775 int render_process_id, |
| 772 int render_frame_id, | 776 int render_frame_id, |
| 773 const std::vector<GURL>& presentation_urls, | 777 const std::vector<GURL>& presentation_urls, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 817 if (presentation_urls.empty()) { | 821 if (presentation_urls.empty()) { |
| 818 error_cb.Run(content::PresentationError( | 822 error_cb.Run(content::PresentationError( |
| 819 content::PRESENTATION_ERROR_NO_PRESENTATION_FOUND, | 823 content::PRESENTATION_ERROR_NO_PRESENTATION_FOUND, |
| 820 "Invalid presentation arguments.")); | 824 "Invalid presentation arguments.")); |
| 821 } | 825 } |
| 822 | 826 |
| 823 // TODO(crbug.com/627655): Handle multiple URLs. | 827 // TODO(crbug.com/627655): Handle multiple URLs. |
| 824 const GURL& presentation_url = presentation_urls[0]; | 828 const GURL& presentation_url = presentation_urls[0]; |
| 825 bool incognito = web_contents_->GetBrowserContext()->IsOffTheRecord(); | 829 bool incognito = web_contents_->GetBrowserContext()->IsOffTheRecord(); |
| 826 std::vector<MediaRouteResponseCallback> route_response_callbacks; | 830 std::vector<MediaRouteResponseCallback> route_response_callbacks; |
| 827 route_response_callbacks.push_back(base::Bind( | 831 route_response_callbacks.push_back( |
| 828 &PresentationServiceDelegateImpl::OnJoinRouteResponse, | 832 base::Bind(&PresentationServiceDelegateImpl::OnJoinRouteResponse, |
|
mark a. foltz
2016/11/09 19:28:23
It would be ideal to also include the presentation
zhaobin
2016/11/11 18:41:51
Done.
| |
| 829 weak_factory_.GetWeakPtr(), render_process_id, render_frame_id, | 833 weak_factory_.GetWeakPtr(), render_process_id, render_frame_id, |
| 830 content::PresentationSessionInfo(presentation_url, presentation_id), | 834 presentation_url, success_cb, error_cb)); |
| 831 success_cb, error_cb)); | |
| 832 router_->JoinRoute( | 835 router_->JoinRoute( |
| 833 MediaSourceForPresentationUrl(presentation_url).id(), presentation_id, | 836 MediaSourceForPresentationUrl(presentation_url).id(), presentation_id, |
| 834 GetLastCommittedURLForFrame( | 837 GetLastCommittedURLForFrame( |
| 835 RenderFrameHostId(render_process_id, render_frame_id)) | 838 RenderFrameHostId(render_process_id, render_frame_id)) |
| 836 .GetOrigin(), | 839 .GetOrigin(), |
| 837 web_contents_, route_response_callbacks, base::TimeDelta(), incognito); | 840 web_contents_, route_response_callbacks, base::TimeDelta(), incognito); |
| 838 } | 841 } |
| 839 | 842 |
| 840 void PresentationServiceDelegateImpl::CloseConnection( | 843 void PresentationServiceDelegateImpl::CloseConnection( |
| 841 int render_process_id, | 844 int render_process_id, |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 915 state_changed_cb); | 918 state_changed_cb); |
| 916 } | 919 } |
| 917 | 920 |
| 918 void PresentationServiceDelegateImpl::OnRouteResponse( | 921 void PresentationServiceDelegateImpl::OnRouteResponse( |
| 919 const PresentationRequest& presentation_request, | 922 const PresentationRequest& presentation_request, |
| 920 const RouteRequestResult& result) { | 923 const RouteRequestResult& result) { |
| 921 if (!result.route()) | 924 if (!result.route()) |
| 922 return; | 925 return; |
| 923 | 926 |
| 924 content::PresentationSessionInfo session_info( | 927 content::PresentationSessionInfo session_info( |
| 925 presentation_request.presentation_url(), result.presentation_id()); | 928 presentation_request.presentation_url(), result.presentation_id(), |
| 929 result.route()->is_offscreen_presentation()); | |
| 926 frame_manager_->OnDefaultPresentationSessionStarted( | 930 frame_manager_->OnDefaultPresentationSessionStarted( |
| 927 presentation_request, session_info, result.route()->media_route_id()); | 931 presentation_request, session_info, result.route()->media_route_id()); |
| 928 } | 932 } |
| 929 | 933 |
| 930 void PresentationServiceDelegateImpl::AddDefaultPresentationRequestObserver( | 934 void PresentationServiceDelegateImpl::AddDefaultPresentationRequestObserver( |
| 931 DefaultPresentationRequestObserver* observer) { | 935 DefaultPresentationRequestObserver* observer) { |
| 932 frame_manager_->AddDefaultPresentationRequestObserver(observer); | 936 frame_manager_->AddDefaultPresentationRequestObserver(observer); |
| 933 } | 937 } |
| 934 | 938 |
| 935 void PresentationServiceDelegateImpl::RemoveDefaultPresentationRequestObserver( | 939 void PresentationServiceDelegateImpl::RemoveDefaultPresentationRequestObserver( |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 961 bool PresentationServiceDelegateImpl::HasScreenAvailabilityListenerForTest( | 965 bool PresentationServiceDelegateImpl::HasScreenAvailabilityListenerForTest( |
| 962 int render_process_id, | 966 int render_process_id, |
| 963 int render_frame_id, | 967 int render_frame_id, |
| 964 const MediaSource::Id& source_id) const { | 968 const MediaSource::Id& source_id) const { |
| 965 RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id); | 969 RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id); |
| 966 return frame_manager_->HasScreenAvailabilityListenerForTest( | 970 return frame_manager_->HasScreenAvailabilityListenerForTest( |
| 967 render_frame_host_id, source_id); | 971 render_frame_host_id, source_id); |
| 968 } | 972 } |
| 969 | 973 |
| 970 } // namespace media_router | 974 } // namespace media_router |
| OLD | NEW |