Chromium Code Reviews| Index: chrome/browser/media/router/presentation_service_delegate_impl.cc |
| diff --git a/chrome/browser/media/router/presentation_service_delegate_impl.cc b/chrome/browser/media/router/presentation_service_delegate_impl.cc |
| index 0a40a5b3346a2fcb5d13b3d9513211d0e0366b9e..c5b54c0be1d11a4aab4bb249fde2734b8dfa38ba 100644 |
| --- a/chrome/browser/media/router/presentation_service_delegate_impl.cc |
| +++ b/chrome/browser/media/router/presentation_service_delegate_impl.cc |
| @@ -21,6 +21,8 @@ |
| #include "chrome/browser/media/router/media_router_factory.h" |
| #include "chrome/browser/media/router/media_sink.h" |
| #include "chrome/browser/media/router/media_source_helper.h" |
| +#include "chrome/browser/media/router/offscreen_presentation_manager.h" |
| +#include "chrome/browser/media/router/offscreen_presentation_manager_factory.h" |
| #include "chrome/browser/media/router/presentation_media_sinks_observer.h" |
| #include "chrome/browser/media/router/route_message.h" |
| #include "chrome/browser/media/router/route_message_observer.h" |
| @@ -31,6 +33,7 @@ |
| #include "content/public/browser/presentation_session.h" |
| #include "content/public/browser/render_frame_host.h" |
| #include "content/public/browser/render_process_host.h" |
| +#include "url/gurl.h" |
| DEFINE_WEB_CONTENTS_USER_DATA_KEY( |
| media_router::PresentationServiceDelegateImpl); |
| @@ -41,7 +44,7 @@ namespace media_router { |
| namespace { |
| -using DelegateObserver = content::PresentationServiceDelegate::Observer; |
| +using DelegateObserver = content::PresentationServiceDelegateBase::Observer; |
| // Returns the unique identifier for the supplied RenderFrameHost. |
| RenderFrameHostId GetRenderFrameHostId(RenderFrameHost* render_frame_host) { |
| @@ -663,6 +666,9 @@ PresentationServiceDelegateImpl::PresentationServiceDelegateImpl( |
| router_(MediaRouterFactory::GetApiForBrowserContext( |
| web_contents_->GetBrowserContext())), |
| frame_manager_(new PresentationFrameManager(web_contents, router_)), |
| + offscreen_presentation_manager_( |
| + OffscreenPresentationManagerFactory:: |
| + GetOrCreateForControllerBrowserContext(web_contents_)), |
|
imcheng
2016/11/01 17:20:29
that means we are creating an OffscreenPresentatio
zhaobin
2016/11/02 03:55:47
Done.
|
| weak_factory_(this) { |
| DCHECK(web_contents_); |
| DCHECK(router_); |
| @@ -753,11 +759,13 @@ void PresentationServiceDelegateImpl::OnStartSessionSucceeded( |
| int render_frame_id, |
| const content::PresentationSessionStartedCallback& success_cb, |
| const content::PresentationSessionInfo& new_session, |
| - const MediaRoute::Id& route_id) { |
| + const MediaRoute& route) { |
| + const MediaRoute::Id& route_id = route.media_route_id(); |
| DVLOG(1) << "OnStartSessionSucceeded: " |
| << "route_id: " << route_id |
| << ", presentation URL: " << new_session.presentation_url |
| - << ", presentation ID: " << new_session.presentation_id; |
| + << ", presentation ID: " << new_session.presentation_id |
| + << ", is_offscreen_presentation: " << new_session.is_offscreen; |
| frame_manager_->OnPresentationSessionStarted( |
| RenderFrameHostId(render_process_id, render_frame_id), new_session, |
| route_id); |
| @@ -912,6 +920,17 @@ void PresentationServiceDelegateImpl::ListenForConnectionStateChange( |
| state_changed_cb); |
| } |
| +void PresentationServiceDelegateImpl::ConnectToOffscreenPresentation( |
| + int render_process_id, |
| + int render_frame_id, |
| + const content::PresentationSessionInfo& session, |
| + content::PresentationConnectionPtr connection) { |
| + RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id); |
| + offscreen_presentation_manager_->RegisterOffscreenPresentationController( |
| + session.presentation_id, GURL(session.presentation_url), |
| + render_frame_host_id, std::move(connection)); |
| +} |
| + |
| void PresentationServiceDelegateImpl::OnRouteResponse( |
| const PresentationRequest& presentation_request, |
| const RouteRequestResult& result) { |