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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 presentation_service_->ListenForSessionStateChange(base::Bind( | 203 presentation_service_->ListenForSessionStateChange(base::Bind( |
204 &PresentationDispatcher::OnSessionStateChange, | 204 &PresentationDispatcher::OnSessionStateChange, |
205 base::Unretained(this))); | 205 base::Unretained(this))); |
206 | 206 |
207 DCHECK(!session_info.is_null()); | 207 DCHECK(!session_info.is_null()); |
208 controller_->didChangeSessionState( | 208 controller_->didChangeSessionState( |
209 new PresentationSessionClient(session_info.Pass()), | 209 new PresentationSessionClient(session_info.Pass()), |
210 GetWebPresentationSessionStateFromMojo(session_state)); | 210 GetWebPresentationSessionStateFromMojo(session_state)); |
211 } | 211 } |
212 | 212 |
| 213 void PresentationDispatcher::OnSessionTextMessageReceived( |
| 214 presentation::PresentationSessionInfoPtr session_info, |
| 215 const std::string& message) { |
| 216 if (!controller_) |
| 217 return; |
| 218 |
| 219 presentation_service_->ListenForSessionTextMessage(base::Bind( |
| 220 &PresentationDispatcher::OnSessionTextMessageReceived, |
| 221 base::Unretained(this))); |
| 222 |
| 223 DCHECK(!session_info.is_null()); |
| 224 controller_->didReceiveSessionTextMessage( |
| 225 new PresentationSessionClient(session_info.Pass()), |
| 226 blink::WebString::fromUTF8(message)); |
| 227 } |
| 228 |
213 void PresentationDispatcher::ConnectToPresentationServiceIfNeeded() { | 229 void PresentationDispatcher::ConnectToPresentationServiceIfNeeded() { |
214 if (presentation_service_.get()) | 230 if (presentation_service_.get()) |
215 return; | 231 return; |
216 | 232 |
217 render_frame()->GetServiceRegistry()->ConnectToRemoteService( | 233 render_frame()->GetServiceRegistry()->ConnectToRemoteService( |
218 &presentation_service_); | 234 &presentation_service_); |
219 // TODO(imcheng): Uncomment these once they are implemented on the browser | 235 // TODO(imcheng): Uncomment these once they are implemented on the browser |
220 // side. (crbug.com/459006) | 236 // side. (crbug.com/459006) |
221 /* | 237 /* |
222 presentation_service_->ListenForDefaultSessionStart(base::Bind( | 238 presentation_service_->ListenForDefaultSessionStart(base::Bind( |
223 &PresentationDispatcher::OnDefaultSessionStarted, | 239 &PresentationDispatcher::OnDefaultSessionStarted, |
224 base::Unretained(this))); | 240 base::Unretained(this))); |
225 presentation_service_->ListenForSessionStateChange(base::Bind( | 241 presentation_service_->ListenForSessionStateChange(base::Bind( |
226 &PresentationDispatcher::OnSessionStateChange, | 242 &PresentationDispatcher::OnSessionStateChange, |
227 base::Unretained(this))); | 243 base::Unretained(this))); |
| 244 presentation_service_->ListenForSessionTextMessage(base::Bind( |
| 245 &PresentationDispatcher::OnSessionTextMessageReceived, |
| 246 base::Unretained(this))); |
228 */ | 247 */ |
229 } | 248 } |
230 | 249 |
231 } // namespace content | 250 } // namespace content |
OLD | NEW |