Skip to content

Commit

Permalink
Move VR Runtime features to device/base/features.h
Browse files Browse the repository at this point in the history
As part of the refactor to move the VRService into content, the isolated
device service will need to move from chrome/services to
components/services and from chrome/utility/services to
content/utility/services. At that time, XRRuntimeProvider will no longer
be able to use anything from either chrome_features or content_features.
While it is a pattern for components to define their own features, these
features indicate the support of an implemented runtime, and thus make
more sense being implemented at this layer.

Bug: 1031622
Change-Id: I7649bf5c20a2973ca4eaa818fa05a76a7f8432d7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2108964
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Reviewed-by: Ken Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/master@{#751864}
  • Loading branch information
alcooper91 authored and Commit Bot committed Mar 20, 2020
1 parent 4e14124 commit 6a49497
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 63 deletions.
1 change: 1 addition & 0 deletions chrome/browser/vr/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ component("vr_ui") {
"//components/omnibox/browser:vector_icons",
"//components/url_formatter",
"//components/vector_icons",
"//device/base",
"//device/vr/buildflags:buildflags",
"//media",
"//net",
Expand Down
16 changes: 8 additions & 8 deletions chrome/browser/vr/test/webxr_vr_browser_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ void WebXrVrBrowserTestBase::SetupFakeConsentManager(

WebXrVrRuntimelessBrowserTest::WebXrVrRuntimelessBrowserTest() {
#if BUILDFLAG(ENABLE_WINDOWS_MR)
disable_features_.push_back(features::kWindowsMixedReality);
disable_features_.push_back(device::features::kWindowsMixedReality);
#endif
#if BUILDFLAG(ENABLE_OPENXR)
disable_features_.push_back(features::kOpenXR);
disable_features_.push_back(device::features::kOpenXR);
#endif
}

Expand All @@ -149,12 +149,12 @@ WebXrVrRuntimelessBrowserTestSensorless::
#if defined(OS_WIN)

WebXrVrOpenVrBrowserTestBase::WebXrVrOpenVrBrowserTestBase() {
enable_features_.push_back(features::kOpenVR);
enable_features_.push_back(device::features::kOpenVR);
#if BUILDFLAG(ENABLE_WINDOWS_MR)
disable_features_.push_back(features::kWindowsMixedReality);
disable_features_.push_back(device::features::kWindowsMixedReality);
#endif
#if BUILDFLAG(ENABLE_OPENXR)
disable_features_.push_back(features::kOpenXR);
disable_features_.push_back(device::features::kOpenXR);
#endif
}

Expand All @@ -172,7 +172,7 @@ gfx::Vector3dF WebXrVrOpenVrBrowserTestBase::GetControllerOffset() const {

WebXrVrWmrBrowserTestBase::WebXrVrWmrBrowserTestBase() {
#if BUILDFLAG(ENABLE_OPENXR)
disable_features_.push_back(features::kOpenXR);
disable_features_.push_back(device::features::kOpenXR);
#endif
}

Expand All @@ -191,9 +191,9 @@ XrBrowserTestBase::RuntimeType WebXrVrWmrBrowserTestBase::GetRuntimeType()
#if BUILDFLAG(ENABLE_OPENXR)

WebXrVrOpenXrBrowserTestBase::WebXrVrOpenXrBrowserTestBase() {
enable_features_.push_back(features::kOpenXR);
enable_features_.push_back(device::features::kOpenXR);
#if BUILDFLAG(ENABLE_WINDOWS_MR)
disable_features_.push_back(features::kWindowsMixedReality);
disable_features_.push_back(device::features::kWindowsMixedReality);
#endif
}

Expand Down
1 change: 0 additions & 1 deletion chrome/browser/vr/test/webxr_vr_browser_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "chrome/browser/vr/test/mock_xr_device_hook_base.h"
#include "chrome/browser/vr/test/webxr_browser_test.h"
#include "chrome/browser/vr/test/xr_browser_test.h"
#include "chrome/common/chrome_features.h"
#include "components/permissions/permission_request_manager.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_features.h"
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/vr/test/xr_browser_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
#include "build/build_config.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/vr/test/conditional_skipping.h"
#include "chrome/common/chrome_features.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
#include "device/base/features.h"
#include "device/vr/test/test_hook.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "url/gurl.h"
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/vr/ui_host/vr_ui_host_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
#include "chrome/browser/vr/service/xr_runtime_manager.h"
#include "chrome/browser/vr/vr_tab_helper.h"
#include "chrome/browser/vr/win/vr_browser_renderer_thread_win.h"
#include "chrome/common/chrome_features.h"
#include "components/permissions/permission_manager.h"
#include "components/permissions/permission_result.h"
#include "content/public/browser/device_service.h"
#include "content/public/browser/navigation_entry.h"
#include "device/base/features.h"
#include "device/vr/buildflags/buildflags.h"
#include "ui/base/l10n/l10n_util.h"

Expand All @@ -34,7 +34,7 @@ static constexpr base::TimeDelta kPermissionPromptTimeout =

base::TimeDelta GetPermissionPromptTimeout(bool first_time) {
#if BUILDFLAG(ENABLE_WINDOWS_MR)
if (base::FeatureList::IsEnabled(features::kWindowsMixedReality) &&
if (base::FeatureList::IsEnabled(device::features::kWindowsMixedReality) &&
first_time)
return base::TimeDelta::FromSeconds(10);
#endif
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/vr/ui_scene_creator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@
#include "chrome/browser/vr/ui_scene.h"
#include "chrome/browser/vr/ui_scene_constants.h"
#include "chrome/browser/vr/vector_icons/vector_icons.h"
#include "chrome/common/chrome_features.h"
#include "chrome/grit/generated_resources.h"
#include "components/omnibox/browser/vector_icons.h"
#include "components/strings/grit/components_strings.h"
#include "components/url_formatter/elide_url.h"
#include "components/vector_icons/vector_icons.h"
#include "device/base/features.h"
#include "device/vr/buildflags/buildflags.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/paint_vector_icon.h"
Expand Down Expand Up @@ -1097,7 +1097,7 @@ void BindIndicatorTranscience(

int GetIndicatorsTimeout() {
#if BUILDFLAG(ENABLE_WINDOWS_MR)
if (base::FeatureList::IsEnabled(features::kWindowsMixedReality))
if (base::FeatureList::IsEnabled(device::features::kWindowsMixedReality))
return kWmrInitialIndicatorsTimeoutSeconds;
#endif
return kToastTimeoutSeconds;
Expand Down
25 changes: 0 additions & 25 deletions chrome/common/chrome_features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -344,31 +344,6 @@ const base::Feature kExternalExtensionDefaultButtonControl{
// Enables Focus Mode which brings up a PWA-like window look.
const base::Feature kFocusMode{"FocusMode", base::FEATURE_DISABLED_BY_DEFAULT};

#if BUILDFLAG(ENABLE_VR)

#if BUILDFLAG(ENABLE_OCULUS_VR)
// Controls Oculus support.
const base::Feature kOculusVR{"OculusVR", base::FEATURE_DISABLED_BY_DEFAULT};
#endif // ENABLE_OCULUS_VR

#if BUILDFLAG(ENABLE_OPENVR)
// Controls OpenVR support.
const base::Feature kOpenVR{"OpenVR", base::FEATURE_DISABLED_BY_DEFAULT};
#endif // ENABLE_OPENVR

#if BUILDFLAG(ENABLE_WINDOWS_MR)
// Controls Windows Mixed Reality support.
const base::Feature kWindowsMixedReality{"WindowsMixedReality",
base::FEATURE_ENABLED_BY_DEFAULT};
#endif // ENABLE_WINDOWS_MR

#if BUILDFLAG(ENABLE_OPENXR)
// Controls OpenXR support.
const base::Feature kOpenXR{"OpenXR", base::FEATURE_ENABLED_BY_DEFAULT};
#endif // ENABLE_OPENXR

#endif // BUILDFLAG(ENABLE_VR)

#if defined(OS_WIN)
// Enables using GDI to print text as simply text.
const base::Feature kGdiTextPrinting{"GdiTextPrinting",
Expand Down
18 changes: 0 additions & 18 deletions chrome/common/chrome_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,24 +213,6 @@ COMPONENT_EXPORT(CHROME_FEATURES)
extern const base::Feature kVrBrowsingExperimentalFeatures;
COMPONENT_EXPORT(CHROME_FEATURES)
extern const base::Feature kVrBrowsingExperimentalRendering;

#if BUILDFLAG(ENABLE_OCULUS_VR)
COMPONENT_EXPORT(CHROME_FEATURES) extern const base::Feature kOculusVR;
#endif // ENABLE_OCULUS_VR

#if BUILDFLAG(ENABLE_OPENVR)
COMPONENT_EXPORT(CHROME_FEATURES) extern const base::Feature kOpenVR;
#endif // ENABLE_OPENVR

#if BUILDFLAG(ENABLE_WINDOWS_MR)
COMPONENT_EXPORT(CHROME_FEATURES)
extern const base::Feature kWindowsMixedReality;
#endif // ENABLE_WINDOWS_MR

#if BUILDFLAG(ENABLE_OPENXR)
COMPONENT_EXPORT(CHROME_FEATURES) extern const base::Feature kOpenXR;
#endif // ENABLE_OPENXR

#endif // ENABLE_VR

#if defined(OS_WIN)
Expand Down
2 changes: 1 addition & 1 deletion chrome/services/isolated_xr_device/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ source_set("lib") {

deps = [
"//base",
"//chrome/common",
"//device/base",
"//device/vr:vr",
"//device/vr/public/mojom",
"//device/vr/public/mojom:test_mojom",
Expand Down
1 change: 1 addition & 0 deletions chrome/services/isolated_xr_device/DEPS
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include_rules = [
"+device/base",
"+device/vr",
"+mojo/public",
]
10 changes: 5 additions & 5 deletions chrome/services/isolated_xr_device/xr_runtime_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/trace_event/trace_event.h"
#include "chrome/common/chrome_features.h"
#include "content/public/common/content_switches.h"
#include "device/base/features.h"
#include "device/vr/buildflags/buildflags.h"
#include "device/vr/vr_device_base.h"

Expand Down Expand Up @@ -156,23 +156,23 @@ void IsolatedXRRuntimeProvider::SetupPollingForDeviceChanges() {
ALLOW_UNUSED_LOCAL(command_line);

#if BUILDFLAG(ENABLE_OCULUS_VR)
if (IsEnabled(command_line, features::kOculusVR,
if (IsEnabled(command_line, device::features::kOculusVR,
switches::kWebXrRuntimeOculus)) {
should_check_oculus_ = device::OculusDevice::IsApiAvailable();
any_runtimes_available |= should_check_oculus_;
}
#endif

#if BUILDFLAG(ENABLE_OPENVR)
if (IsEnabled(command_line, features::kOpenVR,
if (IsEnabled(command_line, device::features::kOpenVR,
switches::kWebXrRuntimeOpenVr)) {
should_check_openvr_ = device::OpenVRDevice::IsApiAvailable();
any_runtimes_available |= should_check_openvr_;
}
#endif

#if BUILDFLAG(ENABLE_WINDOWS_MR)
if (IsEnabled(command_line, features::kWindowsMixedReality,
if (IsEnabled(command_line, device::features::kWindowsMixedReality,
switches::kWebXrRuntimeWMR)) {
wmr_statics_ = device::MixedRealityDeviceStatics::CreateInstance();
should_check_wmr_ = wmr_statics_->IsApiAvailable();
Expand All @@ -181,7 +181,7 @@ void IsolatedXRRuntimeProvider::SetupPollingForDeviceChanges() {
#endif

#if BUILDFLAG(ENABLE_OPENXR)
if (IsEnabled(command_line, features::kOpenXR,
if (IsEnabled(command_line, device::features::kOpenXR,
switches::kWebXrRuntimeOpenXr)) {
openxr_statics_ = std::make_unique<device::OpenXrStatics>();
should_check_openxr_ = openxr_statics_->IsApiAvailable();
Expand Down
21 changes: 21 additions & 0 deletions device/base/features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,26 @@ const base::Feature kWebXrOrientationSensorDevice {
#endif
};
#endif // BUILDFLAG(ENABLE_VR)
namespace features {
#if BUILDFLAG(ENABLE_OCULUS_VR)
// Controls WebXR support for the Oculus Runtime.
const base::Feature kOculusVR{"OculusVR", base::FEATURE_DISABLED_BY_DEFAULT};
#endif // ENABLE_OCULUS_VR

#if BUILDFLAG(ENABLE_OPENVR)
// Controls WebXR support for the OpenVR Runtime.
const base::Feature kOpenVR{"OpenVR", base::FEATURE_DISABLED_BY_DEFAULT};
#endif // ENABLE_OPENVR

#if BUILDFLAG(ENABLE_OPENXR)
// Controls WebXR support for the OpenXR Runtime.
const base::Feature kOpenXR{"OpenXR", base::FEATURE_ENABLED_BY_DEFAULT};
#endif // ENABLE_OPENXR

#if BUILDFLAG(ENABLE_WINDOWS_MR)
// Controls WebXR support for the Windows Mixed Reality Runtime.
const base::Feature kWindowsMixedReality{"WindowsMixedReality",
base::FEATURE_ENABLED_BY_DEFAULT};
#endif // ENABLE_WINDOWS_MR
} // namespace features
} // namespace device
16 changes: 16 additions & 0 deletions device/base/features.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,22 @@ DEVICE_BASE_EXPORT extern const base::Feature kNewBLEWinImplementation;
DEVICE_BASE_EXPORT extern const base::Feature kWebXrOrientationSensorDevice;
#endif // BUILDFLAG(ENABLE_VR)

// New features should be added to the device::features namespace.

namespace features {
#if BUILDFLAG(ENABLE_OCULUS_VR)
DEVICE_BASE_EXPORT extern const base::Feature kOculusVR;
#endif // ENABLE_OCULUS_VR
#if BUILDFLAG(ENABLE_OPENVR)
DEVICE_BASE_EXPORT extern const base::Feature kOpenVR;
#endif // ENABLE_OPENVR
#if BUILDFLAG(ENABLE_OPENXR)
DEVICE_BASE_EXPORT extern const base::Feature kOpenXR;
#endif // ENABLE_OPENXR
#if BUILDFLAG(ENABLE_WINDOWS_MR)
DEVICE_BASE_EXPORT extern const base::Feature kWindowsMixedReality;
#endif // ENABLE_WINDOWS_MR
} // namespace features
} // namespace device

#endif // DEVICE_BASE_FEATURES_H_

0 comments on commit 6a49497

Please sign in to comment.