Commit 850e5fd2 authored by Alex Cooper's avatar Alex Cooper Committed by Commit Bot

Create SessionRequestData struct for VRService

The "RequestSession" flow for a typical VR Session requires bouncing
calls through a few asynchronous API's via callbacks. Currently there
are four pieces of data which get constantly passed through these
callbacks, as they needed at various stages of the request flow.

Unfortunately, since a second "RequestSession" request may come in
during this asynchronous work, this data cannot just be cached on the
VRService class.

This change cleans up some of the pattern to make this more readable by
creating a struct to hold this data, so that only one object needs to
be consistently forwarded around by the code.

Bug: 1045130
Change-Id: I4a64eaba2944ddfe4304a20e023acc0100c834f9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2024267
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Reviewed-by: default avatarKlaus Weidner <klausw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#736192}
parent 2b09b822
...@@ -99,6 +99,21 @@ ContentSettingsType GetRequiredPermission(device::mojom::XRSessionMode mode) { ...@@ -99,6 +99,21 @@ ContentSettingsType GetRequiredPermission(device::mojom::XRSessionMode mode) {
namespace vr { namespace vr {
VRServiceImpl::SessionRequestData::SessionRequestData(
device::mojom::XRSessionOptionsPtr options,
device::mojom::VRService::RequestSessionCallback callback,
std::set<device::mojom::XRSessionFeature> enabled_features,
device::mojom::XRDeviceId runtime_id)
: options(std::move(options)),
callback(std::move(callback)),
enabled_features(std::move(enabled_features)),
runtime_id(runtime_id) {}
VRServiceImpl::SessionRequestData::~SessionRequestData() = default;
VRServiceImpl::SessionRequestData::SessionRequestData(SessionRequestData&&) =
default;
VRServiceImpl::VRServiceImpl(content::RenderFrameHost* render_frame_host) VRServiceImpl::VRServiceImpl(content::RenderFrameHost* render_frame_host)
: WebContentsObserver( : WebContentsObserver(
content::WebContents::FromRenderFrameHost(render_frame_host)), content::WebContents::FromRenderFrameHost(render_frame_host)),
...@@ -236,16 +251,13 @@ bool VRServiceImpl::IsXrDeviceConsentPromptDisabledForTesting() { ...@@ -236,16 +251,13 @@ bool VRServiceImpl::IsXrDeviceConsentPromptDisabledForTesting() {
} }
void VRServiceImpl::OnInlineSessionCreated( void VRServiceImpl::OnInlineSessionCreated(
device::mojom::XRSessionOptionsPtr options, SessionRequestData request,
device::mojom::XRDeviceId session_runtime_id,
device::mojom::VRService::RequestSessionCallback callback,
const std::set<device::mojom::XRSessionFeature>& enabled_features,
device::mojom::XRSessionPtr session, device::mojom::XRSessionPtr session,
mojo::PendingRemote<device::mojom::XRSessionController> mojo::PendingRemote<device::mojom::XRSessionController>
pending_controller) { pending_controller) {
if (!session) { if (!session) {
std::move(callback).Run( std::move(request.callback)
device::mojom::RequestSessionResult::NewFailureReason( .Run(device::mojom::RequestSessionResult::NewFailureReason(
device::mojom::RequestSessionError::UNKNOWN_RUNTIME_ERROR)); device::mojom::RequestSessionError::UNKNOWN_RUNTIME_ERROR));
return; return;
} }
...@@ -257,26 +269,22 @@ void VRServiceImpl::OnInlineSessionCreated( ...@@ -257,26 +269,22 @@ void VRServiceImpl::OnInlineSessionCreated(
auto id = magic_window_controllers_.Add(std::move(controller)); auto id = magic_window_controllers_.Add(std::move(controller));
DVLOG(2) << __func__ << ": session_id=" << id.GetUnsafeValue() DVLOG(2) << __func__ << ": session_id=" << id.GetUnsafeValue()
<< " runtime_id=" << session_runtime_id; << " runtime_id=" << request.runtime_id;
// Note: We might be recording an inline session that was created by WebVR. // Note: We might be recording an inline session that was created by WebVR.
auto* session_metrics_tracker = auto* session_metrics_tracker =
GetSessionMetricsHelper()->RecordInlineSessionStart(id.GetUnsafeValue()); GetSessionMetricsHelper()->RecordInlineSessionStart(id.GetUnsafeValue());
OnSessionCreated(std::move(options), session_runtime_id, std::move(callback), OnSessionCreated(std::move(request), std::move(session),
enabled_features, std::move(session),
session_metrics_tracker); session_metrics_tracker);
} }
void VRServiceImpl::OnImmersiveSessionCreated( void VRServiceImpl::OnImmersiveSessionCreated(
device::mojom::XRSessionOptionsPtr options, SessionRequestData request,
device::mojom::XRDeviceId session_runtime_id,
device::mojom::VRService::RequestSessionCallback callback,
const std::set<device::mojom::XRSessionFeature>& enabled_features,
device::mojom::XRSessionPtr session) { device::mojom::XRSessionPtr session) {
if (!session) { if (!session) {
std::move(callback).Run( std::move(request.callback)
device::mojom::RequestSessionResult::NewFailureReason( .Run(device::mojom::RequestSessionResult::NewFailureReason(
device::mojom::RequestSessionError::UNKNOWN_RUNTIME_ERROR)); device::mojom::RequestSessionError::UNKNOWN_RUNTIME_ERROR));
return; return;
} }
...@@ -295,8 +303,7 @@ void VRServiceImpl::OnImmersiveSessionCreated( ...@@ -295,8 +303,7 @@ void VRServiceImpl::OnImmersiveSessionCreated(
GetSessionMetricsHelper()->RecordImmersiveSessionStart(); GetSessionMetricsHelper()->RecordImmersiveSessionStart();
} }
OnSessionCreated(std::move(options), session_runtime_id, std::move(callback), OnSessionCreated(std::move(request), std::move(session),
enabled_features, std::move(session),
session_metrics_tracker); session_metrics_tracker);
} }
...@@ -324,39 +331,37 @@ SessionMetricsHelper* VRServiceImpl::GetSessionMetricsHelper() { ...@@ -324,39 +331,37 @@ SessionMetricsHelper* VRServiceImpl::GetSessionMetricsHelper() {
} }
void VRServiceImpl::OnSessionCreated( void VRServiceImpl::OnSessionCreated(
device::mojom::XRSessionOptionsPtr options, SessionRequestData request,
device::mojom::XRDeviceId session_runtime_id,
device::mojom::VRService::RequestSessionCallback callback,
const std::set<device::mojom::XRSessionFeature>& enabled_features,
device::mojom::XRSessionPtr session, device::mojom::XRSessionPtr session,
WebXRSessionTracker* session_metrics_tracker) { WebXRSessionTracker* session_metrics_tracker) {
DVLOG(2) << __func__ << ": session_runtime_id=" << session_runtime_id; DVLOG(2) << __func__ << ": session_runtime_id=" << request.runtime_id;
// Not checking for validity of |session|, since that's done by // Not checking for validity of |session|, since that's done by
// |OnInlineSessionCreated| and |OnImmersiveSessionCreated|. // |OnInlineSessionCreated| and |OnImmersiveSessionCreated|.
UMA_HISTOGRAM_ENUMERATION("XR.RuntimeUsed", session_runtime_id); UMA_HISTOGRAM_ENUMERATION("XR.RuntimeUsed", request.runtime_id);
mojo::Remote<device::mojom::XRSessionClient> client; mojo::Remote<device::mojom::XRSessionClient> client;
session->client_receiver = client.BindNewPipeAndPassReceiver(); session->client_receiver = client.BindNewPipeAndPassReceiver();
session->enabled_features.clear(); session->enabled_features.clear();
for (const auto& feature : enabled_features) { for (const auto& feature : request.enabled_features) {
session->enabled_features.push_back(feature); session->enabled_features.push_back(feature);
} }
client->OnVisibilityStateChanged(visibility_state_); client->OnVisibilityStateChanged(visibility_state_);
session_clients_.Add(std::move(client)); session_clients_.Add(std::move(client));
session_metrics_tracker->RecordRequestedFeatures(*options, enabled_features); session_metrics_tracker->RecordRequestedFeatures(*(request.options),
request.enabled_features);
auto success = device::mojom::RequestSessionSuccess::New(); auto success = device::mojom::RequestSessionSuccess::New();
success->session = std::move(session); success->session = std::move(session);
success->metrics_recorder = success->metrics_recorder =
session_metrics_tracker->BindMetricsRecorderPipe(); session_metrics_tracker->BindMetricsRecorderPipe();
std::move(callback).Run( std::move(request.callback)
device::mojom::RequestSessionResult::NewSuccess(std::move(success))); .Run(device::mojom::RequestSessionResult::NewSuccess(std::move(success)));
} }
void VRServiceImpl::RequestSession( void VRServiceImpl::RequestSession(
...@@ -408,37 +413,36 @@ void VRServiceImpl::RequestSession( ...@@ -408,37 +413,36 @@ void VRServiceImpl::RequestSession(
} }
} }
ShowConsentPrompt(std::move(options), std::move(callback), runtime, SessionRequestData request(std::move(options), std::move(callback),
std::move(requested_features)); std::move(requested_features), runtime->GetId());
ShowConsentPrompt(std::move(request), runtime);
} }
void VRServiceImpl::ShowConsentPrompt( void VRServiceImpl::ShowConsentPrompt(SessionRequestData request,
device::mojom::XRSessionOptionsPtr options, BrowserXRRuntime* runtime) {
device::mojom::VRService::RequestSessionCallback callback,
BrowserXRRuntime* runtime,
std::set<device::mojom::XRSessionFeature> requested_features) {
DVLOG(2) << __func__; DVLOG(2) << __func__;
DCHECK(options); DCHECK(request.options);
DCHECK(runtime); DCHECK(runtime);
DCHECK_EQ(runtime->GetId(), request.runtime_id);
#if defined(OS_WIN) #if defined(OS_WIN)
DCHECK_NE(options->mode, device::mojom::XRSessionMode::kImmersiveAr); DCHECK_NE(request.options->mode, device::mojom::XRSessionMode::kImmersiveAr);
#endif #endif
bool consent_granted = false; bool consent_granted = false;
XrConsentPromptLevel consent_level = XrConsentPromptLevel consent_level = GetRequiredConsentLevel(
GetRequiredConsentLevel(options->mode, runtime, requested_features); request.options->mode, runtime, request.enabled_features);
if (!base::FeatureList::IsEnabled(features::kWebXrPermissionsApi)) { if (!base::FeatureList::IsEnabled(features::kWebXrPermissionsApi)) {
consent_granted = consent_granted =
((consent_level == XrConsentPromptLevel::kNone) || ((consent_level == XrConsentPromptLevel::kNone) ||
IsConsentGrantedForDevice(runtime->GetId(), consent_level)); IsConsentGrantedForDevice(request.runtime_id, consent_level));
} }
// Skip the consent prompt if the user has already consented for this device, // Skip the consent prompt if the user has already consented for this device,
// or if consent is not needed. // or if consent is not needed.
if (consent_granted || IsXrDeviceConsentPromptDisabledForTesting()) { if (consent_granted || IsXrDeviceConsentPromptDisabledForTesting()) {
DoRequestSession(std::move(options), std::move(callback), runtime, DoRequestSession(std::move(request), runtime);
std::move(requested_features));
return; return;
} }
...@@ -449,14 +453,14 @@ void VRServiceImpl::ShowConsentPrompt( ...@@ -449,14 +453,14 @@ void VRServiceImpl::ShowConsentPrompt(
// Need to calculate the permission before the call below, as otherwise // Need to calculate the permission before the call below, as otherwise
// std::move nulls options out before GetRequiredPermission runs. // std::move nulls options out before GetRequiredPermission runs.
ContentSettingsType permission = GetRequiredPermission(options->mode); ContentSettingsType permission =
GetRequiredPermission(request.options->mode);
permission_manager->RequestPermission( permission_manager->RequestPermission(
permission, render_frame_host_, permission, render_frame_host_,
render_frame_host_->GetLastCommittedURL(), true, render_frame_host_->GetLastCommittedURL(), true,
base::BindOnce(&VRServiceImpl::OnPermissionResult, base::BindOnce(&VRServiceImpl::OnPermissionResult,
weak_ptr_factory_.GetWeakPtr(), std::move(options), weak_ptr_factory_.GetWeakPtr(), std::move(request),
std::move(callback), runtime->GetId(), consent_level));
std::move(requested_features), consent_level));
return; return;
} }
...@@ -464,92 +468,76 @@ void VRServiceImpl::ShowConsentPrompt( ...@@ -464,92 +468,76 @@ void VRServiceImpl::ShowConsentPrompt(
render_frame_host_->GetProcess()->GetID(), render_frame_host_->GetProcess()->GetID(),
render_frame_host_->GetRoutingID(), consent_level, render_frame_host_->GetRoutingID(), consent_level,
base::BindOnce(&VRServiceImpl::OnConsentResult, base::BindOnce(&VRServiceImpl::OnConsentResult,
weak_ptr_factory_.GetWeakPtr(), std::move(options), weak_ptr_factory_.GetWeakPtr(), std::move(request)));
std::move(callback), runtime->GetId(),
std::move(requested_features)));
} }
// TODO(alcooper): Once the ConsentFlow can be removed expected_runtime_id and // TODO(alcooper): Once the ConsentFlow can be removed expected_runtime_id and
// consent_level shouldn't be needed. // consent_level shouldn't be needed.
void VRServiceImpl::OnPermissionResult( void VRServiceImpl::OnPermissionResult(SessionRequestData request,
device::mojom::XRSessionOptionsPtr options, XrConsentPromptLevel consent_level,
device::mojom::VRService::RequestSessionCallback callback, ContentSetting setting_value) {
device::mojom::XRDeviceId expected_runtime_id, OnConsentResult(std::move(request), consent_level,
std::set<device::mojom::XRSessionFeature> enabled_features,
XrConsentPromptLevel consent_level,
ContentSetting setting_value) {
OnConsentResult(std::move(options), std::move(callback), expected_runtime_id,
std::move(enabled_features), consent_level,
setting_value == ContentSetting::CONTENT_SETTING_ALLOW); setting_value == ContentSetting::CONTENT_SETTING_ALLOW);
} }
void VRServiceImpl::OnConsentResult( void VRServiceImpl::OnConsentResult(SessionRequestData request,
device::mojom::XRSessionOptionsPtr options, XrConsentPromptLevel consent_level,
device::mojom::VRService::RequestSessionCallback callback, bool is_consent_granted) {
device::mojom::XRDeviceId expected_runtime_id,
std::set<device::mojom::XRSessionFeature> enabled_features,
XrConsentPromptLevel consent_level,
bool is_consent_granted) {
DVLOG(2) << __func__; DVLOG(2) << __func__;
if (!is_consent_granted) { if (!is_consent_granted) {
std::move(callback).Run( std::move(request.callback)
device::mojom::RequestSessionResult::NewFailureReason( .Run(device::mojom::RequestSessionResult::NewFailureReason(
device::mojom::RequestSessionError::USER_DENIED_CONSENT)); device::mojom::RequestSessionError::USER_DENIED_CONSENT));
return; return;
} }
// Get the runtime again, since we're running in an async context // Get the runtime again, since we're running in an async context
// and the pointer returned from `GetRuntimeForOptions` is non-owning. // and the pointer returned from `GetRuntimeForOptions` is non-owning.
auto* runtime = runtime_manager_->GetRuntimeForOptions(options.get()); auto* runtime = runtime_manager_->GetRuntimeForOptions(request.options.get());
// Ensure that it's the same runtime as the one we expect. // Ensure that it's the same runtime as the one we expect.
if (!runtime || runtime->GetId() != expected_runtime_id) { if (!runtime || runtime->GetId() != request.runtime_id) {
std::move(callback).Run( std::move(request.callback)
device::mojom::RequestSessionResult::NewFailureReason( .Run(device::mojom::RequestSessionResult::NewFailureReason(
device::mojom::RequestSessionError::UNKNOWN_RUNTIME_ERROR)); device::mojom::RequestSessionError::UNKNOWN_RUNTIME_ERROR));
return; return;
} }
AddConsentGrantedDevice(runtime->GetId(), consent_level); AddConsentGrantedDevice(request.runtime_id, consent_level);
// Re-check for another client instance after a potential user consent. // Re-check for another client instance after a potential user consent.
if (runtime_manager_->IsOtherClientPresenting(this)) { if (runtime_manager_->IsOtherClientPresenting(this)) {
// Can't create sessions while an immersive session exists. // Can't create sessions while an immersive session exists.
std::move(callback).Run( std::move(request.callback)
device::mojom::RequestSessionResult::NewFailureReason( .Run(device::mojom::RequestSessionResult::NewFailureReason(
device::mojom::RequestSessionError::EXISTING_IMMERSIVE_SESSION)); device::mojom::RequestSessionError::EXISTING_IMMERSIVE_SESSION));
return; return;
} }
DoRequestSession(std::move(options), std::move(callback), runtime, DoRequestSession(std::move(request), runtime);
std::move(enabled_features));
} }
void VRServiceImpl::DoRequestSession( void VRServiceImpl::DoRequestSession(SessionRequestData request,
device::mojom::XRSessionOptionsPtr options, BrowserXRRuntime* runtime) {
device::mojom::VRService::RequestSessionCallback callback,
BrowserXRRuntime* runtime,
std::set<device::mojom::XRSessionFeature> enabled_features) {
DVLOG(2) << __func__; DVLOG(2) << __func__;
// Get the runtime we'll be creating a session with. // Get the runtime we'll be creating a session with.
DCHECK(runtime); DCHECK(runtime);
DCHECK_EQ(runtime->GetId(), request.runtime_id);
device::mojom::XRDeviceId session_runtime_id = runtime->GetId();
TRACE_EVENT_INSTANT1("xr", "GetRuntimeForOptions", TRACE_EVENT_SCOPE_THREAD, TRACE_EVENT_INSTANT1("xr", "GetRuntimeForOptions", TRACE_EVENT_SCOPE_THREAD,
"id", session_runtime_id); "id", request.runtime_id);
auto runtime_options = GetRuntimeOptions(options.get()); auto runtime_options = GetRuntimeOptions(request.options.get());
#if defined(OS_ANDROID) && BUILDFLAG(ENABLE_ARCORE) #if defined(OS_ANDROID) && BUILDFLAG(ENABLE_ARCORE)
if (session_runtime_id == device::mojom::XRDeviceId::ARCORE_DEVICE_ID) { if (request.runtime_id == device::mojom::XRDeviceId::ARCORE_DEVICE_ID) {
runtime_options->render_process_id = runtime_options->render_process_id =
render_frame_host_->GetProcess()->GetID(); render_frame_host_->GetProcess()->GetID();
runtime_options->render_frame_id = render_frame_host_->GetRoutingID(); runtime_options->render_frame_id = render_frame_host_->GetRoutingID();
} }
#endif #endif
// Make the resolved enabled features available to the runtime. // Make the resolved enabled features available to the runtime.
runtime_options->enabled_features.reserve(enabled_features.size()); runtime_options->enabled_features.reserve(request.enabled_features.size());
for (const auto& feature : enabled_features) { for (const auto& feature : request.enabled_features) {
runtime_options->enabled_features.push_back(feature); runtime_options->enabled_features.push_back(feature);
} }
...@@ -558,9 +546,7 @@ void VRServiceImpl::DoRequestSession( ...@@ -558,9 +546,7 @@ void VRServiceImpl::DoRequestSession(
base::OnceCallback<void(device::mojom::XRSessionPtr)> immersive_callback = base::OnceCallback<void(device::mojom::XRSessionPtr)> immersive_callback =
base::BindOnce(&VRServiceImpl::OnImmersiveSessionCreated, base::BindOnce(&VRServiceImpl::OnImmersiveSessionCreated,
weak_ptr_factory_.GetWeakPtr(), std::move(options), weak_ptr_factory_.GetWeakPtr(), std::move(request));
session_runtime_id, std::move(callback),
std::move(enabled_features));
runtime->RequestSession(this, std::move(runtime_options), runtime->RequestSession(this, std::move(runtime_options),
std::move(immersive_callback)); std::move(immersive_callback));
} else { } else {
...@@ -569,9 +555,7 @@ void VRServiceImpl::DoRequestSession( ...@@ -569,9 +555,7 @@ void VRServiceImpl::DoRequestSession(
mojo::PendingRemote<device::mojom::XRSessionController>)> mojo::PendingRemote<device::mojom::XRSessionController>)>
non_immersive_callback = non_immersive_callback =
base::BindOnce(&VRServiceImpl::OnInlineSessionCreated, base::BindOnce(&VRServiceImpl::OnInlineSessionCreated,
weak_ptr_factory_.GetWeakPtr(), std::move(options), weak_ptr_factory_.GetWeakPtr(), std::move(request));
session_runtime_id, std::move(callback),
std::move(enabled_features));
runtime->GetRuntime()->RequestSession(std::move(runtime_options), runtime->GetRuntime()->RequestSession(std::move(runtime_options),
std::move(non_immersive_callback)); std::move(non_immersive_callback));
} }
......
...@@ -87,6 +87,25 @@ class VRServiceImpl : public device::mojom::VRService, ...@@ -87,6 +87,25 @@ class VRServiceImpl : public device::mojom::VRService,
content::WebContents* GetWebContents(); content::WebContents* GetWebContents();
private: private:
struct SessionRequestData {
device::mojom::XRSessionOptionsPtr options;
device::mojom::VRService::RequestSessionCallback callback;
std::set<device::mojom::XRSessionFeature> enabled_features;
device::mojom::XRDeviceId runtime_id;
SessionRequestData(
device::mojom::XRSessionOptionsPtr options,
device::mojom::VRService::RequestSessionCallback callback,
std::set<device::mojom::XRSessionFeature> enabled_features,
device::mojom::XRDeviceId runtime_id);
~SessionRequestData();
SessionRequestData(SessionRequestData&&);
private:
SessionRequestData(const SessionRequestData&) = delete;
SessionRequestData& operator=(const SessionRequestData&) = delete;
};
// content::WebContentsObserver implementation // content::WebContentsObserver implementation
void OnWebContentsFocused(content::RenderWidgetHost* host) override; void OnWebContentsFocused(content::RenderWidgetHost* host) override;
void OnWebContentsLostFocus(content::RenderWidgetHost* host) override; void OnWebContentsLostFocus(content::RenderWidgetHost* host) override;
...@@ -102,57 +121,40 @@ class VRServiceImpl : public device::mojom::VRService, ...@@ -102,57 +121,40 @@ class VRServiceImpl : public device::mojom::VRService,
SessionMetricsHelper* GetSessionMetricsHelper(); SessionMetricsHelper* GetSessionMetricsHelper();
bool InternalSupportsSession(device::mojom::XRSessionOptions* options); bool InternalSupportsSession(device::mojom::XRSessionOptions* options);
void OnInlineSessionCreated(
device::mojom::XRSessionOptionsPtr options,
device::mojom::XRDeviceId session_runtime_id,
device::mojom::VRService::RequestSessionCallback callback,
const std::set<device::mojom::XRSessionFeature>& enabled_features,
device::mojom::XRSessionPtr session,
mojo::PendingRemote<device::mojom::XRSessionController> controller);
void OnImmersiveSessionCreated(
device::mojom::XRSessionOptionsPtr options,
device::mojom::XRDeviceId session_runtime_id,
device::mojom::VRService::RequestSessionCallback callback,
const std::set<device::mojom::XRSessionFeature>& enabled_features,
device::mojom::XRSessionPtr session);
void OnSessionCreated(
device::mojom::XRSessionOptionsPtr options,
device::mojom::XRDeviceId session_runtime_id,
device::mojom::VRService::RequestSessionCallback callback,
const std::set<device::mojom::XRSessionFeature>& enabled_features,
device::mojom::XRSessionPtr session,
WebXRSessionTracker* session_metrics_tracker);
void DoRequestSession(
device::mojom::XRSessionOptionsPtr options,
device::mojom::VRService::RequestSessionCallback callback,
BrowserXRRuntime* runtime,
std::set<device::mojom::XRSessionFeature> enabled_features);
void ShowConsentPrompt(
device::mojom::XRSessionOptionsPtr options,
device::mojom::VRService::RequestSessionCallback callback,
BrowserXRRuntime* runtime,
std::set<device::mojom::XRSessionFeature> requested_features);
void OnConsentResult(
device::mojom::XRSessionOptionsPtr options,
device::mojom::VRService::RequestSessionCallback callback,
device::mojom::XRDeviceId expected_runtime_id,
std::set<device::mojom::XRSessionFeature> enabled_features,
XrConsentPromptLevel consent_level,
bool is_consent_granted);
void OnPermissionResult(
device::mojom::XRSessionOptionsPtr options,
device::mojom::VRService::RequestSessionCallback callback,
device::mojom::XRDeviceId expected_runtime_id,
std::set<device::mojom::XRSessionFeature> enabled_features,
XrConsentPromptLevel consent_level,
ContentSetting setting_value);
bool IsConsentGrantedForDevice(device::mojom::XRDeviceId device_id, bool IsConsentGrantedForDevice(device::mojom::XRDeviceId device_id,
XrConsentPromptLevel consent_level); XrConsentPromptLevel consent_level);
void AddConsentGrantedDevice(device::mojom::XRDeviceId device_id, void AddConsentGrantedDevice(device::mojom::XRDeviceId device_id,
XrConsentPromptLevel consent_level); XrConsentPromptLevel consent_level);
// The following steps are ordered in the general flow for "RequestSession"
// If the WebXrPermissionsAPI is enabled ShowConsentPrompt will result in a
// call to OnPermissionResult which feeds into OnConsentResult.
// If ShowConsentPrompt determines that no consent/permission is needed (or
// has already been granted), then it will directly call DoRequestSession.
// DoRequestSession will continue with OnInline or OnImmersive SessionCreated
// depending on the type of SessionCreated.
void ShowConsentPrompt(SessionRequestData request, BrowserXRRuntime* runtime);
void OnConsentResult(SessionRequestData request,
XrConsentPromptLevel consent_level,
bool is_consent_granted);
void OnPermissionResult(SessionRequestData request,
XrConsentPromptLevel consent_level,
ContentSetting setting_value);
void DoRequestSession(SessionRequestData request, BrowserXRRuntime* runtime);
void OnInlineSessionCreated(
SessionRequestData request,
device::mojom::XRSessionPtr session,
mojo::PendingRemote<device::mojom::XRSessionController> controller);
void OnImmersiveSessionCreated(SessionRequestData request,
device::mojom::XRSessionPtr session);
void OnSessionCreated(SessionRequestData request,
device::mojom::XRSessionPtr session,
WebXRSessionTracker* session_metrics_tracker);
scoped_refptr<XRRuntimeManager> runtime_manager_; scoped_refptr<XRRuntimeManager> runtime_manager_;
mojo::RemoteSet<device::mojom::XRSessionClient> session_clients_; mojo::RemoteSet<device::mojom::XRSessionClient> session_clients_;
mojo::Remote<device::mojom::VRServiceClient> service_client_; mojo::Remote<device::mojom::VRServiceClient> service_client_;
......
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