Index: content/renderer/presentation/presentation_dispatcher.cc |
diff --git a/content/renderer/presentation/presentation_dispatcher.cc b/content/renderer/presentation/presentation_dispatcher.cc |
index a0b3125568cfa47217c6424ab470549d34f99c92..321acb43d4a72a53fa5c6fcb65d4b1d3a45260ba 100644 |
--- a/content/renderer/presentation/presentation_dispatcher.cc |
+++ b/content/renderer/presentation/presentation_dispatcher.cc |
@@ -81,8 +81,8 @@ namespace content { |
PresentationDispatcher::PresentationDispatcher(RenderFrame* render_frame) |
: RenderFrameObserver(render_frame), |
controller_(nullptr), |
- binding_(this) { |
-} |
+ receiver_(nullptr), |
+ binding_(this) {} |
PresentationDispatcher::~PresentationDispatcher() { |
// Controller should be destroyed before the dispatcher when frame is |
@@ -394,16 +394,35 @@ void PresentationDispatcher::OnSessionCreated( |
DCHECK(!session_info.is_null()); |
presentation_service_->ListenForSessionMessages(session_info.Clone()); |
- callback->onSuccess( |
- base::MakeUnique<PresentationConnectionClient>(std::move(session_info))); |
+ |
+ RendererPresentationConnection* controller_connection_proxy = |
+ new RendererPresentationConnection(); |
+ // Bind controller_connection_proxy with PresentationConnection |
+ // in controller page. |
+ callback->onSuccess(base::MakeUnique<PresentationConnectionClient>( |
+ session_info.Clone(), controller_connection_proxy)); |
+ |
+ // Pass controller_connection_proxy to PSImpl and register |
+ // it with OffscreenPresentationManager. |
+ presentation_service_->SetPresentationConnection( |
+ session_info.Clone(), controller_connection_proxy->Bind()); |
} |
void PresentationDispatcher::OnReceiverConnectionAvailable( |
- blink::mojom::PresentationSessionInfoPtr session_info) { |
- if (receiver_) { |
- receiver_->onReceiverConnectionAvailable( |
- new PresentationConnectionClient(std::move(session_info))); |
- } |
+ blink::mojom::PresentationSessionInfoPtr session_info, |
+ blink::mojom::PresentationConnectionPtr controller) { |
+ if (!receiver_) |
+ return; |
+ |
+ RendererPresentationConnection* receiver_connection_proxy = |
+ new RendererPresentationConnection(); |
+ // Bind receiver_connection_proxy with PresentationConnection |
+ // in receiver page. |
+ receiver_->onReceiverConnectionAvailable(new PresentationConnectionClient( |
+ std::move(session_info), receiver_connection_proxy)); |
+ |
+ controller->SetTargetConnection(receiver_connection_proxy->Bind()); |
+ receiver_connection_proxy->SetTargetConnection(std::move(controller)); |
} |
void PresentationDispatcher::OnConnectionStateChanged( |