| 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 a25b6a513e19f90feaf80bb77c62485cb3b9d239..d7bf7dbbe33a4feb02a969ed7813579e035051e2 100644
|
| --- a/chrome/browser/android/vr_shell/vr_shell_delegate.cc
|
| +++ b/chrome/browser/android/vr_shell/vr_shell_delegate.cc
|
| @@ -21,16 +21,23 @@ namespace vr_shell {
|
| VrShellDelegate::VrShellDelegate(JNIEnv* env, jobject obj)
|
| : weak_ptr_factory_(this) {
|
| j_vr_shell_delegate_.Reset(env, obj);
|
| - GvrDelegateProvider::SetInstance(this);
|
| }
|
|
|
| VrShellDelegate::~VrShellDelegate() {
|
| - GvrDelegateProvider::SetInstance(nullptr);
|
| if (device_provider_) {
|
| device_provider_->Device()->OnDelegateChanged();
|
| }
|
| }
|
|
|
| +device::GvrDelegateProvider* VrShellDelegate::CreateVrShellDelegate() {
|
| + JNIEnv* env = AttachCurrentThread();
|
| + base::android::ScopedJavaLocalRef<jobject> jdelegate =
|
| + Java_VrShellDelegate_getInstance(env);
|
| + if (!jdelegate.is_null())
|
| + return GetNativeVrShellDelegate(env, jdelegate.obj());
|
| + return nullptr;
|
| +}
|
| +
|
| VrShellDelegate* VrShellDelegate::GetNativeVrShellDelegate(JNIEnv* env,
|
| jobject jdelegate) {
|
| return reinterpret_cast<VrShellDelegate*>(
|
| @@ -115,6 +122,10 @@ void VrShellDelegate::OnResume(JNIEnv* env, const JavaParamRef<jobject>& obj) {
|
| }
|
| }
|
|
|
| +void VrShellDelegate::Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj) {
|
| + delete this;
|
| +}
|
| +
|
| void VrShellDelegate::ShowTab(int id) {
|
| JNIEnv* env = AttachCurrentThread();
|
| Java_VrShellDelegate_showTab(env, j_vr_shell_delegate_.obj(), id);
|
| @@ -134,7 +145,6 @@ void VrShellDelegate::ClearDeviceProvider() {
|
| JNIEnv* env = AttachCurrentThread();
|
| Java_VrShellDelegate_shutdownNonPresentingNativeContext(
|
| env, j_vr_shell_delegate_.obj());
|
| - device_provider_->Device()->OnDelegateChanged();
|
| device_provider_ = nullptr;
|
| }
|
|
|
| @@ -208,4 +218,9 @@ jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) {
|
| return reinterpret_cast<intptr_t>(new VrShellDelegate(env, obj));
|
| }
|
|
|
| +static void OnLibraryAvailable(JNIEnv* env, const JavaParamRef<jclass>& clazz) {
|
| + device::GvrDelegateProvider::SetInstance(
|
| + base::Bind(&VrShellDelegate::CreateVrShellDelegate));
|
| +}
|
| +
|
| } // namespace vr_shell
|
|
|