| 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 // OnSessionCreated() is called. |callback| needs to be alive and also needs | 113 // OnSessionCreated() is called. |callback| needs to be alive and also needs |
| 114 // to be destroyed so we transfer its ownership to the mojo callback. | 114 // to be destroyed so we transfer its ownership to the mojo callback. |
| 115 presentation_service_->JoinSession( | 115 presentation_service_->JoinSession( |
| 116 presentationUrl.utf8(), | 116 presentationUrl.utf8(), |
| 117 presentationId.utf8(), | 117 presentationId.utf8(), |
| 118 base::Bind(&PresentationDispatcher::OnSessionCreated, | 118 base::Bind(&PresentationDispatcher::OnSessionCreated, |
| 119 base::Unretained(this), | 119 base::Unretained(this), |
| 120 base::Owned(callback))); | 120 base::Owned(callback))); |
| 121 } | 121 } |
| 122 | 122 |
| 123 void PresentationDispatcher::postMessage( |
| 124 const blink::WebString& presentationUrl, |
| 125 const blink::WebString& presentationId, |
| 126 const blink::WebString& message) { |
| 127 ConnectToPresentationServiceIfNeeded(); |
| 128 presentation_service_->PostMessage( |
| 129 presentationUrl.utf8(), |
| 130 presentationId.utf8(), |
| 131 message.utf8()); |
| 132 } |
| 133 |
| 123 void PresentationDispatcher::closeSession( | 134 void PresentationDispatcher::closeSession( |
| 124 const blink::WebString& presentationUrl, | 135 const blink::WebString& presentationUrl, |
| 125 const blink::WebString& presentationId) { | 136 const blink::WebString& presentationId) { |
| 126 ConnectToPresentationServiceIfNeeded(); | 137 ConnectToPresentationServiceIfNeeded(); |
| 127 | 138 |
| 128 presentation_service_->CloseSession( | 139 presentation_service_->CloseSession( |
| 129 presentationUrl.utf8(), | 140 presentationUrl.utf8(), |
| 130 presentationId.utf8()); | 141 presentationId.utf8()); |
| 131 } | 142 } |
| 132 | 143 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 return; | 204 return; |
| 194 | 205 |
| 195 render_frame()->GetServiceRegistry()->ConnectToRemoteService( | 206 render_frame()->GetServiceRegistry()->ConnectToRemoteService( |
| 196 &presentation_service_); | 207 &presentation_service_); |
| 197 presentation_service_->ListenForDefaultSessionStart(base::Bind( | 208 presentation_service_->ListenForDefaultSessionStart(base::Bind( |
| 198 &PresentationDispatcher::OnDefaultSessionStarted, | 209 &PresentationDispatcher::OnDefaultSessionStarted, |
| 199 base::Unretained(this))); | 210 base::Unretained(this))); |
| 200 } | 211 } |
| 201 | 212 |
| 202 } // namespace content | 213 } // namespace content |
| OLD | NEW |