Index: content/browser/frame_host/render_frame_host_impl.cc |
diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc |
index a0bd7a4cab1230aa9b31931e38929ef992a59942..35dd4054702cbbc2901f7f1cd12c0d9003a4552f 100644 |
--- a/content/browser/frame_host/render_frame_host_impl.cc |
+++ b/content/browser/frame_host/render_frame_host_impl.cc |
@@ -21,6 +21,7 @@ |
#include "content/browser/accessibility/browser_accessibility_manager.h" |
#include "content/browser/accessibility/browser_accessibility_state_impl.h" |
#include "content/browser/bluetooth/web_bluetooth_service_impl.h" |
+#include "content/browser/browser_main_loop.h" |
#include "content/browser/child_process_security_policy_impl.h" |
#include "content/browser/devtools/render_frame_devtools_agent_host.h" |
#include "content/browser/download/mhtml_generation_manager.h" |
@@ -43,6 +44,7 @@ |
#include "content/browser/presentation/presentation_service_impl.h" |
#include "content/browser/renderer_host/input/input_router_impl.h" |
#include "content/browser/renderer_host/input/timeout_monitor.h" |
+#include "content/browser/renderer_host/media/media_devices_dispatcher_host.h" |
#include "content/browser/renderer_host/render_process_host_impl.h" |
#include "content/browser/renderer_host/render_view_host_delegate.h" |
#include "content/browser/renderer_host/render_view_host_delegate_view.h" |
@@ -74,6 +76,7 @@ |
#include "content/public/browser/permission_type.h" |
#include "content/public/browser/render_process_host.h" |
#include "content/public/browser/render_widget_host_view.h" |
+#include "content/public/browser/resource_context.h" |
#include "content/public/browser/storage_partition.h" |
#include "content/public/browser/stream_handle.h" |
#include "content/public/browser/user_metrics.h" |
@@ -2209,6 +2212,28 @@ void RenderFrameHostImpl::RegisterMojoInterfaces() { |
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)); |
} |
+#if defined(ENABLE_WEBRTC) |
+ // BrowserMainLoop::GetInstance() may be null on unit tests. |
+ if (BrowserMainLoop::GetInstance()) { |
+ // BrowserMainLoop, which owns MediaStreamManager, is alive for the lifetime |
+ // of Mojo communication (see BrowserMainLoop::ShutdownThreadsAndCleanUp(), |
+ // which shuts down Mojo). Hence, passing that MediaStreamManager instance |
+ // as a raw pointer here is safe. |
+ MediaStreamManager* media_stream_manager = |
+ BrowserMainLoop::GetInstance()->media_stream_manager(); |
+ GetInterfaceRegistry()->AddInterface( |
+ base::Bind(&MediaDevicesDispatcherHost::Create, GetProcess()->GetID(), |
+ GetRoutingID(), GetProcess() |
+ ->GetBrowserContext() |
+ ->GetResourceContext() |
+ ->GetMediaDeviceIDSalt(), |
+ base::Unretained(media_stream_manager), |
+ base::CommandLine::ForCurrentProcess()->HasSwitch( |
+ switches::kUseFakeUIForMediaStream)), |
+ BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)); |
+ } |
+#endif |
+ |
GetContentClient()->browser()->RegisterRenderFrameMojoInterfaces( |
GetInterfaceRegistry(), this); |
} |