| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/cast_remoting_connector.h" | 5 #include "chrome/browser/media/cast_remoting_connector.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "chrome/browser/media/cast_remoting_connector_messaging.h" | 13 #include "chrome/browser/media/cast_remoting_connector_messaging.h" |
| 14 #include "chrome/browser/media/cast_remoting_sender.h" | 14 #include "chrome/browser/media/cast_remoting_sender.h" |
| 15 #include "chrome/browser/media/router/media_router.h" | 15 #include "chrome/browser/media/router/media_router.h" |
| 16 #include "chrome/browser/media/router/media_router_factory.h" | 16 #include "chrome/browser/media/router/media_router_factory.h" |
| 17 #include "chrome/browser/media/router/media_source_helper.h" | |
| 18 #include "chrome/browser/media/router/route_message.h" | |
| 19 #include "chrome/browser/media/router/route_message_observer.h" | 17 #include "chrome/browser/media/router/route_message_observer.h" |
| 18 #include "chrome/browser/sessions/session_tab_helper.h" |
| 20 #include "chrome/common/chrome_features.h" | 19 #include "chrome/common/chrome_features.h" |
| 20 #include "chrome/common/media_router/media_source_helper.h" |
| 21 #include "chrome/common/media_router/route_message.h" |
| 21 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
| 22 #include "content/public/browser/render_frame_host.h" | 23 #include "content/public/browser/render_frame_host.h" |
| 23 #include "content/public/browser/render_process_host.h" | 24 #include "content/public/browser/render_process_host.h" |
| 24 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
| 25 #include "mojo/public/cpp/bindings/strong_binding.h" | 26 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 26 | 27 |
| 27 using content::BrowserThread; | 28 using content::BrowserThread; |
| 28 using media::mojom::RemotingSinkCapabilities; | 29 using media::mojom::RemotingSinkCapabilities; |
| 29 using media::mojom::RemotingStartFailReason; | 30 using media::mojom::RemotingStartFailReason; |
| 30 using media::mojom::RemotingStopReason; | 31 using media::mojom::RemotingStopReason; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 // static | 136 // static |
| 136 CastRemotingConnector* CastRemotingConnector::Get( | 137 CastRemotingConnector* CastRemotingConnector::Get( |
| 137 content::WebContents* contents) { | 138 content::WebContents* contents) { |
| 138 DCHECK(contents); | 139 DCHECK(contents); |
| 139 CastRemotingConnector* connector = | 140 CastRemotingConnector* connector = |
| 140 static_cast<CastRemotingConnector*>(contents->GetUserData(kUserDataKey)); | 141 static_cast<CastRemotingConnector*>(contents->GetUserData(kUserDataKey)); |
| 141 if (!connector) { | 142 if (!connector) { |
| 142 connector = new CastRemotingConnector( | 143 connector = new CastRemotingConnector( |
| 143 media_router::MediaRouterFactory::GetApiForBrowserContext( | 144 media_router::MediaRouterFactory::GetApiForBrowserContext( |
| 144 contents->GetBrowserContext()), | 145 contents->GetBrowserContext()), |
| 145 media_router::MediaSourceForTabContentRemoting(contents).id()); | 146 media_router::MediaSourceForTabContentRemoting( |
| 147 SessionTabHelper::IdForTab(contents)) |
| 148 .id()); |
| 146 contents->SetUserData(kUserDataKey, connector); | 149 contents->SetUserData(kUserDataKey, connector); |
| 147 } | 150 } |
| 148 return connector; | 151 return connector; |
| 149 } | 152 } |
| 150 | 153 |
| 151 // static | 154 // static |
| 152 void CastRemotingConnector::CreateMediaRemoter( | 155 void CastRemotingConnector::CreateMediaRemoter( |
| 153 content::RenderFrameHost* host, | 156 content::RenderFrameHost* host, |
| 154 media::mojom::RemotingSourcePtr source, | 157 media::mojom::RemotingSourcePtr source, |
| 155 media::mojom::RemoterRequest request) { | 158 media::mojom::RemoterRequest request) { |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 media_router::MediaRoutesObserver::router(), route.media_route_id(), | 507 media_router::MediaRoutesObserver::router(), route.media_route_id(), |
| 505 this)); | 508 this)); |
| 506 // TODO(miu): In the future, scan the route ID for sink capabilities | 509 // TODO(miu): In the future, scan the route ID for sink capabilities |
| 507 // properties and pass these to the source in the OnSinkAvailable() | 510 // properties and pass these to the source in the OnSinkAvailable() |
| 508 // notification. | 511 // notification. |
| 509 for (RemotingBridge* notifyee : bridges_) | 512 for (RemotingBridge* notifyee : bridges_) |
| 510 notifyee->OnSinkAvailable(enabled_features_); | 513 notifyee->OnSinkAvailable(enabled_features_); |
| 511 break; | 514 break; |
| 512 } | 515 } |
| 513 } | 516 } |
| OLD | NEW |