| 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 "chrome/browser/media/router/presentation_service_delegate_impl.h" | 5 #include "chrome/browser/media/router/presentation_service_delegate_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <unordered_map> | 8 #include <unordered_map> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 // Gets the last committed URL for the render frame specified by | 62 // Gets the last committed URL for the render frame specified by |
| 63 // |render_frame_host_id|. | 63 // |render_frame_host_id|. |
| 64 url::Origin GetLastCommittedURLForFrame( | 64 url::Origin GetLastCommittedURLForFrame( |
| 65 RenderFrameHostId render_frame_host_id) { | 65 RenderFrameHostId render_frame_host_id) { |
| 66 RenderFrameHost* render_frame_host = RenderFrameHost::FromID( | 66 RenderFrameHost* render_frame_host = RenderFrameHost::FromID( |
| 67 render_frame_host_id.first, render_frame_host_id.second); | 67 render_frame_host_id.first, render_frame_host_id.second); |
| 68 DCHECK(render_frame_host); | 68 DCHECK(render_frame_host); |
| 69 return render_frame_host->GetLastCommittedOrigin(); | 69 return render_frame_host->GetLastCommittedOrigin(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 // Observes messages originating from the MediaSink connected to a MediaRoute | |
| 73 // that represents a presentation. Converts the messages into | |
| 74 // content::PresentationConnectionMessages and dispatches them via the provided | |
| 75 // PresentationConnectionMessageCallback. | |
| 76 class PresentationConnectionMessagesObserver : public RouteMessageObserver { | |
| 77 public: | |
| 78 // |message_cb|: The callback to invoke whenever messages are received. | |
| 79 // |route_id|: ID of MediaRoute to listen for messages. | |
| 80 PresentationConnectionMessagesObserver( | |
| 81 MediaRouter* router, | |
| 82 const MediaRoute::Id& route_id, | |
| 83 const content::PresentationConnectionMessageCallback& message_cb) | |
| 84 : RouteMessageObserver(router, route_id), message_cb_(message_cb) { | |
| 85 DCHECK(!message_cb_.is_null()); | |
| 86 } | |
| 87 | |
| 88 ~PresentationConnectionMessagesObserver() final {} | |
| 89 | |
| 90 void OnMessagesReceived(const std::vector<RouteMessage>& messages) final { | |
| 91 DVLOG(2) << __func__ << ", number of messages : " << messages.size(); | |
| 92 // TODO(mfoltz): Remove RouteMessage and replace with move-only | |
| 93 // PresentationConnectionMessage. | |
| 94 std::vector<content::PresentationConnectionMessage> presentation_messages; | |
| 95 for (const RouteMessage& message : messages) { | |
| 96 if (message.type == RouteMessage::TEXT && message.text) { | |
| 97 presentation_messages.emplace_back(message.text.value()); | |
| 98 } else if (message.type == RouteMessage::BINARY && message.binary) { | |
| 99 presentation_messages.emplace_back(message.binary.value()); | |
| 100 } else { | |
| 101 NOTREACHED() << "Unknown route message type"; | |
| 102 } | |
| 103 } | |
| 104 message_cb_.Run(std::move(presentation_messages)); | |
| 105 } | |
| 106 | |
| 107 private: | |
| 108 const content::PresentationConnectionMessageCallback message_cb_; | |
| 109 | |
| 110 DISALLOW_COPY_AND_ASSIGN(PresentationConnectionMessagesObserver); | |
| 111 }; | |
| 112 | |
| 113 } // namespace | 72 } // namespace |
| 114 | 73 |
| 115 // Used by PresentationServiceDelegateImpl to manage | 74 // Used by PresentationServiceDelegateImpl to manage |
| 116 // listeners and default presentation info in a render frame. | 75 // listeners and default presentation info in a render frame. |
| 117 // Its lifetime: | 76 // Its lifetime: |
| 118 // * Create an instance with |render_frame_host_id_| if no instance with the | 77 // * Create an instance with |render_frame_host_id_| if no instance with the |
| 119 // same |render_frame_host_id_| exists in: | 78 // same |render_frame_host_id_| exists in: |
| 120 // PresentationFrameManager::OnPresentationConnection | 79 // PresentationFrameManager::OnPresentationConnection |
| 121 // PresentationFrameManager::OnDefaultPresentationStarted | 80 // PresentationFrameManager::OnDefaultPresentationStarted |
| 122 // PresentationFrameManager::SetScreenAvailabilityListener | 81 // PresentationFrameManager::SetScreenAvailabilityListener |
| (...skipping 11 matching lines...) Expand all Loading... |
| 134 content::PresentationScreenAvailabilityListener* listener); | 93 content::PresentationScreenAvailabilityListener* listener); |
| 135 void RemoveScreenAvailabilityListener( | 94 void RemoveScreenAvailabilityListener( |
| 136 content::PresentationScreenAvailabilityListener* listener); | 95 content::PresentationScreenAvailabilityListener* listener); |
| 137 bool HasScreenAvailabilityListenerForTest( | 96 bool HasScreenAvailabilityListenerForTest( |
| 138 const MediaSource::Id& source_id) const; | 97 const MediaSource::Id& source_id) const; |
| 139 std::string GetDefaultPresentationId() const; | 98 std::string GetDefaultPresentationId() const; |
| 140 void ListenForConnectionStateChange( | 99 void ListenForConnectionStateChange( |
| 141 const content::PresentationInfo& connection, | 100 const content::PresentationInfo& connection, |
| 142 const content::PresentationConnectionStateChangedCallback& | 101 const content::PresentationConnectionStateChangedCallback& |
| 143 state_changed_cb); | 102 state_changed_cb); |
| 144 void ListenForConnectionMessages( | |
| 145 const content::PresentationInfo& presentation_info, | |
| 146 const content::PresentationConnectionMessageCallback& message_cb); | |
| 147 | 103 |
| 148 void Reset(); | 104 void Reset(); |
| 149 void RemoveConnection(const std::string& presentation_id, | 105 void RemoveConnection(const std::string& presentation_id, |
| 150 const MediaRoute::Id& route_id); | 106 const MediaRoute::Id& route_id); |
| 151 | 107 |
| 152 const MediaRoute::Id GetRouteId(const std::string& presentation_id) const; | 108 const MediaRoute::Id GetRouteId(const std::string& presentation_id) const; |
| 153 | 109 |
| 154 void OnPresentationConnection( | 110 void OnPresentationConnection( |
| 155 const content::PresentationInfo& presentation_info, | 111 const content::PresentationInfo& presentation_info, |
| 156 const MediaRoute& route); | 112 const MediaRoute& route); |
| 157 void OnPresentationServiceDelegateDestroyed() const; | 113 void OnPresentationServiceDelegateDestroyed() const; |
| 158 | 114 |
| 159 void ConnectToPresentation( | 115 void ConnectToPresentation( |
| 160 const content::PresentationInfo& presentation_info, | 116 const content::PresentationInfo& presentation_info, |
| 161 content::PresentationConnectionPtr controller_connection_ptr, | 117 content::PresentationConnectionPtr controller_connection_ptr, |
| 162 content::PresentationConnectionRequest receiver_connection_request); | 118 content::PresentationConnectionRequest receiver_connection_request); |
| 163 | 119 |
| 164 private: | 120 private: |
| 165 MediaSource GetMediaSourceFromListener( | 121 MediaSource GetMediaSourceFromListener( |
| 166 content::PresentationScreenAvailabilityListener* listener) const; | 122 content::PresentationScreenAvailabilityListener* listener) const; |
| 167 base::small_map<std::map<std::string, MediaRoute>> presentation_id_to_route_; | 123 base::small_map<std::map<std::string, MediaRoute>> presentation_id_to_route_; |
| 168 base::small_map< | 124 base::small_map< |
| 169 std::map<std::string, std::unique_ptr<PresentationMediaSinksObserver>>> | 125 std::map<std::string, std::unique_ptr<PresentationMediaSinksObserver>>> |
| 170 url_to_sinks_observer_; | 126 url_to_sinks_observer_; |
| 171 std::unordered_map< | 127 std::unordered_map< |
| 172 MediaRoute::Id, | 128 MediaRoute::Id, |
| 173 std::unique_ptr<PresentationConnectionStateSubscription>> | 129 std::unique_ptr<PresentationConnectionStateSubscription>> |
| 174 connection_state_subscriptions_; | 130 connection_state_subscriptions_; |
| 175 std::unordered_map<MediaRoute::Id, | 131 std::unordered_map<MediaRoute::Id, |
| 176 std::unique_ptr<PresentationConnectionMessagesObserver>> | |
| 177 connection_messages_observers_; | |
| 178 std::unordered_map<MediaRoute::Id, | |
| 179 std::unique_ptr<BrowserPresentationConnectionProxy>> | 132 std::unique_ptr<BrowserPresentationConnectionProxy>> |
| 180 browser_connection_proxies_; | 133 browser_connection_proxies_; |
| 181 | 134 |
| 182 RenderFrameHostId render_frame_host_id_; | 135 RenderFrameHostId render_frame_host_id_; |
| 183 | 136 |
| 184 // References to the owning WebContents, and the corresponding MediaRouter. | 137 // References to the owning WebContents, and the corresponding MediaRouter. |
| 185 content::WebContents* web_contents_; | 138 content::WebContents* web_contents_; |
| 186 MediaRouter* router_; | 139 MediaRouter* router_; |
| 187 }; | 140 }; |
| 188 | 141 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 url_to_sinks_observer_.erase(sinks_observer_it); | 201 url_to_sinks_observer_.erase(sinks_observer_it); |
| 249 } | 202 } |
| 250 } | 203 } |
| 251 | 204 |
| 252 bool PresentationFrame::HasScreenAvailabilityListenerForTest( | 205 bool PresentationFrame::HasScreenAvailabilityListenerForTest( |
| 253 const MediaSource::Id& source_id) const { | 206 const MediaSource::Id& source_id) const { |
| 254 return url_to_sinks_observer_.find(source_id) != url_to_sinks_observer_.end(); | 207 return url_to_sinks_observer_.find(source_id) != url_to_sinks_observer_.end(); |
| 255 } | 208 } |
| 256 | 209 |
| 257 void PresentationFrame::Reset() { | 210 void PresentationFrame::Reset() { |
| 258 | |
| 259 for (const auto& pid_route : presentation_id_to_route_) { | 211 for (const auto& pid_route : presentation_id_to_route_) { |
| 260 if (pid_route.second.is_offscreen_presentation()) { | 212 if (pid_route.second.is_offscreen_presentation()) { |
| 261 auto* offscreen_presentation_manager = | 213 auto* offscreen_presentation_manager = |
| 262 OffscreenPresentationManagerFactory::GetOrCreateForWebContents( | 214 OffscreenPresentationManagerFactory::GetOrCreateForWebContents( |
| 263 web_contents_); | 215 web_contents_); |
| 264 offscreen_presentation_manager->UnregisterOffscreenPresentationController( | 216 offscreen_presentation_manager->UnregisterOffscreenPresentationController( |
| 265 pid_route.first, render_frame_host_id_); | 217 pid_route.first, render_frame_host_id_); |
| 266 } else { | 218 } else { |
| 267 router_->DetachRoute(pid_route.second.media_route_id()); | 219 router_->DetachRoute(pid_route.second.media_route_id()); |
| 268 } | 220 } |
| 269 } | 221 } |
| 270 | 222 |
| 271 presentation_id_to_route_.clear(); | 223 presentation_id_to_route_.clear(); |
| 272 url_to_sinks_observer_.clear(); | 224 url_to_sinks_observer_.clear(); |
| 273 connection_state_subscriptions_.clear(); | 225 connection_state_subscriptions_.clear(); |
| 274 connection_messages_observers_.clear(); | |
| 275 browser_connection_proxies_.clear(); | 226 browser_connection_proxies_.clear(); |
| 276 } | 227 } |
| 277 | 228 |
| 278 void PresentationFrame::RemoveConnection(const std::string& presentation_id, | 229 void PresentationFrame::RemoveConnection(const std::string& presentation_id, |
| 279 const MediaRoute::Id& route_id) { | 230 const MediaRoute::Id& route_id) { |
| 280 // Remove the presentation id mapping so a later call to Reset is a no-op. | 231 // Remove the presentation id mapping so a later call to Reset is a no-op. |
| 281 presentation_id_to_route_.erase(presentation_id); | 232 presentation_id_to_route_.erase(presentation_id); |
| 282 | 233 |
| 283 // We no longer need to observe route messages. | |
| 284 connection_messages_observers_.erase(route_id); | |
| 285 | |
| 286 browser_connection_proxies_.erase(route_id); | 234 browser_connection_proxies_.erase(route_id); |
| 287 // We keep the PresentationConnectionStateChangedCallback registered with MR | 235 // We keep the PresentationConnectionStateChangedCallback registered with MR |
| 288 // so the MRP can tell us when terminate() completed. | 236 // so the MRP can tell us when terminate() completed. |
| 289 } | 237 } |
| 290 | 238 |
| 291 void PresentationFrame::ListenForConnectionStateChange( | 239 void PresentationFrame::ListenForConnectionStateChange( |
| 292 const content::PresentationInfo& connection, | 240 const content::PresentationInfo& connection, |
| 293 const content::PresentationConnectionStateChangedCallback& | 241 const content::PresentationConnectionStateChangedCallback& |
| 294 state_changed_cb) { | 242 state_changed_cb) { |
| 295 auto it = presentation_id_to_route_.find(connection.presentation_id); | 243 auto it = presentation_id_to_route_.find(connection.presentation_id); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 306 << "Already listening connection state change for route: " | 254 << "Already listening connection state change for route: " |
| 307 << route_id; | 255 << route_id; |
| 308 return; | 256 return; |
| 309 } | 257 } |
| 310 | 258 |
| 311 connection_state_subscriptions_.insert(std::make_pair( | 259 connection_state_subscriptions_.insert(std::make_pair( |
| 312 route_id, router_->AddPresentationConnectionStateChangedCallback( | 260 route_id, router_->AddPresentationConnectionStateChangedCallback( |
| 313 route_id, state_changed_cb))); | 261 route_id, state_changed_cb))); |
| 314 } | 262 } |
| 315 | 263 |
| 316 void PresentationFrame::ListenForConnectionMessages( | |
| 317 const content::PresentationInfo& presentation_info, | |
| 318 const content::PresentationConnectionMessageCallback& message_cb) { | |
| 319 auto it = presentation_id_to_route_.find(presentation_info.presentation_id); | |
| 320 if (it == presentation_id_to_route_.end()) { | |
| 321 DVLOG(2) << "ListenForConnectionMessages: no route for " | |
| 322 << presentation_info.presentation_id; | |
| 323 return; | |
| 324 } | |
| 325 | |
| 326 if (it->second.is_offscreen_presentation()) { | |
| 327 DVLOG(2) << "ListenForConnectionMessages: do not listen for offscreen " | |
| 328 << "presentation [id]: " << presentation_info.presentation_id; | |
| 329 return; | |
| 330 } | |
| 331 | |
| 332 const MediaRoute::Id& route_id = it->second.media_route_id(); | |
| 333 if (connection_messages_observers_.find(route_id) != | |
| 334 connection_messages_observers_.end()) { | |
| 335 DLOG(ERROR) << __func__ | |
| 336 << "Already listening for connection messages for route: " | |
| 337 << route_id; | |
| 338 return; | |
| 339 } | |
| 340 | |
| 341 connection_messages_observers_.insert(std::make_pair( | |
| 342 route_id, base::MakeUnique<PresentationConnectionMessagesObserver>( | |
| 343 router_, route_id, message_cb))); | |
| 344 } | |
| 345 | |
| 346 MediaSource PresentationFrame::GetMediaSourceFromListener( | 264 MediaSource PresentationFrame::GetMediaSourceFromListener( |
| 347 content::PresentationScreenAvailabilityListener* listener) const { | 265 content::PresentationScreenAvailabilityListener* listener) const { |
| 348 // If the default presentation URL is empty then fall back to tab mirroring. | 266 // If the default presentation URL is empty then fall back to tab mirroring. |
| 349 return listener->GetAvailabilityUrl().is_empty() | 267 return listener->GetAvailabilityUrl().is_empty() |
| 350 ? MediaSourceForTab(SessionTabHelper::IdForTab(web_contents_)) | 268 ? MediaSourceForTab(SessionTabHelper::IdForTab(web_contents_)) |
| 351 : MediaSourceForPresentationUrl(listener->GetAvailabilityUrl()); | 269 : MediaSourceForPresentationUrl(listener->GetAvailabilityUrl()); |
| 352 } | 270 } |
| 353 | 271 |
| 354 void PresentationFrame::ConnectToPresentation( | 272 void PresentationFrame::ConnectToPresentation( |
| 355 const content::PresentationInfo& presentation_info, | 273 const content::PresentationInfo& presentation_info, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 370 web_contents_); | 288 web_contents_); |
| 371 offscreen_presentation_manager->RegisterOffscreenPresentationController( | 289 offscreen_presentation_manager->RegisterOffscreenPresentationController( |
| 372 presentation_info.presentation_id, presentation_info.presentation_url, | 290 presentation_info.presentation_id, presentation_info.presentation_url, |
| 373 render_frame_host_id_, std::move(controller_connection_ptr), | 291 render_frame_host_id_, std::move(controller_connection_ptr), |
| 374 std::move(receiver_connection_request), pid_route_it->second); | 292 std::move(receiver_connection_request), pid_route_it->second); |
| 375 } else { | 293 } else { |
| 376 DVLOG(2) | 294 DVLOG(2) |
| 377 << "Creating BrowserPresentationConnectionProxy for [presentation_id]: " | 295 << "Creating BrowserPresentationConnectionProxy for [presentation_id]: " |
| 378 << presentation_info.presentation_id; | 296 << presentation_info.presentation_id; |
| 379 MediaRoute::Id route_id = pid_route_it->second.media_route_id(); | 297 MediaRoute::Id route_id = pid_route_it->second.media_route_id(); |
| 298 if (base::ContainsKey(browser_connection_proxies_, route_id)) { |
| 299 DLOG(ERROR) << __func__ |
| 300 << "Already has a BrowserPresentationConnectionProxy for " |
| 301 << "route: " << route_id; |
| 302 return; |
| 303 } |
| 304 |
| 380 auto* proxy = new BrowserPresentationConnectionProxy( | 305 auto* proxy = new BrowserPresentationConnectionProxy( |
| 381 router_, route_id, std::move(receiver_connection_request), | 306 router_, route_id, std::move(receiver_connection_request), |
| 382 std::move(controller_connection_ptr)); | 307 std::move(controller_connection_ptr)); |
| 383 | |
| 384 browser_connection_proxies_.insert( | 308 browser_connection_proxies_.insert( |
| 385 std::make_pair(route_id, base::WrapUnique(proxy))); | 309 std::make_pair(route_id, base::WrapUnique(proxy))); |
| 386 } | 310 } |
| 387 } | 311 } |
| 388 | 312 |
| 389 // Used by PresentationServiceDelegateImpl to manage PresentationFrames. | 313 // Used by PresentationServiceDelegateImpl to manage PresentationFrames. |
| 390 class PresentationFrameManager { | 314 class PresentationFrameManager { |
| 391 public: | 315 public: |
| 392 PresentationFrameManager(content::WebContents* web_contents, | 316 PresentationFrameManager(content::WebContents* web_contents, |
| 393 MediaRouter* router); | 317 MediaRouter* router); |
| 394 ~PresentationFrameManager(); | 318 ~PresentationFrameManager(); |
| 395 | 319 |
| 396 // Mirror corresponding APIs in PresentationServiceDelegateImpl. | 320 // Mirror corresponding APIs in PresentationServiceDelegateImpl. |
| 397 bool SetScreenAvailabilityListener( | 321 bool SetScreenAvailabilityListener( |
| 398 const RenderFrameHostId& render_frame_host_id, | 322 const RenderFrameHostId& render_frame_host_id, |
| 399 content::PresentationScreenAvailabilityListener* listener); | 323 content::PresentationScreenAvailabilityListener* listener); |
| 400 void RemoveScreenAvailabilityListener( | 324 void RemoveScreenAvailabilityListener( |
| 401 const RenderFrameHostId& render_frame_host_id, | 325 const RenderFrameHostId& render_frame_host_id, |
| 402 content::PresentationScreenAvailabilityListener* listener); | 326 content::PresentationScreenAvailabilityListener* listener); |
| 403 void ListenForConnectionStateChange( | 327 void ListenForConnectionStateChange( |
| 404 const RenderFrameHostId& render_frame_host_id, | 328 const RenderFrameHostId& render_frame_host_id, |
| 405 const content::PresentationInfo& connection, | 329 const content::PresentationInfo& connection, |
| 406 const content::PresentationConnectionStateChangedCallback& | 330 const content::PresentationConnectionStateChangedCallback& |
| 407 state_changed_cb); | 331 state_changed_cb); |
| 408 void ListenForConnectionMessages( | |
| 409 const RenderFrameHostId& render_frame_host_id, | |
| 410 const content::PresentationInfo& presentation_info, | |
| 411 const content::PresentationConnectionMessageCallback& message_cb); | |
| 412 | 332 |
| 413 // Sets or clears the default presentation request and callback for the given | 333 // Sets or clears the default presentation request and callback for the given |
| 414 // frame. Also sets / clears the default presentation requests for the owning | 334 // frame. Also sets / clears the default presentation requests for the owning |
| 415 // tab WebContents. | 335 // tab WebContents. |
| 416 void SetDefaultPresentationUrls( | 336 void SetDefaultPresentationUrls( |
| 417 const RenderFrameHostId& render_frame_host_id, | 337 const RenderFrameHostId& render_frame_host_id, |
| 418 const std::vector<GURL>& default_presentation_urls, | 338 const std::vector<GURL>& default_presentation_urls, |
| 419 const content::PresentationConnectionCallback& callback); | 339 const content::PresentationConnectionCallback& callback); |
| 420 void AddDelegateObserver(const RenderFrameHostId& render_frame_host_id, | 340 void AddDelegateObserver(const RenderFrameHostId& render_frame_host_id, |
| 421 DelegateObserver* observer); | 341 DelegateObserver* observer); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 void PresentationFrameManager::ListenForConnectionStateChange( | 496 void PresentationFrameManager::ListenForConnectionStateChange( |
| 577 const RenderFrameHostId& render_frame_host_id, | 497 const RenderFrameHostId& render_frame_host_id, |
| 578 const content::PresentationInfo& connection, | 498 const content::PresentationInfo& connection, |
| 579 const content::PresentationConnectionStateChangedCallback& | 499 const content::PresentationConnectionStateChangedCallback& |
| 580 state_changed_cb) { | 500 state_changed_cb) { |
| 581 const auto it = presentation_frames_.find(render_frame_host_id); | 501 const auto it = presentation_frames_.find(render_frame_host_id); |
| 582 if (it != presentation_frames_.end()) | 502 if (it != presentation_frames_.end()) |
| 583 it->second->ListenForConnectionStateChange(connection, state_changed_cb); | 503 it->second->ListenForConnectionStateChange(connection, state_changed_cb); |
| 584 } | 504 } |
| 585 | 505 |
| 586 void PresentationFrameManager::ListenForConnectionMessages( | |
| 587 const RenderFrameHostId& render_frame_host_id, | |
| 588 const content::PresentationInfo& presentation_info, | |
| 589 const content::PresentationConnectionMessageCallback& message_cb) { | |
| 590 const auto it = presentation_frames_.find(render_frame_host_id); | |
| 591 if (it == presentation_frames_.end()) { | |
| 592 DVLOG(2) << "ListenForConnectionMessages: PresentationFrame does not exist " | |
| 593 << "for: (" << render_frame_host_id.first << ", " | |
| 594 << render_frame_host_id.second << ")"; | |
| 595 return; | |
| 596 } | |
| 597 it->second->ListenForConnectionMessages(presentation_info, message_cb); | |
| 598 } | |
| 599 | |
| 600 void PresentationFrameManager::SetDefaultPresentationUrls( | 506 void PresentationFrameManager::SetDefaultPresentationUrls( |
| 601 const RenderFrameHostId& render_frame_host_id, | 507 const RenderFrameHostId& render_frame_host_id, |
| 602 const std::vector<GURL>& default_presentation_urls, | 508 const std::vector<GURL>& default_presentation_urls, |
| 603 const content::PresentationConnectionCallback& callback) { | 509 const content::PresentationConnectionCallback& callback) { |
| 604 if (!IsMainFrame(render_frame_host_id)) | 510 if (!IsMainFrame(render_frame_host_id)) |
| 605 return; | 511 return; |
| 606 | 512 |
| 607 if (default_presentation_urls.empty()) { | 513 if (default_presentation_urls.empty()) { |
| 608 ClearDefaultPresentationRequest(); | 514 ClearDefaultPresentationRequest(); |
| 609 } else { | 515 } else { |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 956 const MediaRoute::Id& route_id = | 862 const MediaRoute::Id& route_id = |
| 957 frame_manager_->GetRouteId(rfh_id, presentation_id); | 863 frame_manager_->GetRouteId(rfh_id, presentation_id); |
| 958 if (route_id.empty()) { | 864 if (route_id.empty()) { |
| 959 DVLOG(1) << "No active route for: " << presentation_id; | 865 DVLOG(1) << "No active route for: " << presentation_id; |
| 960 return; | 866 return; |
| 961 } | 867 } |
| 962 router_->TerminateRoute(route_id); | 868 router_->TerminateRoute(route_id); |
| 963 frame_manager_->RemoveConnection(rfh_id, presentation_id, route_id); | 869 frame_manager_->RemoveConnection(rfh_id, presentation_id, route_id); |
| 964 } | 870 } |
| 965 | 871 |
| 966 void PresentationServiceDelegateImpl::ListenForConnectionMessages( | |
| 967 int render_process_id, | |
| 968 int render_frame_id, | |
| 969 const content::PresentationInfo& presentation_info, | |
| 970 const content::PresentationConnectionMessageCallback& message_cb) { | |
| 971 frame_manager_->ListenForConnectionMessages( | |
| 972 RenderFrameHostId(render_process_id, render_frame_id), presentation_info, | |
| 973 message_cb); | |
| 974 } | |
| 975 | |
| 976 void PresentationServiceDelegateImpl::SendMessage( | 872 void PresentationServiceDelegateImpl::SendMessage( |
| 977 int render_process_id, | 873 int render_process_id, |
| 978 int render_frame_id, | 874 int render_frame_id, |
| 979 const content::PresentationInfo& presentation_info, | 875 const content::PresentationInfo& presentation_info, |
| 980 content::PresentationConnectionMessage message, | 876 content::PresentationConnectionMessage message, |
| 981 SendMessageCallback send_message_cb) { | 877 SendMessageCallback send_message_cb) { |
| 982 const MediaRoute::Id& route_id = frame_manager_->GetRouteId( | 878 const MediaRoute::Id& route_id = frame_manager_->GetRouteId( |
| 983 RenderFrameHostId(render_process_id, render_frame_id), | 879 RenderFrameHostId(render_process_id, render_frame_id), |
| 984 presentation_info.presentation_id); | 880 presentation_info.presentation_id); |
| 985 if (route_id.empty()) { | 881 if (route_id.empty()) { |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1083 const base::ListValue* origins = | 979 const base::ListValue* origins = |
| 1084 Profile::FromBrowserContext(web_contents_->GetBrowserContext()) | 980 Profile::FromBrowserContext(web_contents_->GetBrowserContext()) |
| 1085 ->GetPrefs() | 981 ->GetPrefs() |
| 1086 ->GetList(prefs::kMediaRouterTabMirroringSources); | 982 ->GetList(prefs::kMediaRouterTabMirroringSources); |
| 1087 return origins && | 983 return origins && |
| 1088 origins->Find(base::Value(origin.Serialize())) != origins->end(); | 984 origins->Find(base::Value(origin.Serialize())) != origins->end(); |
| 1089 } | 985 } |
| 1090 #endif // !defined(OS_ANDROID) | 986 #endif // !defined(OS_ANDROID) |
| 1091 | 987 |
| 1092 } // namespace media_router | 988 } // namespace media_router |
| OLD | NEW |