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 91a9badfb4c827e61ad3dbf7a605ea7e11b34af2..f473ca1d887d0cd014c2244644e4f6f417db8e90 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); |
@@ -145,11 +148,6 @@ class PresentationFrame { |
void OnPresentationSessionStarted( |
const content::PresentationSessionInfo& session, |
const MediaRoute::Id& route_id); |
- void OnPresentationServiceDelegateDestroyed() const; |
- |
- void set_delegate_observer(DelegateObserver* observer) { |
- delegate_observer_ = observer; |
- } |
private: |
MediaSource GetMediaSourceFromListener( |
@@ -173,8 +171,6 @@ class PresentationFrame { |
// References to the owning WebContents, and the corresponding MediaRouter. |
const content::WebContents* web_contents_; |
MediaRouter* router_; |
- |
- DelegateObserver* delegate_observer_; |
}; |
PresentationFrame::PresentationFrame( |
@@ -183,8 +179,7 @@ PresentationFrame::PresentationFrame( |
MediaRouter* router) |
: render_frame_host_id_(render_frame_host_id), |
web_contents_(web_contents), |
- router_(router), |
- delegate_observer_(nullptr) { |
+ router_(router) { |
DCHECK(web_contents_); |
DCHECK(router_); |
} |
@@ -192,11 +187,6 @@ PresentationFrame::PresentationFrame( |
PresentationFrame::~PresentationFrame() { |
} |
-void PresentationFrame::OnPresentationServiceDelegateDestroyed() const { |
- if (delegate_observer_) |
- delegate_observer_->OnDelegateDestroyed(); |
-} |
- |
void PresentationFrame::OnPresentationSessionStarted( |
const content::PresentationSessionInfo& session, |
const MediaRoute::Id& route_id) { |
@@ -447,10 +437,7 @@ PresentationFrameManager::PresentationFrameManager( |
DCHECK(router_); |
} |
-PresentationFrameManager::~PresentationFrameManager() { |
- for (auto& frame : presentation_frames_) |
- frame.second->OnPresentationServiceDelegateDestroyed(); |
-} |
+PresentationFrameManager::~PresentationFrameManager() {} |
void PresentationFrameManager::OnPresentationSessionStarted( |
const RenderFrameHostId& render_frame_host_id, |
@@ -558,22 +545,6 @@ void PresentationFrameManager::SetDefaultPresentationUrl( |
} |
} |
-void PresentationFrameManager::AddDelegateObserver( |
- const RenderFrameHostId& render_frame_host_id, |
- DelegateObserver* observer) { |
- auto* presentation_frame = GetOrAddPresentationFrame(render_frame_host_id); |
- presentation_frame->set_delegate_observer(observer); |
-} |
- |
-void PresentationFrameManager::RemoveDelegateObserver( |
- const RenderFrameHostId& render_frame_host_id) { |
- const auto it = presentation_frames_.find(render_frame_host_id); |
- if (it != presentation_frames_.end()) { |
- it->second->set_delegate_observer(nullptr); |
- presentation_frames_.erase(it); |
- } |
-} |
- |
void PresentationFrameManager::AddDefaultPresentationRequestObserver( |
PresentationServiceDelegateImpl::DefaultPresentationRequestObserver* |
observer) { |
@@ -674,20 +645,6 @@ PresentationServiceDelegateImpl::PresentationServiceDelegateImpl( |
PresentationServiceDelegateImpl::~PresentationServiceDelegateImpl() { |
} |
-void PresentationServiceDelegateImpl::AddObserver(int render_process_id, |
- int render_frame_id, |
- DelegateObserver* observer) { |
- DCHECK(observer); |
- frame_manager_->AddDelegateObserver( |
- RenderFrameHostId(render_process_id, render_frame_id), observer); |
-} |
- |
-void PresentationServiceDelegateImpl::RemoveObserver(int render_process_id, |
- int render_frame_id) { |
- frame_manager_->RemoveDelegateObserver( |
- RenderFrameHostId(render_process_id, render_frame_id)); |
-} |
- |
bool PresentationServiceDelegateImpl::AddScreenAvailabilityListener( |
int render_process_id, |
int render_frame_id, |
@@ -918,6 +875,20 @@ 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); |
+ auto* const offscreen_presentation_manager = |
+ OffscreenPresentationManagerFactory:: |
+ GetOrCreateForControllerBrowserContext(web_contents_); |
+ offscreen_presentation_manager->RegisterOffscreenPresentationController( |
+ session.presentation_id, session.presentation_url, render_frame_host_id, |
+ std::move(connection)); |
+} |
+ |
void PresentationServiceDelegateImpl::OnRouteResponse( |
const PresentationRequest& presentation_request, |
const RouteRequestResult& result) { |