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

Side by Side Diff: chrome/browser/media/router/presentation_service_delegate_impl.cc

Issue 2379703002: [Presentation API] (alternative) 1-UA: send message between controller and receiver page (Closed)
Patch Set: merge with master Created 4 years, 1 month 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 "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>
11 11
12 #include "base/containers/small_map.h" 12 #include "base/containers/small_map.h"
13 #include "base/guid.h" 13 #include "base/guid.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
17 #include "chrome/browser/media/router/create_presentation_connection_request.h" 17 #include "chrome/browser/media/router/create_presentation_connection_request.h"
18 #include "chrome/browser/media/router/media_route.h" 18 #include "chrome/browser/media/router/media_route.h"
19 #include "chrome/browser/media/router/media_router.h" 19 #include "chrome/browser/media/router/media_router.h"
20 #include "chrome/browser/media/router/media_router_dialog_controller.h" 20 #include "chrome/browser/media/router/media_router_dialog_controller.h"
21 #include "chrome/browser/media/router/media_router_factory.h" 21 #include "chrome/browser/media/router/media_router_factory.h"
22 #include "chrome/browser/media/router/media_sink.h" 22 #include "chrome/browser/media/router/media_sink.h"
23 #include "chrome/browser/media/router/media_source_helper.h" 23 #include "chrome/browser/media/router/media_source_helper.h"
24 #include "chrome/browser/media/router/offscreen_presentation_manager.h"
25 #include "chrome/browser/media/router/offscreen_presentation_manager_factory.h"
24 #include "chrome/browser/media/router/presentation_media_sinks_observer.h" 26 #include "chrome/browser/media/router/presentation_media_sinks_observer.h"
25 #include "chrome/browser/media/router/route_message.h" 27 #include "chrome/browser/media/router/route_message.h"
26 #include "chrome/browser/media/router/route_message_observer.h" 28 #include "chrome/browser/media/router/route_message_observer.h"
27 #include "chrome/browser/media/router/route_request_result.h" 29 #include "chrome/browser/media/router/route_request_result.h"
28 #include "chrome/browser/sessions/session_tab_helper.h" 30 #include "chrome/browser/sessions/session_tab_helper.h"
29 #include "content/public/browser/browser_context.h" 31 #include "content/public/browser/browser_context.h"
30 #include "content/public/browser/presentation_screen_availability_listener.h" 32 #include "content/public/browser/presentation_screen_availability_listener.h"
31 #include "content/public/browser/presentation_session.h" 33 #include "content/public/browser/presentation_session.h"
32 #include "content/public/browser/render_frame_host.h" 34 #include "content/public/browser/render_frame_host.h"
33 #include "content/public/browser/render_process_host.h" 35 #include "content/public/browser/render_process_host.h"
36 #include "url/gurl.h"
34 37
35 DEFINE_WEB_CONTENTS_USER_DATA_KEY( 38 DEFINE_WEB_CONTENTS_USER_DATA_KEY(
36 media_router::PresentationServiceDelegateImpl); 39 media_router::PresentationServiceDelegateImpl);
37 40
38 using content::RenderFrameHost; 41 using content::RenderFrameHost;
39 42
40 namespace media_router { 43 namespace media_router {
41 44
42 namespace { 45 namespace {
43 46
44 using DelegateObserver = content::PresentationServiceDelegate::Observer; 47 using DelegateObserver = content::PresentationServiceDelegateBase::Observer;
45 48
46 // Returns the unique identifier for the supplied RenderFrameHost. 49 // Returns the unique identifier for the supplied RenderFrameHost.
47 RenderFrameHostId GetRenderFrameHostId(RenderFrameHost* render_frame_host) { 50 RenderFrameHostId GetRenderFrameHostId(RenderFrameHost* render_frame_host) {
48 int render_process_id = render_frame_host->GetProcess()->GetID(); 51 int render_process_id = render_frame_host->GetProcess()->GetID();
49 int render_frame_id = render_frame_host->GetRoutingID(); 52 int render_frame_id = render_frame_host->GetRoutingID();
50 return RenderFrameHostId(render_process_id, render_frame_id); 53 return RenderFrameHostId(render_process_id, render_frame_id);
51 } 54 }
52 55
53 // Gets the last committed URL for the render frame specified by 56 // Gets the last committed URL for the render frame specified by
54 // |render_frame_host_id|. 57 // |render_frame_host_id|.
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 result.route()->media_route_id()); 752 result.route()->media_route_id());
750 success_cb.Run(session); 753 success_cb.Run(session);
751 } 754 }
752 } 755 }
753 756
754 void PresentationServiceDelegateImpl::OnStartSessionSucceeded( 757 void PresentationServiceDelegateImpl::OnStartSessionSucceeded(
755 int render_process_id, 758 int render_process_id,
756 int render_frame_id, 759 int render_frame_id,
757 const content::PresentationSessionStartedCallback& success_cb, 760 const content::PresentationSessionStartedCallback& success_cb,
758 const content::PresentationSessionInfo& new_session, 761 const content::PresentationSessionInfo& new_session,
759 const MediaRoute::Id& route_id) { 762 const MediaRoute& route) {
763 const MediaRoute::Id& route_id = route.media_route_id();
760 DVLOG(1) << "OnStartSessionSucceeded: " 764 DVLOG(1) << "OnStartSessionSucceeded: "
761 << "route_id: " << route_id 765 << "route_id: " << route_id
762 << ", presentation URL: " << new_session.presentation_url 766 << ", presentation URL: " << new_session.presentation_url
763 << ", presentation ID: " << new_session.presentation_id; 767 << ", presentation ID: " << new_session.presentation_id
768 << ", is_offscreen_presentation: " << new_session.is_offscreen;
764 frame_manager_->OnPresentationSessionStarted( 769 frame_manager_->OnPresentationSessionStarted(
765 RenderFrameHostId(render_process_id, render_frame_id), new_session, 770 RenderFrameHostId(render_process_id, render_frame_id), new_session,
766 route_id); 771 route_id);
767 success_cb.Run(new_session); 772 success_cb.Run(new_session);
768 } 773 }
769 774
770 void PresentationServiceDelegateImpl::StartSession( 775 void PresentationServiceDelegateImpl::StartSession(
771 int render_process_id, 776 int render_process_id,
772 int render_frame_id, 777 int render_frame_id,
773 const std::vector<GURL>& presentation_urls, 778 const std::vector<GURL>& presentation_urls,
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 int render_process_id, 913 int render_process_id,
909 int render_frame_id, 914 int render_frame_id,
910 const content::PresentationSessionInfo& connection, 915 const content::PresentationSessionInfo& connection,
911 const content::PresentationConnectionStateChangedCallback& 916 const content::PresentationConnectionStateChangedCallback&
912 state_changed_cb) { 917 state_changed_cb) {
913 frame_manager_->ListenForConnectionStateChange( 918 frame_manager_->ListenForConnectionStateChange(
914 RenderFrameHostId(render_process_id, render_frame_id), connection, 919 RenderFrameHostId(render_process_id, render_frame_id), connection,
915 state_changed_cb); 920 state_changed_cb);
916 } 921 }
917 922
923 void PresentationServiceDelegateImpl::ConnectToOffscreenPresentation(
924 int render_process_id,
925 int render_frame_id,
926 const content::PresentationSessionInfo& session,
927 content::PresentationConnectionPtr connection) {
928 RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id);
929 auto offscreen_presentation_manager = OffscreenPresentationManagerFactory::
930 GetOrCreateForControllerBrowserContext(web_contents_);
931 offscreen_presentation_manager->RegisterOffscreenPresentationController(
932 session.presentation_id, GURL(session.presentation_url),
933 render_frame_host_id, std::move(connection));
934 }
935
918 void PresentationServiceDelegateImpl::OnRouteResponse( 936 void PresentationServiceDelegateImpl::OnRouteResponse(
919 const PresentationRequest& presentation_request, 937 const PresentationRequest& presentation_request,
920 const RouteRequestResult& result) { 938 const RouteRequestResult& result) {
921 if (!result.route()) 939 if (!result.route())
922 return; 940 return;
923 941
924 content::PresentationSessionInfo session_info( 942 content::PresentationSessionInfo session_info(
925 presentation_request.presentation_url(), result.presentation_id()); 943 presentation_request.presentation_url(), result.presentation_id());
926 frame_manager_->OnDefaultPresentationSessionStarted( 944 frame_manager_->OnDefaultPresentationSessionStarted(
927 presentation_request, session_info, result.route()->media_route_id()); 945 presentation_request, session_info, result.route()->media_route_id());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 bool PresentationServiceDelegateImpl::HasScreenAvailabilityListenerForTest( 979 bool PresentationServiceDelegateImpl::HasScreenAvailabilityListenerForTest(
962 int render_process_id, 980 int render_process_id,
963 int render_frame_id, 981 int render_frame_id,
964 const MediaSource::Id& source_id) const { 982 const MediaSource::Id& source_id) const {
965 RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id); 983 RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id);
966 return frame_manager_->HasScreenAvailabilityListenerForTest( 984 return frame_manager_->HasScreenAvailabilityListenerForTest(
967 render_frame_host_id, source_id); 985 render_frame_host_id, source_id);
968 } 986 }
969 987
970 } // namespace media_router 988 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698