Commit c8448702 authored by Alexander Cooper's avatar Alexander Cooper Committed by Commit Bot

Move XrInstallHelper interface/factory to content/

Moves the existing XrInstallHelper interface to content/public/browser
and creates an XrIntegrationClient interface. This allows embedders to
provide any factory methods for XR that may end up being required.
Currently this is expected to be GetXrInstallHelper and GetVrUiHost.

A mojom interface method was considered, but ultimately not feasible as
most of the installation steps actually still need to stay in the
browser process and some steps are also chrome specific. This code needs
to remain in the browser process because the install kicks off an intent
to the Play Store, which needs to be notified of the Resume event, and
in chrome as some of the installation paths (mainly for ARCore) show
custom UI. In addition to intenting out to the play store, VR also needs
to ensure that the appropriate DFM is installed, which is specific to
chrome.

Note that for AR, if an embedder were to require ARCore in their app
manifest, the current installation steps would mostly be a no-op, though
it is still recommended to check the ARCore install status.

This is one of the refactors that needs to happen before VRServiceImpl
can be moved into content.

Bug: 1031622
Change-Id: I730ec082422a92f47b5b8abe0cebe5dd9bb68c12
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2095957
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Reviewed-by: default avatarKlaus Weidner <klausw@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#750376}
parent 32b83391
...@@ -5403,10 +5403,11 @@ jumbo_static_library("browser") { ...@@ -5403,10 +5403,11 @@ jumbo_static_library("browser") {
"component_updater/vr_assets_component_installer.h", "component_updater/vr_assets_component_installer.h",
"vr/service/browser_xr_runtime.cc", "vr/service/browser_xr_runtime.cc",
"vr/service/browser_xr_runtime.h", "vr/service/browser_xr_runtime.h",
"vr/service/chrome_xr_integration_client.cc",
"vr/service/chrome_xr_integration_client.h",
"vr/service/vr_service_impl.cc", "vr/service/vr_service_impl.cc",
"vr/service/vr_service_impl.h", "vr/service/vr_service_impl.h",
"vr/service/xr_consent_helper.h", "vr/service/xr_consent_helper.h",
"vr/service/xr_install_helper.h",
"vr/service/xr_runtime_manager.cc", "vr/service/xr_runtime_manager.cc",
"vr/service/xr_runtime_manager.h", "vr/service/xr_runtime_manager.h",
] ]
......
...@@ -63,7 +63,7 @@ ArCoreInstallHelper::~ArCoreInstallHelper() { ...@@ -63,7 +63,7 @@ ArCoreInstallHelper::~ArCoreInstallHelper() {
void ArCoreInstallHelper::EnsureInstalled( void ArCoreInstallHelper::EnsureInstalled(
int render_process_id, int render_process_id,
int render_frame_id, int render_frame_id,
OnInstallFinishedCallback install_callback) { base::OnceCallback<void(bool)> install_callback) {
DCHECK(!install_finished_callback_); DCHECK(!install_finished_callback_);
install_finished_callback_ = std::move(install_callback); install_finished_callback_ = std::move(install_callback);
......
...@@ -9,12 +9,12 @@ ...@@ -9,12 +9,12 @@
#include "base/android/scoped_java_ref.h" #include "base/android/scoped_java_ref.h"
#include "base/callback.h" #include "base/callback.h"
#include "base/threading/thread_checker.h" #include "base/threading/thread_checker.h"
#include "chrome/browser/vr/service/xr_install_helper.h"
#include "chrome/browser/vr/vr_export.h" #include "chrome/browser/vr/vr_export.h"
#include "content/public/browser/xr_install_helper.h"
namespace vr { namespace vr {
class VR_EXPORT ArCoreInstallHelper : public XrInstallHelper { class VR_EXPORT ArCoreInstallHelper : public content::XrInstallHelper {
public: public:
ArCoreInstallHelper(); ArCoreInstallHelper();
~ArCoreInstallHelper() override; ~ArCoreInstallHelper() override;
...@@ -22,9 +22,10 @@ class VR_EXPORT ArCoreInstallHelper : public XrInstallHelper { ...@@ -22,9 +22,10 @@ class VR_EXPORT ArCoreInstallHelper : public XrInstallHelper {
ArCoreInstallHelper(const ArCoreInstallHelper&) = delete; ArCoreInstallHelper(const ArCoreInstallHelper&) = delete;
ArCoreInstallHelper& operator=(const ArCoreInstallHelper&) = delete; ArCoreInstallHelper& operator=(const ArCoreInstallHelper&) = delete;
void EnsureInstalled(int render_process_id, void EnsureInstalled(
int render_frame_id, int render_process_id,
OnInstallFinishedCallback install_callback) override; int render_frame_id,
base::OnceCallback<void(bool)> install_callback) override;
// Called from Java end. // Called from Java end.
void OnRequestInstallSupportedArCoreResult(JNIEnv* env, bool success); void OnRequestInstallSupportedArCoreResult(JNIEnv* env, bool success);
...@@ -32,7 +33,7 @@ class VR_EXPORT ArCoreInstallHelper : public XrInstallHelper { ...@@ -32,7 +33,7 @@ class VR_EXPORT ArCoreInstallHelper : public XrInstallHelper {
private: private:
void RunInstallFinishedCallback(bool succeeded); void RunInstallFinishedCallback(bool succeeded);
OnInstallFinishedCallback install_finished_callback_; base::OnceCallback<void(bool)> install_finished_callback_;
base::android::ScopedJavaGlobalRef<jobject> java_install_utils_; base::android::ScopedJavaGlobalRef<jobject> java_install_utils_;
}; };
......
...@@ -22,7 +22,8 @@ GvrInstallHelper::~GvrInstallHelper() { ...@@ -22,7 +22,8 @@ GvrInstallHelper::~GvrInstallHelper() {
void GvrInstallHelper::EnsureInstalled( void GvrInstallHelper::EnsureInstalled(
int render_process_id, int render_process_id,
int render_frame_id, int render_frame_id,
OnInstallFinishedCallback install_callback) { base::OnceCallback<void(bool)> install_callback) {
DVLOG(1) << __func__;
// Callers should ensure they only prompt for install once. // Callers should ensure they only prompt for install once.
DCHECK(!install_finished_callback_); DCHECK(!install_finished_callback_);
......
...@@ -10,12 +10,12 @@ ...@@ -10,12 +10,12 @@
#include "base/callback.h" #include "base/callback.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "chrome/browser/android/vr/vr_module_provider.h" #include "chrome/browser/android/vr/vr_module_provider.h"
#include "chrome/browser/vr/service/xr_install_helper.h"
#include "chrome/browser/vr/vr_export.h" #include "chrome/browser/vr/vr_export.h"
#include "content/public/browser/xr_install_helper.h"
namespace vr { namespace vr {
class VR_EXPORT GvrInstallHelper : public XrInstallHelper { class VR_EXPORT GvrInstallHelper : public content::XrInstallHelper {
public: public:
GvrInstallHelper(); GvrInstallHelper();
~GvrInstallHelper() override; ~GvrInstallHelper() override;
...@@ -23,15 +23,16 @@ class VR_EXPORT GvrInstallHelper : public XrInstallHelper { ...@@ -23,15 +23,16 @@ class VR_EXPORT GvrInstallHelper : public XrInstallHelper {
GvrInstallHelper(const GvrInstallHelper&) = delete; GvrInstallHelper(const GvrInstallHelper&) = delete;
GvrInstallHelper& operator=(const GvrInstallHelper&) = delete; GvrInstallHelper& operator=(const GvrInstallHelper&) = delete;
void EnsureInstalled(int render_process_id, void EnsureInstalled(
int render_frame_id, int render_process_id,
OnInstallFinishedCallback install_callback) override; int render_frame_id,
base::OnceCallback<void(bool)> install_callback) override;
private: private:
void OnModuleInstalled(bool success); void OnModuleInstalled(bool success);
void RunInstallFinishedCallback(bool succeeded); void RunInstallFinishedCallback(bool succeeded);
OnInstallFinishedCallback install_finished_callback_; base::OnceCallback<void(bool)> install_finished_callback_;
std::unique_ptr<VrModuleProvider> module_delegate_; std::unique_ptr<VrModuleProvider> module_delegate_;
base::WeakPtrFactory<GvrInstallHelper> weak_ptr_{this}; base::WeakPtrFactory<GvrInstallHelper> weak_ptr_{this};
......
...@@ -597,6 +597,10 @@ ...@@ -597,6 +597,10 @@
#include "chrome/browser/safe_browsing/cloud_content_scanning/deep_scanning_dialog_delegate.h" #include "chrome/browser/safe_browsing/cloud_content_scanning/deep_scanning_dialog_delegate.h"
#endif #endif
#if BUILDFLAG(ENABLE_VR)
#include "chrome/browser/vr/service/chrome_xr_integration_client.h"
#endif
using base::FileDescriptor; using base::FileDescriptor;
using content::BrowserThread; using content::BrowserThread;
using content::BrowserURLHandler; using content::BrowserURLHandler;
...@@ -5540,3 +5544,13 @@ bool ChromeContentBrowserClient::ShouldAllowPluginCreation( ...@@ -5540,3 +5544,13 @@ bool ChromeContentBrowserClient::ShouldAllowPluginCreation(
return true; return true;
} }
#endif // BUILDFLAG(ENABLE_PLUGINS) #endif // BUILDFLAG(ENABLE_PLUGINS)
#if BUILDFLAG(ENABLE_VR)
content::XrIntegrationClient*
ChromeContentBrowserClient::GetXrIntegrationClient() {
if (!xr_integration_client_)
xr_integration_client_ = std::make_unique<vr::ChromeXrIntegrationClient>(
util::PassKey<ChromeContentBrowserClient>());
return xr_integration_client_.get();
}
#endif // BUILDFLAG(ENABLE_VR)
...@@ -85,6 +85,12 @@ class ChromeBluetoothDelegate; ...@@ -85,6 +85,12 @@ class ChromeBluetoothDelegate;
class ChromeHidDelegate; class ChromeHidDelegate;
class ChromeSerialDelegate; class ChromeSerialDelegate;
#if BUILDFLAG(ENABLE_VR)
namespace vr {
class ChromeXrIntegrationClient;
}
#endif
// Returns the user agent of Chrome. // Returns the user agent of Chrome.
std::string GetUserAgent(); std::string GetUserAgent();
...@@ -656,6 +662,10 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient { ...@@ -656,6 +662,10 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient {
const content::PepperPluginInfo& plugin_info) override; const content::PepperPluginInfo& plugin_info) override;
#endif #endif
#if BUILDFLAG(ENABLE_VR)
content::XrIntegrationClient* GetXrIntegrationClient() override;
#endif
protected: protected:
static bool HandleWebUI(GURL* url, content::BrowserContext* browser_context); static bool HandleWebUI(GURL* url, content::BrowserContext* browser_context);
static bool HandleWebUIReverse(GURL* url, static bool HandleWebUIReverse(GURL* url,
...@@ -722,6 +732,10 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient { ...@@ -722,6 +732,10 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient {
#endif #endif
std::unique_ptr<ChromeBluetoothDelegate> bluetooth_delegate_; std::unique_ptr<ChromeBluetoothDelegate> bluetooth_delegate_;
#if BUILDFLAG(ENABLE_VR)
std::unique_ptr<vr::ChromeXrIntegrationClient> xr_integration_client_;
#endif
// Returned from GetNetworkContextsParentDirectory() but created on the UI // Returned from GetNetworkContextsParentDirectory() but created on the UI
// thread because it needs to access the Local State prefs. // thread because it needs to access the Local State prefs.
std::vector<base::FilePath> network_contexts_parent_directory_; std::vector<base::FilePath> network_contexts_parent_directory_;
......
...@@ -11,10 +11,13 @@ ...@@ -11,10 +11,13 @@
#include "base/bind_helpers.h" #include "base/bind_helpers.h"
#include "base/numerics/ranges.h" #include "base/numerics/ranges.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/browser/vr/service/chrome_xr_integration_client.h"
#include "chrome/browser/vr/service/vr_service_impl.h" #include "chrome/browser/vr/service/vr_service_impl.h"
#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/browser/xr_install_helper.h"
#include "content/public/browser/xr_integration_client.h"
#include "content/public/common/content_features.h" #include "content/public/common/content_features.h"
#include "device/vr/buildflags/buildflags.h" #include "device/vr/buildflags/buildflags.h"
#include "device/vr/public/cpp/session_mode.h" #include "device/vr/public/cpp/session_mode.h"
...@@ -26,10 +29,8 @@ ...@@ -26,10 +29,8 @@
#include "chrome/browser/vr/service/xr_session_request_consent_manager.h" #include "chrome/browser/vr/service/xr_session_request_consent_manager.h"
#elif defined(OS_ANDROID) #elif defined(OS_ANDROID)
#include "chrome/browser/android/vr/gvr_consent_helper.h" #include "chrome/browser/android/vr/gvr_consent_helper.h"
#include "chrome/browser/android/vr/gvr_install_helper.h"
#if BUILDFLAG(ENABLE_ARCORE) #if BUILDFLAG(ENABLE_ARCORE)
#include "chrome/browser/android/vr/arcore_device/arcore_consent_prompt.h" #include "chrome/browser/android/vr/arcore_device/arcore_consent_prompt.h"
#include "chrome/browser/android/vr/arcore_device/arcore_install_helper.h"
#endif #endif
#endif #endif
...@@ -250,15 +251,20 @@ BrowserXRRuntime::BrowserXRRuntime( ...@@ -250,15 +251,20 @@ BrowserXRRuntime::BrowserXRRuntime(
base::BindOnce(&BrowserXRRuntime::OnDisplayInfoChanged, base::BindOnce(&BrowserXRRuntime::OnDisplayInfoChanged,
base::Unretained(this))); base::Unretained(this)));
// TODO(crbug.com/1031622): Convert this to a query for the client off of
// ContentBrowserClient once BrowserXrRuntime moves to content.
auto* integration_client = ChromeXrIntegrationClient::GetInstance();
if (integration_client)
install_helper_ = integration_client->GetInstallHelper(id_);
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
if (id_ == device::mojom::XRDeviceId::GVR_DEVICE_ID) { if (id_ == device::mojom::XRDeviceId::GVR_DEVICE_ID) {
consent_helper_ = std::make_unique<GvrConsentHelper>(); consent_helper_ = std::make_unique<GvrConsentHelper>();
install_helper_ = std::make_unique<GvrInstallHelper>();
} }
#if BUILDFLAG(ENABLE_ARCORE) #if BUILDFLAG(ENABLE_ARCORE)
if (id_ == device::mojom::XRDeviceId::ARCORE_DEVICE_ID) { if (id_ == device::mojom::XRDeviceId::ARCORE_DEVICE_ID) {
consent_helper_ = std::make_unique<ArCoreConsentPrompt>(); consent_helper_ = std::make_unique<ArCoreConsentPrompt>();
install_helper_ = std::make_unique<ArCoreInstallHelper>();
} }
#endif #endif
#endif #endif
...@@ -551,7 +557,7 @@ void BrowserXRRuntime::ShowConsentPrompt( ...@@ -551,7 +557,7 @@ void BrowserXRRuntime::ShowConsentPrompt(
void BrowserXRRuntime::EnsureInstalled( void BrowserXRRuntime::EnsureInstalled(
int render_process_id, int render_process_id,
int render_frame_id, int render_frame_id,
OnInstallFinishedCallback install_callback) { base::OnceCallback<void(bool)> install_callback) {
// If there's no install helper, then we can assume no install is needed. // If there's no install helper, then we can assume no install is needed.
if (!install_helper_) { if (!install_helper_) {
std::move(install_callback).Run(true); std::move(install_callback).Run(true);
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "base/observer_list_types.h" #include "base/observer_list_types.h"
#include "chrome/browser/vr/service/vr_service_impl.h" #include "chrome/browser/vr/service/vr_service_impl.h"
#include "chrome/browser/vr/service/xr_consent_helper.h" #include "chrome/browser/vr/service/xr_consent_helper.h"
#include "chrome/browser/vr/service/xr_install_helper.h"
#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_frame_host.h"
#include "device/vr/public/mojom/isolated_xr_service.mojom.h" #include "device/vr/public/mojom/isolated_xr_service.mojom.h"
#include "device/vr/public/mojom/vr_service.mojom.h" #include "device/vr/public/mojom/vr_service.mojom.h"
...@@ -23,6 +22,7 @@ ...@@ -23,6 +22,7 @@
namespace content { namespace content {
class WebContents; class WebContents;
class XrInstallHelper;
} }
namespace vr { namespace vr {
...@@ -84,7 +84,7 @@ class BrowserXRRuntime : public device::mojom::XRRuntimeEventListener { ...@@ -84,7 +84,7 @@ class BrowserXRRuntime : public device::mojom::XRRuntimeEventListener {
OnUserConsentCallback consent_callback); OnUserConsentCallback consent_callback);
void EnsureInstalled(int render_process_id, void EnsureInstalled(int render_process_id,
int render_frame_id, int render_frame_id,
OnInstallFinishedCallback install_callback); base::OnceCallback<void(bool)> install_callback);
VRServiceImpl* GetServiceWithActiveImmersiveSession() { VRServiceImpl* GetServiceWithActiveImmersiveSession() {
return presenting_service_; return presenting_service_;
} }
...@@ -141,8 +141,8 @@ class BrowserXRRuntime : public device::mojom::XRRuntimeEventListener { ...@@ -141,8 +141,8 @@ class BrowserXRRuntime : public device::mojom::XRRuntimeEventListener {
base::ObserverList<BrowserXRRuntimeObserver> observers_; base::ObserverList<BrowserXRRuntimeObserver> observers_;
std::unique_ptr<XrConsentHelper> consent_helper_; std::unique_ptr<XrConsentHelper> consent_helper_;
std::unique_ptr<XrInstallHelper> install_helper_; std::unique_ptr<content::XrInstallHelper> install_helper_;
OnInstallFinishedCallback install_finished_callback_; base::OnceCallback<void(bool)> install_finished_callback_;
base::WeakPtrFactory<BrowserXRRuntime> weak_ptr_factory_{this}; base::WeakPtrFactory<BrowserXRRuntime> weak_ptr_factory_{this};
}; };
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/vr/service/chrome_xr_integration_client.h"
#include "build/build_config.h"
#include "content/public/browser/xr_install_helper.h"
#include "device/vr/buildflags/buildflags.h"
#include "device/vr/public/mojom/vr_service.mojom-shared.h"
#if defined(OS_ANDROID)
#include "chrome/browser/android/vr/gvr_install_helper.h"
#if BUILDFLAG(ENABLE_ARCORE)
#include "chrome/browser/android/vr/arcore_device/arcore_install_helper.h"
#endif
#endif
namespace {
vr::ChromeXrIntegrationClient* g_instance = nullptr;
}
namespace vr {
ChromeXrIntegrationClient* ChromeXrIntegrationClient::GetInstance() {
if (!g_instance)
g_instance = new ChromeXrIntegrationClient();
return g_instance;
}
std::unique_ptr<content::XrInstallHelper>
ChromeXrIntegrationClient::GetInstallHelper(
device::mojom::XRDeviceId device_id) {
switch (device_id) {
#if defined(OS_ANDROID)
case device::mojom::XRDeviceId::GVR_DEVICE_ID:
return std::make_unique<GvrInstallHelper>();
#if BUILDFLAG(ENABLE_ARCORE)
case device::mojom::XRDeviceId::ARCORE_DEVICE_ID:
return std::make_unique<ArCoreInstallHelper>();
#endif // ENABLE_ARCORE
#endif // OS_ANDROID
default:
return nullptr;
}
}
} // namespace vr
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_VR_SERVICE_CHROME_XR_INTEGRATION_CLIENT_H_
#define CHROME_BROWSER_VR_SERVICE_CHROME_XR_INTEGRATION_CLIENT_H_
#include <memory>
#include "base/util/type_safety/pass_key.h"
#include "content/public/browser/xr_integration_client.h"
#include "device/vr/public/mojom/vr_service.mojom-forward.h"
class ChromeContentBrowserClient;
namespace vr {
class ChromeXrIntegrationClient : public content::XrIntegrationClient {
public:
explicit ChromeXrIntegrationClient(
util::PassKey<ChromeContentBrowserClient>) {}
~ChromeXrIntegrationClient() override = default;
ChromeXrIntegrationClient(const ChromeXrIntegrationClient&) = delete;
ChromeXrIntegrationClient& operator=(const ChromeXrIntegrationClient&) =
delete;
// XrIntegrationClient
std::unique_ptr<content::XrInstallHelper> GetInstallHelper(
device::mojom::XRDeviceId device_id) override;
// TODO(1031622): Once all consumers have been moved to content/, this should
// be removed, and those consumers should be updated to get this instance from
// the ContentBrowserClient.
// Nothing in this class should rely on this singleton behavior.
// This is simply created as a "Singleton" here to ensure that callers don't
// just create an instance of this and cache the value.
static ChromeXrIntegrationClient* GetInstance();
private:
ChromeXrIntegrationClient() = default;
};
} // namespace vr
#endif // CHROME_BROWSER_VR_SERVICE_CHROME_XR_INTEGRATION_CLIENT_H_
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_VR_SERVICE_XR_INSTALL_HELPER_H_
#define CHROME_BROWSER_VR_SERVICE_XR_INSTALL_HELPER_H_
#include "base/callback_forward.h"
namespace vr {
typedef base::OnceCallback<void(bool)> OnInstallFinishedCallback;
class XrInstallHelper {
public:
virtual ~XrInstallHelper() = default;
virtual void EnsureInstalled(int render_process_id,
int render_frame_id,
OnInstallFinishedCallback install_callback) = 0;
protected:
XrInstallHelper() = default;
private:
XrInstallHelper(const XrInstallHelper&) = delete;
XrInstallHelper& operator=(const XrInstallHelper&) = delete;
};
} // namespace vr
#endif // CHROME_BROWSER_VR_SERVICE_XR_INSTALL_HELPER_H_
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import("//build/config/jumbo.gni") import("//build/config/jumbo.gni")
import("//build/config/ui.gni") import("//build/config/ui.gni")
import("//device/vr/buildflags/buildflags.gni")
import("//ppapi/buildflags/buildflags.gni") import("//ppapi/buildflags/buildflags.gni")
import("//third_party/webrtc/webrtc.gni") import("//third_party/webrtc/webrtc.gni")
...@@ -418,6 +419,7 @@ jumbo_source_set("browser_sources") { ...@@ -418,6 +419,7 @@ jumbo_source_set("browser_sources") {
"//components/download/public/common:public", "//components/download/public/common:public",
"//components/services/storage/public/mojom", "//components/services/storage/public/mojom",
"//content/public/common:common_sources", "//content/public/common:common_sources",
"//device/vr/buildflags",
"//ipc", "//ipc",
"//media/mojo/mojom", "//media/mojo/mojom",
"//media/mojo/mojom:remoting", "//media/mojo/mojom:remoting",
...@@ -505,6 +507,16 @@ jumbo_source_set("browser_sources") { ...@@ -505,6 +507,16 @@ jumbo_source_set("browser_sources") {
sources += sources +=
[ "chromeos/delegate_to_browser_gpu_service_accelerator_factory.h" ] [ "chromeos/delegate_to_browser_gpu_service_accelerator_factory.h" ]
} }
if (enable_vr) {
sources += [
"xr_install_helper.h",
"xr_integration_client.cc",
"xr_integration_client.h",
]
public_deps += [ "//device/vr/public/mojom" ]
}
} }
if (is_android) { if (is_android) {
......
...@@ -6,6 +6,8 @@ include_rules = [ ...@@ -6,6 +6,8 @@ include_rules = [
"+components/viz/common", "+components/viz/common",
"+components/viz/host", "+components/viz/host",
"+device/fido", "+device/fido",
"+device/vr/buildflags",
"+device/vr/public/mojom",
"+services/audio/public", "+services/audio/public",
"+services/content/public", "+services/content/public",
"+services/data_decoder/public", "+services/data_decoder/public",
......
...@@ -1060,4 +1060,10 @@ bool ContentBrowserClient::ShouldAllowPluginCreation( ...@@ -1060,4 +1060,10 @@ bool ContentBrowserClient::ShouldAllowPluginCreation(
} }
#endif #endif
#if BUILDFLAG(ENABLE_VR)
XrIntegrationClient* ContentBrowserClient::GetXrIntegrationClient() {
return nullptr;
}
#endif
} // namespace content } // namespace content
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "content/public/common/page_visibility_state.h" #include "content/public/common/page_visibility_state.h"
#include "content/public/common/previews_state.h" #include "content/public/common/previews_state.h"
#include "content/public/common/window_container_type.mojom-forward.h" #include "content/public/common/window_container_type.mojom-forward.h"
#include "device/vr/buildflags/buildflags.h"
#include "media/base/video_codecs.h" #include "media/base/video_codecs.h"
#include "media/cdm/cdm_proxy.h" #include "media/cdm/cdm_proxy.h"
#include "media/mojo/mojom/media_service.mojom-forward.h" #include "media/mojo/mojom/media_service.mojom-forward.h"
...@@ -204,6 +205,7 @@ class URLLoaderRequestInterceptor; ...@@ -204,6 +205,7 @@ class URLLoaderRequestInterceptor;
class VpnServiceProxy; class VpnServiceProxy;
class WebContents; class WebContents;
class WebContentsViewDelegate; class WebContentsViewDelegate;
class XrIntegrationClient;
struct GlobalFrameRoutingId; struct GlobalFrameRoutingId;
struct GlobalRequestID; struct GlobalRequestID;
struct MainFunctionParams; struct MainFunctionParams;
...@@ -1804,6 +1806,12 @@ class CONTENT_EXPORT ContentBrowserClient { ...@@ -1804,6 +1806,12 @@ class CONTENT_EXPORT ContentBrowserClient {
virtual bool ShouldAllowPluginCreation(const url::Origin& embedder_origin, virtual bool ShouldAllowPluginCreation(const url::Origin& embedder_origin,
const PepperPluginInfo& plugin_info); const PepperPluginInfo& plugin_info);
#endif #endif
#if BUILDFLAG(ENABLE_VR)
// Allows the embedder to provide mechanisms to integrate with WebXR
// functionality.
virtual XrIntegrationClient* GetXrIntegrationClient();
#endif
}; };
} // namespace content } // namespace content
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_PUBLIC_BROWSER_XR_INSTALL_HELPER_H_
#define CONTENT_PUBLIC_BROWSER_XR_INSTALL_HELPER_H_
#include "base/callback_forward.h"
#include "content/common/content_export.h"
namespace content {
// Interface class to provide the opportunity for runtimes to ensure that any
// necessary installation steps that need to occur from within the browser
// process are kicked off. This is acquired via the |XrInstallHelperFactory|.
// Generally, these steps are specific per runtime, so likely this should be
// implemented for each runtime that has browser-specific installation steps.
// This should be implemented by embedders.
class CONTENT_EXPORT XrInstallHelper {
public:
virtual ~XrInstallHelper() = default;
XrInstallHelper(const XrInstallHelper&) = delete;
XrInstallHelper& operator=(const XrInstallHelper&) = delete;
// Triggers checks and appropriate installation requests for any runtime
// dependencies that need to be installed from the browser process.
// render_process_id and render_frame_id are passed in case any tab specific
// UI needs to be shown.
// The callback should be guaranteed to run in the event that that the object
// is destroyed, and should return whether or not the runtime was able to be
// successfully installed (or verified to already be installed).
virtual void EnsureInstalled(
int render_process_id,
int render_frame_id,
base::OnceCallback<void(bool installed)> install_callback) = 0;
protected:
XrInstallHelper() = default;
};
} // namespace content
#endif // CONTENT_PUBLIC_BROWSER_XR_INSTALL_HELPER_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/public/browser/xr_integration_client.h"
#include "content/public/browser/xr_install_helper.h"
#include "device/vr/public/mojom/vr_service.mojom-shared.h"
namespace content {
std::unique_ptr<content::XrInstallHelper> XrIntegrationClient::GetInstallHelper(
device::mojom::XRDeviceId device_id) {
return nullptr;
}
} // namespace content
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_PUBLIC_BROWSER_XR_INTEGRATION_CLIENT_H_
#define CONTENT_PUBLIC_BROWSER_XR_INTEGRATION_CLIENT_H_
#include <memory>
#include "content/common/content_export.h"
#include "device/vr/public/mojom/vr_service.mojom-forward.h"
namespace content {
class XrInstallHelper;
// A helper class for |ContentBrowserClient| to wrap for XR-specific
// integration that may be needed from content/. Currently it only provides
// access to relevant XrInstallHelpers, but will eventually be expanded to
// include integration points for VrUiHost.
// This should be implemented by embedders.
class CONTENT_EXPORT XrIntegrationClient {
public:
XrIntegrationClient() = default;
virtual ~XrIntegrationClient() = default;
XrIntegrationClient(const XrIntegrationClient&) = delete;
XrIntegrationClient& operator=(const XrIntegrationClient&) = delete;
// Returns the |XrInstallHelper| for the corresponding |XRDeviceId|, or
// nullptr if the requested |XRDeviceId| does not have any required extra
// installation steps.
virtual std::unique_ptr<XrInstallHelper> GetInstallHelper(
device::mojom::XRDeviceId device_id);
};
} // namespace content
#endif // CONTENT_PUBLIC_BROWSER_XR_INTEGRATION_CLIENT_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment