#include "content/browser/xr/service/xr_runtime_manager_impl.h"
#include <string>
#include <utility>
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/lazy_instance.h"
#include "base/memory/singleton.h"
#include "base/no_destructor.h"
#include "base/not_fatal_until.h"
#include "base/observer_list.h"
#include "base/strings/string_number_conversions.h"
#include "base/trace_event/trace_event.h"
#include "base/trace_event/typed_macros.h"
#include "build/build_config.h"
#include "content/browser/xr/service/xr_frame_sink_client_impl.h"
#include "content/browser/xr/webxr_internals/mojom/webxr_internals.mojom.h"
#include "content/browser/xr/webxr_internals/webxr_internals_handler_impl.h"
#include "content/browser/xr/xr_utils.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/device_service.h"
#include "content/public/browser/gpu_data_manager.h"
#include "content/public/browser/gpu_utils.h"
#include "content/public/browser/xr_runtime_manager.h"
#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
#include "device/vr/buildflags/buildflags.h"
#include "device/vr/orientation/orientation_device_provider.h"
#include "device/vr/public/cpp/features.h"
#include "device/vr/public/cpp/vr_device_provider.h"
#include "gpu/config/gpu_info.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "services/device/public/mojom/sensor_provider.mojom.h"
#include "ui/gl/gl_switches.h"
#if !BUILDFLAG(IS_ANDROID)
#include "content/browser/xr/service/isolated_device_provider.h"
#endif
namespace content {
XrRuntimeManagerObservers;
namespace {
XRRuntimeManagerImpl* g_xr_runtime_manager = …;
XrRuntimeManagerObservers& GetXrRuntimeManagerObservers() { … }
#if !BUILDFLAG(IS_ANDROID)
bool IsEnabled(const base::CommandLine* command_line,
const base::Feature& feature,
const std::string& name) { … }
#endif
bool IsForcedRuntime(const base::CommandLine* command_line,
const std::string& name) { … }
std::optional<device::mojom::XRDeviceId> GetForcedRuntime(
device::mojom::XRSessionMode mode) { … }
std::unique_ptr<device::XrFrameSinkClient> FrameSinkClientFactory(
int32_t render_process_id,
int32_t render_frame_id) { … }
}
XRRuntimeManager* XRRuntimeManager::GetInstanceIfCreated() { … }
void XRRuntimeManager::AddObserver(XRRuntimeManager::Observer* observer) { … }
void XRRuntimeManager::RemoveObserver(XRRuntimeManager::Observer* observer) { … }
void XRRuntimeManager::ExitImmersivePresentation() { … }
scoped_refptr<XRRuntimeManagerImpl>
XRRuntimeManagerImpl::GetOrCreateRuntimeManagerInternal(
WebContents* web_contents) { … }
scoped_refptr<XRRuntimeManagerImpl> XRRuntimeManagerImpl::GetOrCreateInstance(
WebContents& web_contents) { … }
scoped_refptr<XRRuntimeManagerImpl>
XRRuntimeManagerImpl::GetOrCreateInstanceForTesting() { … }
content::WebContents* XRRuntimeManagerImpl::GetImmersiveSessionWebContents() { … }
void XRRuntimeManagerImpl::AddService(VRServiceImpl* service) { … }
void XRRuntimeManagerImpl::RemoveService(VRServiceImpl* service) { … }
BrowserXRRuntimeImpl* XRRuntimeManagerImpl::GetRuntime(
device::mojom::XRDeviceId id) { … }
content::WebXrLoggerManager& XRRuntimeManagerImpl::GetLoggerManager() { … }
BrowserXRRuntimeImpl* XRRuntimeManagerImpl::GetRuntimeForOptions(
device::mojom::XRSessionOptions* options) { … }
BrowserXRRuntimeImpl* XRRuntimeManagerImpl::GetImmersiveVrRuntime() { … }
BrowserXRRuntimeImpl* XRRuntimeManagerImpl::GetImmersiveArRuntime() { … }
BrowserXRRuntimeImpl* XRRuntimeManagerImpl::GetInlineRuntime() { … }
BrowserXRRuntimeImpl*
XRRuntimeManagerImpl::GetCurrentlyPresentingImmersiveRuntime() { … }
bool XRRuntimeManagerImpl::HasPendingImmersiveRequest() { … }
bool XRRuntimeManagerImpl::IsOtherClientPresenting(VRServiceImpl* service) { … }
void XRRuntimeManagerImpl::SupportsSession(
device::mojom::XRSessionOptionsPtr options,
device::mojom::VRService::SupportsSessionCallback callback) { … }
void XRRuntimeManagerImpl::MakeXrCompatible() { … }
bool XRRuntimeManagerImpl::IsInitializedOnCompatibleAdapter(
BrowserXRRuntimeImpl* runtime) { … }
void XRRuntimeManagerImpl::OnGpuInfoUpdate() { … }
XRRuntimeManagerImpl::XRRuntimeManagerImpl(XRProviderList providers,
WebContents* web_contents)
: … { … }
XRRuntimeManagerImpl::~XRRuntimeManagerImpl() { … }
scoped_refptr<XRRuntimeManagerImpl> XRRuntimeManagerImpl::CreateInstance(
XRProviderList providers,
WebContents* contents) { … }
device::mojom::XRRuntime* XRRuntimeManagerImpl::GetRuntimeForTest(
device::mojom::XRDeviceId id) { … }
size_t XRRuntimeManagerImpl::NumberOfConnectedServices() { … }
void XRRuntimeManagerImpl::InitializeProviders(WebContents* web_contents) { … }
void XRRuntimeManagerImpl::OnProviderInitialized() { … }
bool XRRuntimeManagerImpl::AreAllProvidersInitialized() { … }
void XRRuntimeManagerImpl::AddRuntime(
device::mojom::XRDeviceId id,
device::mojom::XRDeviceDataPtr device_data,
mojo::PendingRemote<device::mojom::XRRuntime> runtime) { … }
void XRRuntimeManagerImpl::RemoveRuntime(device::mojom::XRDeviceId id) { … }
device::XrFrameSinkClientFactory
XRRuntimeManagerImpl::GetXrFrameSinkClientFactory() { … }
std::vector<webxr::mojom::RuntimeInfoPtr>
XRRuntimeManagerImpl::GetActiveRuntimes() { … }
}