| Index: chrome/browser/android/vr_shell/vr_shell_delegate.cc
|
| diff --git a/chrome/browser/android/vr_shell/vr_shell_delegate.cc b/chrome/browser/android/vr_shell/vr_shell_delegate.cc
|
| index cd01c36309d3b1f1be210be0c199200019a69616..850f8311fe5d820326e8e7b940835e9730e7d714 100644
|
| --- a/chrome/browser/android/vr_shell/vr_shell_delegate.cc
|
| +++ b/chrome/browser/android/vr_shell/vr_shell_delegate.cc
|
| @@ -63,22 +63,34 @@ base::WeakPtr<device::GvrDeviceProvider> VrShellDelegate::GetDeviceProvider() {
|
| return device_provider_;
|
| }
|
|
|
| -bool VrShellDelegate::RequestWebVRPresent(
|
| - base::WeakPtr<device::GvrDeviceProvider> device_provider) {
|
| - // Only set one device provider at a time
|
| - DCHECK(!device_provider_);
|
| +void VrShellDelegate::SetPresentResult(JNIEnv* env, jobject obj,
|
| + jboolean result) {
|
| + CHECK(!present_callback_.is_null());
|
| + present_callback_.Run(result);
|
| + present_callback_.Reset();
|
| +}
|
| +
|
| +void VrShellDelegate::RequestWebVRPresent(
|
| + base::WeakPtr<device::GvrDeviceProvider> device_provider,
|
| + const base::Callback<void(bool)>& callback) {
|
| + if (!present_callback_.is_null()) {
|
| + // Can only handle one request at a time. This is also extremely unlikely to
|
| + // happen in practice.
|
| + callback.Run(false);
|
| + return;
|
| + }
|
| +
|
| + // TODO(mthiesse): Clean this up, there's no reason to be setting the device
|
| + // provider from RequestWebVRPresent.
|
| device_provider_ = device_provider;
|
| + present_callback_ = std::move(callback);
|
|
|
| - // If/When VRShell is ready for use it will call OnVrShellReady.
|
| + // If/When VRShell is ready for use it will call SetPresentResult.
|
| JNIEnv* env = AttachCurrentThread();
|
| - Java_VrShellDelegate_enterVRIfNecessary(env, j_vr_shell_delegate_.obj(),
|
| - true);
|
| - return true;
|
| + Java_VrShellDelegate_presentRequested(env, j_vr_shell_delegate_.obj(), true);
|
| }
|
|
|
| void VrShellDelegate::ExitWebVRPresent() {
|
| - device_provider_.reset();
|
| -
|
| // VRShell is no longer needed by WebVR, allow it to shut down if it's not
|
| // being used elsewhere.
|
| JNIEnv* env = AttachCurrentThread();
|
|
|