Commit 417f0e75 authored by Michael Thiessen's avatar Michael Thiessen Committed by Commit Bot

VR: Prevent WebVR from receiving poses while in VR browsing mode.

This CL is kept intentionally as simple as possible for merging back to
M-63.

Tests to prevent this regression in the future will be added in a
followup CL.

Bug: 775571
Change-Id: I78ea1e46efdb2b48bc61e1ab704b6b1526d2c171
Reviewed-on: https://chromium-review.googlesource.com/723770Reviewed-by: default avatarBrandon Jones <bajones@chromium.org>
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#509606}
parent 7a7f3d91
......@@ -79,6 +79,10 @@ VrShellDelegate* VrShellDelegate::GetNativeVrShellDelegate(
void VrShellDelegate::SetDelegate(VrShell* vr_shell,
gvr::ViewerType viewer_type) {
vr_shell_ = vr_shell;
device::GvrDevice* device = static_cast<device::GvrDevice*>(GetDevice());
if (device)
device->SetInBrowsingMode(true);
if (pending_successful_present_request_) {
CHECK(!present_callback_.is_null());
base::ResetAndReturn(&present_callback_).Run(true);
......@@ -90,9 +94,11 @@ void VrShellDelegate::SetDelegate(VrShell* vr_shell,
void VrShellDelegate::RemoveDelegate() {
vr_shell_ = nullptr;
device::VRDevice* device = GetDevice();
if (device)
device::GvrDevice* device = static_cast<device::GvrDevice*>(GetDevice());
if (device) {
device->SetInBrowsingMode(false);
device->OnExitPresent();
}
}
void VrShellDelegate::SetPresentResult(JNIEnv* env,
......@@ -170,6 +176,11 @@ void VrShellDelegate::Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj) {
void VrShellDelegate::SetDeviceId(unsigned int device_id) {
device_id_ = device_id;
if (vr_shell_) {
device::GvrDevice* device = static_cast<device::GvrDevice*>(GetDevice());
if (device)
device->SetInBrowsingMode(true);
}
}
void VrShellDelegate::RequestWebVRPresent(
......
......@@ -182,6 +182,10 @@ void GvrDevice::ExitPresent() {
void GvrDevice::GetPose(
mojom::VRMagicWindowProvider::GetPoseCallback callback) {
if (in_browsing_mode_) {
std::move(callback).Run(nullptr);
return;
}
std::move(callback).Run(
GvrDelegate::GetVRPosePtrWithNeckModel(gvr_api_.get(), nullptr));
}
......
......@@ -42,6 +42,11 @@ class DEVICE_VR_EXPORT GvrDevice : public VRDeviceBase {
void Activate(mojom::VRDisplayEventReason reason,
base::Callback<void(bool)> on_handled);
// TODO(mthiesse): Make this functionality cross-platform.
void SetInBrowsingMode(bool in_browsing_mode) {
in_browsing_mode_ = in_browsing_mode;
}
private:
void OnListeningForActivate(bool listening) override;
void OnRequestPresentResult(
......@@ -54,6 +59,7 @@ class DEVICE_VR_EXPORT GvrDevice : public VRDeviceBase {
base::android::ScopedJavaGlobalRef<jobject> non_presenting_context_;
std::unique_ptr<gvr::GvrApi> gvr_api_;
bool in_browsing_mode_ = false;
base::WeakPtrFactory<GvrDevice> weak_ptr_factory_;
......
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