Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1861)

Unified Diff: chrome/browser/android/vr_shell/vr_shell_delegate.cc

Issue 2701523008: Intercept WebVR api calls and check for VrCore compatibility. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
}

Powered by Google App Engine
This is Rietveld 408576698