Commit 21811970 authored by Alex Cooper's avatar Alex Cooper Committed by Commit Bot

Remove WebVR Display events/plumbing

This change removes the infrastructure around the WebVr displayactivate
events, including XRRuntimeEventListener methods and XRRuntime's
SetListeningForActivate for notifications to the browser process.
This also remvoes the VRDisplayClient, and some compatibility methods
on the VRService.
Future work will remove GetImmersiveVRDisplayInfo, which should be the
last remaining WebVr-only method in the mojom files.

Bug: 1017872
Change-Id: Ic149384917a25d6db4fceef35091f28350025f90
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1898506Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarKlaus Weidner <klausw@chromium.org>
Reviewed-by: default avatarPiotr Bialecki <bialpio@chromium.org>
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713693}
parent f8ad018f
......@@ -165,10 +165,6 @@ public class VrShellDelegate
private boolean mRestoreSystemUiVisibility;
private Integer mRestoreOrientation;
private boolean mRequestedWebVr;
private boolean mListeningForWebVrActivate;
private boolean mMaybeActivateAfterHeadsetInsertion;
private Handler mClearMaybeActivateHandler = new Handler();
private boolean mActivateFromHeadsetInsertion;
private boolean mStartedFromVrIntent;
private boolean mInternalIntentUsedToStartVr;
......@@ -252,11 +248,6 @@ public class VrShellDelegate
VrModuleProvider.getDelegate().addBlackOverlayViewForActivity(sInstance.mActivity);
}
// For headset insertion handling it should be impossible in practice to receive this
// broadcast after being resumed. However, with VR entry flows skipped, these events
// can happen out of order. See https://crbug.com/762724.
sInstance.mActivateFromHeadsetInsertion = sInstance.mMaybeActivateAfterHeadsetInsertion;
if (sInstance.mPaused) {
if (activity instanceof ChromeTabbedActivity) {
// We can special case singleInstance activities like CTA to avoid having to use
......@@ -1067,19 +1058,7 @@ public class VrShellDelegate
if (mNativeVrShellDelegate == 0) return false;
if (!canEnterVr()) return false;
// If headset insertion was performed while a page was listening for vrdisplayactivate,
// we assume it wants to request presentation. Go into WebVR mode tentatively. If the page
// doesn't request presentation in the vrdisplayactivate handler we will exit presentation
// later.
if (mActivateFromHeadsetInsertion) {
assert !mRequestedWebVr;
assert !mStartedFromVrIntent;
}
enterVr(mActivateFromHeadsetInsertion);
if (mActivateFromHeadsetInsertion && mListeningForWebVrActivate) {
VrShellDelegateJni.get().displayActivate(mNativeVrShellDelegate, VrShellDelegate.this);
mActivateFromHeadsetInsertion = false;
}
enterVr();
// The user has successfully completed a DON flow.
RecordUserAction.record("VR.DON");
......@@ -1087,7 +1066,7 @@ public class VrShellDelegate
return true;
}
private void enterVr(final boolean tentativeWebVrMode) {
private void enterVr() {
// We should only enter VR when we're the resumed Activity or our changes to things like
// system UI flags might get lost.
assert !mPaused;
......@@ -1116,12 +1095,11 @@ public class VrShellDelegate
if (!sRegisteredVrAssetsComponent) {
registerVrAssetsComponentIfDaydreamUser(isDaydreamCurrentViewer());
}
boolean webVrMode = mRequestedWebVr || tentativeWebVrMode;
mVrShell.initializeNative(webVrMode, VrModuleProvider.getDelegate().bootsToVr());
mVrShell.setWebVrModeEnabled(webVrMode);
mVrShell.initializeNative(mRequestedWebVr, VrModuleProvider.getDelegate().bootsToVr());
mVrShell.setWebVrModeEnabled(mRequestedWebVr);
// We're entering VR, but not in WebVr mode.
mVrBrowserUsed = !webVrMode;
mVrBrowserUsed = !mRequestedWebVr;
// resume needs to be called on GvrLayout after initialization to make sure DON flow works
// properly.
......@@ -1298,8 +1276,7 @@ public class VrShellDelegate
if (getVrSupportLevel() <= VrSupportLevel.VR_NEEDS_UPDATE) return false;
// If VR browsing is not enabled and this is not a WebXR request, then return false.
boolean presenting = mRequestedWebVr || mActivateFromHeadsetInsertion;
if (!isVrBrowsingEnabled() && !presenting) return false;
if (!isVrBrowsingEnabled() && !mRequestedWebVr) return false;
return true;
}
......@@ -1354,7 +1331,7 @@ public class VrShellDelegate
getVrDaydreamApi().launchInVr(getEnterVrPendingIntent(mActivity));
mProbablyInDon = true;
} else {
enterVr(false);
enterVr();
}
return EnterVRResult.REQUESTED;
}
......@@ -1430,9 +1407,6 @@ public class VrShellDelegate
@VisibleForTesting
protected void onResume() {
if (VrDelegate.DEBUG_LOGS) Log.i(TAG, "onResume");
if (!mTestWorkaroundDontCancelVrEntryOnResume) {
mMaybeActivateAfterHeadsetInsertion = false;
}
if (mNeedsAnimationCancel) {
// At least on some devices, like the Samsung S8+, a Window animation is run after our
// Activity is shown that fades between a stale screenshot from before pausing to the
......@@ -1520,7 +1494,6 @@ public class VrShellDelegate
if (mInVr) {
maybeSetPresentResult(true);
mDonSucceeded = false;
assert !mActivateFromHeadsetInsertion;
return;
}
if (maybeExitVrToUpdateVrServices()) return;
......@@ -1556,10 +1529,6 @@ public class VrShellDelegate
unregisterDaydreamIntent();
if (getVrSupportLevel() <= VrSupportLevel.VR_NEEDS_UPDATE) return;
if (mMaybeActivateAfterHeadsetInsertion) {
mClearMaybeActivateHandler.removeCallbacksAndMessages(null);
}
if (mInVr) mVrShell.pause();
if (mNativeVrShellDelegate != 0) {
VrShellDelegateJni.get().onPause(mNativeVrShellDelegate, VrShellDelegate.this);
......@@ -1569,7 +1538,6 @@ public class VrShellDelegate
}
private void onStart() {
mMaybeActivateAfterHeadsetInsertion = false;
if (mDonSucceeded) setWindowModeForVr();
// This handles the case where Chrome was paused in VR (ie the user navigated to DD home or
......@@ -1658,47 +1626,10 @@ public class VrShellDelegate
return mIsDaydreamCurrentViewer;
}
@CalledByNative
private void setListeningForWebVrActivate(boolean listening) {
if (VrDelegate.DEBUG_LOGS) {
Log.i(TAG, "WebVR page listening for vrdisplayactivate: " + listening);
}
// Non-Daydream devices do not have the concept of activation.
if (getVrSupportLevel() != VrSupportLevel.VR_DAYDREAM) return;
if (mListeningForWebVrActivate == listening) return;
mListeningForWebVrActivate = listening;
if (mListeningForWebVrActivate) {
registerDaydreamIntent(mActivity);
if (mNeedsAnimationCancel || mCancellingEntryAnimation) return;
if (mActivateFromHeadsetInsertion) {
// Dispatch vrdisplayactivate so that the WebVr page can call requestPresent
// to start presentation.
VrShellDelegateJni.get().displayActivate(
mNativeVrShellDelegate, VrShellDelegate.this);
mActivateFromHeadsetInsertion = false;
}
} else {
if (!canEnterVr()) unregisterDaydreamIntent();
// When the active web page has a vrdisplayactivate event handler, and the phone is
// inserted into the headset, a vrdisplayactive event should be fired once DON flow
// is finished. However, the DON flow will pause our activity, which makes the active
// page lose focus and report that it can't handle displayActivate.
// Because of the order of onPause events running, we can't check for
// mListeningForWebVrActivate in onPause() as we may or may not already have lost focus.
// We need to remember that
mMaybeActivateAfterHeadsetInsertion = !mInVr && !mRequestedWebVr;
if (!mPaused) {
mClearMaybeActivateHandler.post(
() -> { mMaybeActivateAfterHeadsetInsertion = false; });
}
}
}
private void cancelPendingVrEntry() {
if (VrDelegate.DEBUG_LOGS) Log.i(TAG, "cancelPendingVrEntry");
VrModuleProvider.getDelegate().removeBlackOverlayView(mActivity, false /* animate */);
mDonSucceeded = false;
mActivateFromHeadsetInsertion = false;
maybeSetPresentResult(false);
if (!mShowingDaydreamDoff) {
setVrModeEnabled(mActivity, false);
......@@ -1922,11 +1853,6 @@ public class VrShellDelegate
mFeedbackFrequency = frequency;
}
@VisibleForTesting
protected boolean isListeningForWebVrActivate() {
return mListeningForWebVrActivate;
}
@VisibleForTesting
protected boolean isVrEntryComplete() {
return mInVr && !mProbablyInDon && getVrShell().hasUiFinishedLoading();
......@@ -1973,7 +1899,6 @@ public class VrShellDelegate
void onLibraryAvailable();
void setPresentResult(long nativeVrShellDelegate, VrShellDelegate caller, boolean result);
void recordVrStartAction(long nativeVrShellDelegate, int startAction);
void displayActivate(long nativeVrShellDelegate, VrShellDelegate caller);
void onPause(long nativeVrShellDelegate, VrShellDelegate caller);
void onResume(long nativeVrShellDelegate, VrShellDelegate caller);
void destroy(long nativeVrShellDelegate, VrShellDelegate caller);
......
......@@ -82,11 +82,6 @@ public class TestVrShellDelegate extends VrShellDelegate {
return super.isBlackOverlayVisible();
}
@Override
public boolean isListeningForWebVrActivate() {
return super.isListeningForWebVrActivate();
}
@Override
public boolean isVrEntryComplete() {
return super.isVrEntryComplete();
......@@ -191,4 +186,4 @@ public class TestVrShellDelegate extends VrShellDelegate {
public void setAllow2dIntents(boolean allow) {
mAllow2dIntents = allow;
}
}
\ No newline at end of file
}
......@@ -211,23 +211,6 @@ void VrShellDelegate::SendRequestPresentReply(
std::move(request_present_response_callback_).Run(std::move(session));
}
void VrShellDelegate::DisplayActivate(JNIEnv* env,
const JavaParamRef<jobject>& obj) {
device::GvrDevice* gvr_device = GetGvrDevice();
if (gvr_device) {
// The only possible source for DisplayActivate is HeadsetActivation.
possible_presentation_start_action_ =
PresentationStartAction::kHeadsetActivation;
gvr_device->Activate(
device::mojom::VRDisplayEventReason::MOUNTED,
base::BindRepeating(&VrShellDelegate::OnActivateDisplayHandled,
weak_ptr_factory_.GetWeakPtr()));
} else {
OnActivateDisplayHandled(true /* will_not_present */);
}
}
void VrShellDelegate::OnPause(JNIEnv* env, const JavaParamRef<jobject>& obj) {
if (vr_shell_)
return;
......@@ -289,22 +272,6 @@ std::unique_ptr<VrCoreInfo> VrShellDelegate::MakeVrCoreInfo(JNIEnv* env) {
Java_VrShellDelegate_getVrCoreInfo(env, j_vr_shell_delegate_)));
}
void VrShellDelegate::OnActivateDisplayHandled(bool will_not_present) {
if (will_not_present) {
// WebVR page didn't request presentation in the vrdisplayactivate handler.
// Tell VrShell that we are in VR Browsing Mode.
ExitWebVRPresent();
// Reset possible_presentation_start_action_ as it may have been set.
possible_presentation_start_action_ = base::nullopt;
}
}
void VrShellDelegate::OnListeningForActivateChanged(bool listening) {
JNIEnv* env = AttachCurrentThread();
Java_VrShellDelegate_setListeningForWebVrActivate(env, j_vr_shell_delegate_,
listening);
}
void VrShellDelegate::OnRuntimeAdded(vr::BrowserXRRuntime* runtime) {
if (vr_shell_) {
// See comment in VrShellDelegate::SetDelegate. This handles the case where
......
......@@ -59,8 +59,6 @@ class VrShellDelegate : public device::GvrDelegateProvider,
jboolean success);
void RecordVrStartAction(JNIEnv* env,
jint start_action);
void DisplayActivate(JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj);
void OnPause(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj);
void OnResume(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj);
bool IsClearActivatePending(JNIEnv* env,
......@@ -81,7 +79,6 @@ class VrShellDelegate : public device::GvrDelegateProvider,
device::mojom::VRDisplayInfoPtr display_info,
device::mojom::XRRuntimeSessionOptionsPtr options,
base::OnceCallback<void(device::mojom::XRSessionPtr)> callback) override;
void OnListeningForActivateChanged(bool listening) override;
// vr::XRRuntimeManagerObserver implementation.
// VrShellDelegate implements XRRuntimeManagerObserver to turn off poses (by
......@@ -91,9 +88,6 @@ class VrShellDelegate : public device::GvrDelegateProvider,
// VrShell got created, their poses will be turned off too on its
// creation.
void OnRuntimeAdded(vr::BrowserXRRuntime* runtime) override;
void OnActivateDisplayHandled(bool will_not_present);
void SetListeningForActivate(bool listening);
void OnPresentResult(
device::mojom::VRDisplayInfoPtr display_info,
device::mojom::XRRuntimeSessionOptionsPtr options,
......
......@@ -396,24 +396,6 @@ void BrowserXRRuntime::OnExitPresent() {
}
}
void BrowserXRRuntime::OnDeviceActivated(
device::mojom::VRDisplayEventReason reason,
base::OnceCallback<void(bool)> on_handled) {
if (listening_for_activation_service_) {
listening_for_activation_service_->OnActivate(reason,
std::move(on_handled));
} else {
std::move(on_handled).Run(true /* will_not_present */);
}
}
void BrowserXRRuntime::OnDeviceIdle(
device::mojom::VRDisplayEventReason reason) {
for (VRServiceImpl* service : services_) {
service->OnDeactivate(reason);
}
}
void BrowserXRRuntime::OnVisibilityStateChanged(
device::mojom::XRVisibilityState visibility_state) {
for (VRServiceImpl* service : services_) {
......@@ -441,11 +423,6 @@ void BrowserXRRuntime::OnServiceRemoved(VRServiceImpl* service) {
if (service == presenting_service_) {
ExitPresent(service, base::DoNothing());
}
if (service == listening_for_activation_service_) {
// Not listening for activation.
listening_for_activation_service_ = nullptr;
runtime_->SetListeningForActivate(false);
}
}
void BrowserXRRuntime::ExitPresent(
......@@ -524,18 +501,6 @@ void BrowserXRRuntime::OnImmersiveSessionError() {
StopImmersiveSession(base::DoNothing());
}
void BrowserXRRuntime::UpdateListeningForActivate(VRServiceImpl* service) {
if (service->ListeningForActivate() && service->InFocusedFrame()) {
bool was_listening = !!listening_for_activation_service_;
listening_for_activation_service_ = service;
if (!was_listening)
OnListeningForActivate(true);
} else if (listening_for_activation_service_ == service) {
listening_for_activation_service_ = nullptr;
OnListeningForActivate(false);
}
}
void BrowserXRRuntime::InitializeAndGetDisplayInfo(
content::RenderFrameHost* render_frame_host,
device::mojom::VRService::GetImmersiveVRDisplayInfoCallback callback) {
......@@ -551,8 +516,4 @@ void BrowserXRRuntime::InitializeAndGetDisplayInfo(
base::BindOnce(&BrowserXRRuntime::OnInitialized, base::Unretained(this)));
}
void BrowserXRRuntime::OnListeningForActivate(bool is_listening) {
runtime_->SetListeningForActivate(is_listening);
}
} // namespace vr
......@@ -79,7 +79,6 @@ class BrowserXRRuntime : public device::mojom::XRRuntimeEventListener {
VRServiceImpl* GetServiceWithActiveImmersiveSession() {
return presenting_service_;
}
void UpdateListeningForActivate(VRServiceImpl* service);
device::mojom::VRDisplayInfoPtr GetVRDisplayInfo() {
return display_info_.Clone();
......@@ -103,14 +102,10 @@ class BrowserXRRuntime : public device::mojom::XRRuntimeEventListener {
void OnDisplayInfoChanged(
device::mojom::VRDisplayInfoPtr vr_device_info) override;
void OnExitPresent() override;
void OnDeviceActivated(device::mojom::VRDisplayEventReason reason,
base::OnceCallback<void(bool)> on_handled) override;
void OnDeviceIdle(device::mojom::VRDisplayEventReason reason) override;
void OnVisibilityStateChanged(
device::mojom::XRVisibilityState visibility_state) override;
void StopImmersiveSession(VRServiceImpl::ExitPresentCallback on_exited);
void OnListeningForActivate(bool is_listening);
void OnRequestSessionResult(
base::WeakPtr<VRServiceImpl> service,
device::mojom::XRRuntimeSessionOptionsPtr options,
......@@ -129,7 +124,6 @@ class BrowserXRRuntime : public device::mojom::XRRuntimeEventListener {
std::set<VRServiceImpl*> services_;
device::mojom::VRDisplayInfoPtr display_info_;
VRServiceImpl* listening_for_activation_service_ = nullptr;
VRServiceImpl* presenting_service_ = nullptr;
mojo::AssociatedReceiver<device::mojom::XRRuntimeEventListener> receiver_{
......
......@@ -219,12 +219,6 @@ void VRServiceImpl::OnWebContentsFocusChanged(content::RenderWidgetHost* host,
}
in_focused_frame_ = focused;
if (ListeningForActivate()) {
BrowserXRRuntime* immersive_runtime =
runtime_manager_->GetImmersiveVrRuntime();
if (immersive_runtime)
immersive_runtime->UpdateListeningForActivate(this);
}
for (const auto& controller : magic_window_controllers_)
controller->SetFrameDataRestricted(!focused);
......@@ -611,21 +605,6 @@ void VRServiceImpl::SetFramesThrottled(bool throttled) {
}
}
void VRServiceImpl::SetListeningForActivate(
mojo::PendingRemote<device::mojom::VRDisplayClient> display_client) {
// TODO(crbug.com/999745): Remove the check if the condition to check if
// |display_client| is nullptr is not required.
if (display_client)
display_client_.Bind(std::move(display_client));
else
display_client_.reset();
BrowserXRRuntime* immersive_runtime =
runtime_manager_->GetImmersiveVrRuntime();
if (immersive_runtime && display_client_) {
immersive_runtime->UpdateListeningForActivate(this);
}
}
void VRServiceImpl::GetImmersiveVRDisplayInfo(
device::mojom::VRService::GetImmersiveVRDisplayInfoCallback callback) {
if (!initialization_complete_) {
......@@ -669,21 +648,6 @@ void VRServiceImpl::OnVisibilityStateChanged(
client->OnVisibilityStateChanged(visiblity_state);
}
void VRServiceImpl::OnActivate(device::mojom::VRDisplayEventReason reason,
base::OnceCallback<void(bool)> on_handled) {
DVLOG(2) << __func__;
if (display_client_) {
display_client_->OnActivate(reason, std::move(on_handled));
}
}
void VRServiceImpl::OnDeactivate(device::mojom::VRDisplayEventReason reason) {
DVLOG(2) << __func__;
if (display_client_) {
display_client_->OnDeactivate(reason);
}
}
content::WebContents* VRServiceImpl::GetWebContents() {
return content::WebContents::FromRenderFrameHost(render_frame_host_);
}
......
......@@ -81,10 +81,6 @@ class VR_EXPORT VRServiceImpl : public device::mojom::VRService,
void OnExitPresent();
void OnVisibilityStateChanged(
device::mojom::XRVisibilityState visibility_state);
void OnActivate(device::mojom::VRDisplayEventReason reason,
base::OnceCallback<void(bool)> on_handled);
void OnDeactivate(device::mojom::VRDisplayEventReason reason);
bool ListeningForActivate() { return !!display_client_; }
bool InFocusedFrame() { return in_focused_frame_; }
void OnDisplayInfoChanged();
void RuntimesChanged();
......@@ -95,10 +91,6 @@ class VR_EXPORT VRServiceImpl : public device::mojom::VRService,
content::WebContents* GetWebContents();
void SetListeningForActivate(
mojo::PendingRemote<device::mojom::VRDisplayClient> display_client)
override;
private:
// content::WebContentsObserver implementation
void OnWebContentsFocused(content::RenderWidgetHost* host) override;
......@@ -171,9 +163,6 @@ class VR_EXPORT VRServiceImpl : public device::mojom::VRService,
// List of callbacks to run when initialization is completed.
std::vector<base::OnceCallback<void()>> pending_requests_;
// This is required for WebVR 1.1 backwards compatibility.
mojo::Remote<device::mojom::VRDisplayClient> display_client_;
bool initialization_complete_ = false;
bool in_focused_frame_ = false;
bool frames_throttled_ = false;
......
......@@ -249,8 +249,6 @@ if (enable_vr) {
"test/fake_vr_device.h",
"test/fake_vr_device_provider.cc",
"test/fake_vr_device_provider.h",
"test/fake_vr_display_impl_client.cc",
"test/fake_vr_display_impl_client.h",
"test/fake_vr_service_client.cc",
"test/fake_vr_service_client.h",
"vr_export.h",
......
......@@ -24,7 +24,6 @@ class DEVICE_VR_EXPORT GvrDelegateProvider {
mojom::XRRuntimeSessionOptionsPtr options,
base::OnceCallback<void(device::mojom::XRSessionPtr)> callback) = 0;
virtual void ExitWebVRPresent() = 0;
virtual void OnListeningForActivateChanged(bool listening) = 0;
protected:
virtual ~GvrDelegateProvider() = default;
......
......@@ -254,13 +254,6 @@ void GvrDevice::StopPresenting() {
exclusive_controller_receiver_.reset();
}
void GvrDevice::OnListeningForActivate(bool listening) {
GvrDelegateProvider* delegate_provider = GetGvrDelegateProvider();
if (!delegate_provider)
return;
delegate_provider->OnListeningForActivateChanged(listening);
}
void GvrDevice::PauseTracking() {
paused_ = true;
if (gvr_api_ && non_presenting_context_.obj()) {
......@@ -297,11 +290,6 @@ void GvrDevice::OnDisplayConfigurationChanged(JNIEnv* env,
SetVRDisplayInfo(CreateVRDisplayInfo(gvr_api_.get(), GetId()));
}
void GvrDevice::Activate(mojom::VRDisplayEventReason reason,
base::Callback<void(bool)> on_handled) {
OnActivate(reason, std::move(on_handled));
}
void GvrDevice::Init(base::OnceCallback<void(bool)> on_finished) {
GvrDelegateProvider* delegate_provider = GetGvrDelegateProvider();
if (!delegate_provider || delegate_provider->ShouldDisableGvrDevice()) {
......
......@@ -38,13 +38,7 @@ class DEVICE_VR_EXPORT GvrDevice : public VRDeviceBase,
JNIEnv* env,
const base::android::JavaRef<jobject>& obj);
void Activate(mojom::VRDisplayEventReason reason,
base::Callback<void(bool)> on_handled);
private:
// VRDeviceBase
void OnListeningForActivate(bool listening) override;
void OnStartPresentResult(mojom::XRSessionPtr session);
// XRSessionController
......
......@@ -27,13 +27,6 @@ interface XRRuntimeEventListener {
// A device has changed its display information.
OnDisplayInfoChanged(device.mojom.VRDisplayInfo display_info);
// A device has indicated that it is in use.
OnDeviceActivated(device.mojom.VRDisplayEventReason reason) =>
(bool will_not_present);
// A device has indicated that it is idle.
OnDeviceIdle(device.mojom.VRDisplayEventReason reason);
// A device has indicated that the visibility of the content it's displaying
// has changed.
OnVisibilityStateChanged(device.mojom.XRVisibilityState visibility_state);
......@@ -88,8 +81,6 @@ interface XRRuntime {
// GvrDevice::RequestSession().
EnsureInitialized() => ();
SetListeningForActivate(bool listen_for_activation);
SetInlinePosesEnabled(bool enable);
};
......
......@@ -465,13 +465,6 @@ struct XRFrameData {
XRHitTestSubscriptionResultsData? hit_test_subscription_results;
};
enum VRDisplayEventReason {
NONE = 0,
NAVIGATION = 1,
MOUNTED = 2,
UNMOUNTED = 3
};
enum RequestSessionError {
ORIGIN_NOT_SECURE = 1,
EXISTING_IMMERSIVE_SESSION = 2,
......@@ -502,10 +495,6 @@ interface VRService {
// A bad message will be reported if this is called multiple times.
SetClient(pending_remote<VRServiceClient> client);
// WebVR 1.1 functionality compatibility method. To stop listening pass a null
// client.
SetListeningForActivate(pending_remote<VRDisplayClient>? client);
// Request to initialize a session in the browser process. If successful, the
// XRSession struct with the requisite interfaces will be returned.
RequestSession(XRSessionOptions options) => (RequestSessionResult result);
......@@ -724,15 +713,3 @@ interface XRSessionClient {
// Indicates a change in the visibility of the WebXR content.
OnVisibilityStateChanged(XRVisibilityState visibility_state);
};
// Backwards compatibility events for WebVR 1.1. These are expected to not be
// used for WebXR.
interface VRDisplayClient {
// Inform the renderer that a headset has sent a signal indicating that the
// user has put it on. Returns an indicator of whether or not the page
// actually started a WebVR 1.1 presentation.
OnActivate(VRDisplayEventReason reason) => (bool will_not_present);
// Inform the renderer that a headset has sent a signal indicating that the
// user stopped using a headset.
OnDeactivate(VRDisplayEventReason reason);
};
// Copyright 2016 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 "device/vr/test/fake_vr_display_impl_client.h"
#include "device/vr/test/fake_vr_service_client.h"
namespace device {
FakeVRDisplayImplClient::FakeVRDisplayImplClient(
mojo::PendingReceiver<mojom::VRDisplayClient> receiver)
: receiver_(this, std::move(receiver)) {}
FakeVRDisplayImplClient::~FakeVRDisplayImplClient() {}
void FakeVRDisplayImplClient::SetServiceClient(
FakeVRServiceClient* service_client) {
service_client_ = service_client;
}
void FakeVRDisplayImplClient::OnChanged(mojom::VRDisplayInfoPtr display) {
service_client_->SetLastDeviceId(display->id);
}
} // namespace device
// Copyright 2016 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 DEVICE_VR_TEST_FAKE_VR_DISPLAY_IMPL_CLIENT_H_
#define DEVICE_VR_TEST_FAKE_VR_DISPLAY_IMPL_CLIENT_H_
#include "device/vr/public/mojom/vr_service.mojom.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"
namespace device {
class FakeVRServiceClient;
class FakeVRDisplayImplClient : public mojom::VRDisplayClient,
public mojom::XRSessionClient {
public:
explicit FakeVRDisplayImplClient(
mojo::PendingReceiver<mojom::VRDisplayClient> receiver);
~FakeVRDisplayImplClient() override;
void SetServiceClient(FakeVRServiceClient* service_client);
// mojom::XRSessionClient overrides
void OnChanged(mojom::VRDisplayInfoPtr display) override;
void OnExitPresent() override {}
void OnVisibilityStateChanged(
mojom::XRVisibilityState visibility_state) override {}
// mojom::VRDisplayClient overrides
void OnActivate(mojom::VRDisplayEventReason reason,
OnActivateCallback callback) override {}
void OnDeactivate(mojom::VRDisplayEventReason reason) override {}
private:
FakeVRServiceClient* service_client_;
mojom::VRDisplayInfoPtr last_display_;
mojo::Receiver<mojom::VRDisplayClient> receiver_;
DISALLOW_COPY_AND_ASSIGN(FakeVRDisplayImplClient);
};
} // namespace device
#endif // DEVICE_VR_TEST_FAKE_VR_DISPLAY_IMPL_CLIENT_H_
......@@ -3,7 +3,6 @@
// found in the LICENSE file.
#include "device/vr/test/fake_vr_service_client.h"
#include "device/vr/test/fake_vr_display_impl_client.h"
namespace device {
......
......@@ -11,8 +11,6 @@
#include "mojo/public/cpp/bindings/receiver.h"
namespace device {
class FakeVRDisplayImplClient;
// TODO(mthiesse, crbug.com/769373): Remove DEVICE_VR_EXPORT.
class DEVICE_VR_EXPORT FakeVRServiceClient : public mojom::VRServiceClient {
public:
......@@ -25,8 +23,6 @@ class DEVICE_VR_EXPORT FakeVRServiceClient : public mojom::VRServiceClient {
bool CheckDeviceId(mojom::XRDeviceId id);
private:
std::vector<mojom::VRDisplayInfoPtr> displays_;
std::vector<std::unique_ptr<FakeVRDisplayImplClient>> display_clients_;
mojom::XRDeviceId last_device_id_ = static_cast<mojom::XRDeviceId>(0);
mojo::Receiver<mojom::VRServiceClient> receiver_;
......
......@@ -69,12 +69,6 @@ void VRDeviceBase::SetVRDisplayInfo(mojom::VRDisplayInfoPtr display_info) {
listener_->OnDisplayInfoChanged(display_info_.Clone());
}
void VRDeviceBase::OnActivate(mojom::VRDisplayEventReason reason,
base::Callback<void(bool)> on_handled) {
if (listener_)
listener_->OnDeviceActivated(reason, std::move(on_handled));
}
void VRDeviceBase::OnVisibilityStateChanged(
mojom::XRVisibilityState visibility_state) {
if (listener_)
......@@ -86,12 +80,6 @@ mojo::PendingRemote<mojom::XRRuntime> VRDeviceBase::BindXRRuntime() {
return runtime_receiver_.BindNewPipeAndPassRemote();
}
void VRDeviceBase::OnListeningForActivate(bool listening) {}
void VRDeviceBase::SetListeningForActivate(bool is_listening) {
OnListeningForActivate(is_listening);
}
void VRDeviceBase::EnsureInitialized(EnsureInitializedCallback callback) {
std::move(callback).Run();
}
......
......@@ -33,7 +33,6 @@ class DEVICE_VR_EXPORT VRDeviceBase : public mojom::XRRuntime {
void ListenToDeviceChanges(
mojo::PendingAssociatedRemote<mojom::XRRuntimeEventListener> listener,
mojom::XRRuntime::ListenToDeviceChangesCallback callback) final;
void SetListeningForActivate(bool is_listening) override;
void EnsureInitialized(EnsureInitializedCallback callback) override;
void SetInlinePosesEnabled(bool enable) override;
void ShutdownSession(mojom::XRRuntime::ShutdownSessionCallback) override;
......@@ -67,8 +66,6 @@ class DEVICE_VR_EXPORT VRDeviceBase : public mojom::XRRuntime {
void OnStartPresenting();
bool IsPresenting() { return presenting_; } // Exposed for test.
void SetVRDisplayInfo(mojom::VRDisplayInfoPtr display_info);
void OnActivate(mojom::VRDisplayEventReason reason,
base::Callback<void(bool)> on_handled);
void OnVisibilityStateChanged(mojom::XRVisibilityState visibility_state);
mojom::VRDisplayInfoPtr display_info_;
......@@ -76,8 +73,6 @@ class DEVICE_VR_EXPORT VRDeviceBase : public mojom::XRRuntime {
bool inline_poses_enabled_ = true;
private:
// TODO(https://crbug.com/842227): Rename methods to HandleOnXXX
virtual void OnListeningForActivate(bool listening);
mojo::AssociatedRemote<mojom::XRRuntimeEventListener> listener_;
......
......@@ -31,22 +31,11 @@ class VRDeviceBaseForTesting : public VRDeviceBase {
SetVRDisplayInfo(std::move(display_info));
}
void FireDisplayActivate() {
OnActivate(device::mojom::VRDisplayEventReason::MOUNTED, base::DoNothing());
}
bool ListeningForActivate() { return listening_for_activate; }
void RequestSession(
mojom::XRRuntimeSessionOptionsPtr options,
mojom::XRRuntime::RequestSessionCallback callback) override {}
private:
void OnListeningForActivate(bool listening) override {
listening_for_activate = listening;
}
bool listening_for_activate = false;
DISALLOW_COPY_AND_ASSIGN(VRDeviceBaseForTesting);
};
......@@ -61,20 +50,8 @@ class StubVRDeviceEventListener : public mojom::XRRuntimeEventListener {
DoOnChanged(vr_device_info.get());
}
MOCK_METHOD2(DoOnDeviceActivated,
void(mojom::VRDisplayEventReason,
base::OnceCallback<void(bool)>));
void OnDeviceActivated(mojom::VRDisplayEventReason reason,
base::OnceCallback<void(bool)> callback) override {
DoOnDeviceActivated(reason, base::DoNothing());
// For now keep the test simple, and just call the callback:
std::move(callback).Run(true);
}
MOCK_METHOD0(OnExitPresent, void());
MOCK_METHOD1(OnVisibilityStateChanged, void(mojom::XRVisibilityState));
MOCK_METHOD1(OnDeviceIdle, void(mojom::VRDisplayEventReason));
MOCK_METHOD0(OnInitialized, void());
mojo::PendingAssociatedRemote<mojom::XRRuntimeEventListener>
BindPendingRemote() {
......@@ -127,24 +104,4 @@ TEST_F(VRDeviceTest, DeviceChangedDispatched) {
base::RunLoop().RunUntilIdle();
}
TEST_F(VRDeviceTest, DisplayActivateRegsitered) {
device::mojom::VRDisplayEventReason mounted =
device::mojom::VRDisplayEventReason::MOUNTED;
auto device = MakeVRDevice();
mojo::Remote<mojom::XRRuntime> device_remote(device->BindXRRuntime());
StubVRDeviceEventListener listener;
device_remote->ListenToDeviceChanges(
listener.BindPendingRemote(),
base::DoNothing()); // TODO: consider getting initial data
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(device->ListeningForActivate());
device->SetListeningForActivate(true);
EXPECT_TRUE(device->ListeningForActivate());
EXPECT_CALL(listener, DoOnDeviceActivated(mounted, testing::_)).Times(1);
device->FireDisplayActivate();
base::RunLoop().RunUntilIdle();
}
} // namespace device
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