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 3a4e46942bbac967dbaf5b03ab8acdcdde500c27..9648346b2cca9cf4446f5d5f8ffc70fe15d07579 100644 |
--- a/chrome/browser/android/vr_shell/vr_shell_delegate.cc |
+++ b/chrome/browser/android/vr_shell/vr_shell_delegate.cc |
@@ -125,6 +125,12 @@ void VrShellDelegate::ShowTab(int id) { |
void VrShellDelegate::SetDeviceProvider( |
device::GvrDeviceProvider* device_provider) { |
+ JNIEnv* env = AttachCurrentThread(); |
+ bool vrCorecompatible = static_cast<bool>( |
+ Java_VrShellDelegate_isVrCoreCompatible(env, j_vr_shell_delegate_.obj())); |
+ if (!vrCorecompatible) |
+ return; |
+ |
CHECK(!device_provider_); |
device_provider_ = device_provider; |
if (!delegate_) |
@@ -133,11 +139,14 @@ void VrShellDelegate::SetDeviceProvider( |
} |
void VrShellDelegate::ClearDeviceProvider() { |
- non_presenting_delegate_ = nullptr; |
- JNIEnv* env = AttachCurrentThread(); |
- Java_VrShellDelegate_shutdownNonPresentingNativeContext( |
- env, j_vr_shell_delegate_.obj()); |
- device_provider_->Device()->OnDelegateChanged(); |
+ // Clean up the non-presenting delegate. |
+ if (non_presenting_delegate_) { |
+ non_presenting_delegate_ = nullptr; |
+ JNIEnv* env = AttachCurrentThread(); |
+ Java_VrShellDelegate_shutdownNonPresentingNativeContext( |
+ env, j_vr_shell_delegate_.obj()); |
+ device_provider_->Device()->OnDelegateChanged(); |
+ } |
device_provider_ = nullptr; |
} |