1 // Copyright 2020 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef CONTENT_PUBLIC_BROWSER_XR_INTEGRATION_CLIENT_H_
6 #define CONTENT_PUBLIC_BROWSER_XR_INTEGRATION_CLIENT_H_
7 
8 #include <memory>
9 
10 #include "build/build_config.h"
11 #include "content/common/content_export.h"
12 #include "device/vr/public/mojom/vr_service.mojom-forward.h"
13 
14 #if !defined(OS_ANDROID)
15 #include "device/vr/public/mojom/isolated_xr_service.mojom-forward.h"
16 #include "mojo/public/cpp/bindings/pending_remote.h"
17 #endif
18 
19 namespace content {
20 class XrConsentHelper;
21 class XrInstallHelper;
22 
23 #if !defined(OS_ANDROID)
24 // This class is intended to provide implementers a means of accessing the
25 // the XRCompositorHost returned from a create session call. Content has no
26 // obligation to notify it of any events (other than any observers that
27 // implementers subscribe to independently). Any VrUiHost created this way is
28 // guaranteed to be kept alive until the device that it was created for has been
29 // removed. Note that currently this is only supported on Windows.
30 class CONTENT_EXPORT VrUiHost {
31  public:
32   virtual ~VrUiHost() = default;
33 };
34 #endif
35 
36 // A helper class for |ContentBrowserClient| to wrap for XR-specific
37 // integration that may be needed from content/. Currently it only provides
38 // access to relevant XrInstallHelpers, but will eventually be expanded to
39 // include integration points for VrUiHost.
40 // This should be implemented by embedders.
41 class CONTENT_EXPORT XrIntegrationClient {
42  public:
43   XrIntegrationClient() = default;
44   virtual ~XrIntegrationClient() = default;
45   XrIntegrationClient(const XrIntegrationClient&) = delete;
46   XrIntegrationClient& operator=(const XrIntegrationClient&) = delete;
47 
48   // Returns the |XrInstallHelper| for the corresponding |XRDeviceId|, or
49   // nullptr if the requested |XRDeviceId| does not have any required extra
50   // installation steps.
51   virtual std::unique_ptr<XrInstallHelper> GetInstallHelper(
52       device::mojom::XRDeviceId device_id);
53 
54   // Returns the |XrConsentHelper| for the corresponding |XRDeviceId|, or
55   // nullptr if the requested |XRDeviceId| cannot prompt for consent.
56   // In this case, consent is assumed to have been denied.
57   virtual std::unique_ptr<XrConsentHelper> GetConsentHelper(
58       device::mojom::XRDeviceId device_id);
59 
60 #if !defined(OS_ANDROID)
61   // Creates a VrUiHost object for the specified device_id, and takes ownership
62   // of any XRCompositor supplied from the runtime.
63   virtual std::unique_ptr<VrUiHost> CreateVrUiHost(
64       device::mojom::XRDeviceId device_id,
65       mojo::PendingRemote<device::mojom::XRCompositorHost> compositor);
66 #endif
67 };
68 
69 }  // namespace content
70 
71 #endif  // CONTENT_PUBLIC_BROWSER_XR_INTEGRATION_CLIENT_H_
72