| 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 "content/renderer/presentation/presentation_dispatcher.h" | 5 #include "content/renderer/presentation/presentation_dispatcher.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "content/common/presentation/presentation_service.mojom.h" | 8 #include "content/common/presentation/presentation_service.mojom.h" |
| 9 #include "content/public/common/service_registry.h" | 9 #include "content/public/common/service_registry.h" |
| 10 #include "content/public/renderer/render_frame.h" | 10 #include "content/public/renderer/render_frame.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 // OnSessionCreated() is called. |callback| needs to be alive and also needs | 109 // OnSessionCreated() is called. |callback| needs to be alive and also needs |
| 110 // to be destroyed so we transfer its ownership to the mojo callback. | 110 // to be destroyed so we transfer its ownership to the mojo callback. |
| 111 presentation_service_->JoinSession( | 111 presentation_service_->JoinSession( |
| 112 presentationUrl.utf8(), | 112 presentationUrl.utf8(), |
| 113 presentationId.utf8(), | 113 presentationId.utf8(), |
| 114 base::Bind(&PresentationDispatcher::OnSessionCreated, | 114 base::Bind(&PresentationDispatcher::OnSessionCreated, |
| 115 base::Unretained(this), | 115 base::Unretained(this), |
| 116 base::Owned(callback))); | 116 base::Owned(callback))); |
| 117 } | 117 } |
| 118 | 118 |
| 119 void PresentationDispatcher::closeSession( |
| 120 const blink::WebString& presentationUrl, |
| 121 const blink::WebString& presentationId) { |
| 122 ConnectToPresentationServiceIfNeeded(); |
| 123 |
| 124 presentation_service_->CloseSession( |
| 125 presentationUrl.utf8(), |
| 126 presentationId.utf8()); |
| 127 } |
| 128 |
| 119 void PresentationDispatcher::DidChangeDefaultPresentation() { | 129 void PresentationDispatcher::DidChangeDefaultPresentation() { |
| 120 GURL presentation_url(GetPresentationURLFromFrame(render_frame())); | 130 GURL presentation_url(GetPresentationURLFromFrame(render_frame())); |
| 121 | 131 |
| 122 ConnectToPresentationServiceIfNeeded(); | 132 ConnectToPresentationServiceIfNeeded(); |
| 123 presentation_service_->SetDefaultPresentationURL( | 133 presentation_service_->SetDefaultPresentationURL( |
| 124 presentation_url.spec(), mojo::String()); | 134 presentation_url.spec(), mojo::String()); |
| 125 } | 135 } |
| 126 | 136 |
| 127 void PresentationDispatcher::OnScreenAvailabilityChanged(bool available) { | 137 void PresentationDispatcher::OnScreenAvailabilityChanged(bool available) { |
| 128 if (!controller_) | 138 if (!controller_) |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 return; | 187 return; |
| 178 | 188 |
| 179 render_frame()->GetServiceRegistry()->ConnectToRemoteService( | 189 render_frame()->GetServiceRegistry()->ConnectToRemoteService( |
| 180 &presentation_service_); | 190 &presentation_service_); |
| 181 presentation_service_->ListenForDefaultSessionStart(base::Bind( | 191 presentation_service_->ListenForDefaultSessionStart(base::Bind( |
| 182 &PresentationDispatcher::OnDefaultSessionStarted, | 192 &PresentationDispatcher::OnDefaultSessionStarted, |
| 183 base::Unretained(this))); | 193 base::Unretained(this))); |
| 184 } | 194 } |
| 185 | 195 |
| 186 } // namespace content | 196 } // namespace content |
| OLD | NEW |