| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_DELEGATE_H_ | 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 | 9 |
| 10 #include "base/android/jni_weak_ref.h" | 10 #include "base/android/jni_weak_ref.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "device/vr/android/gvr/gvr_delegate.h" | 12 #include "device/vr/android/gvr/gvr_delegate.h" |
| 13 | 13 |
| 14 namespace device { |
| 15 class GvrDeviceProvider; |
| 16 } |
| 17 |
| 14 namespace vr_shell { | 18 namespace vr_shell { |
| 15 | 19 |
| 16 class VrShell; | 20 class VrShell; |
| 17 | 21 |
| 18 class VrShellDelegate : public device::GvrDelegateProvider { | 22 class VrShellDelegate : public device::GvrDelegateProvider { |
| 19 public: | 23 public: |
| 20 VrShellDelegate(JNIEnv* env, jobject obj); | 24 VrShellDelegate(JNIEnv* env, jobject obj); |
| 21 virtual ~VrShellDelegate(); | 25 virtual ~VrShellDelegate(); |
| 22 | 26 |
| 23 static VrShellDelegate* getNativeDelegate(JNIEnv* env, jobject jdelegate); | 27 static VrShellDelegate* GetNativeDelegate(JNIEnv* env, jobject jdelegate); |
| 28 |
| 29 base::WeakPtr<device::GvrDeviceProvider> GetDeviceProvider(); |
| 24 | 30 |
| 25 // Called by the Java VrShellDelegate. Returns true if the GvrDeviceProvider | 31 // Called by the Java VrShellDelegate. Returns true if the GvrDeviceProvider |
| 26 // needs to handle shutdown first. | 32 // needs to handle shutdown first. |
| 27 void ExitWebVRIfNecessary(JNIEnv* env, jobject obj); | 33 void ExitWebVRIfNecessary(JNIEnv* env, jobject obj); |
| 28 | 34 |
| 29 // device::vrDelegateProvider implementation | 35 // device::GvrDelegateProvider implementation |
| 30 bool RequestWebVRPresent(device::GvrDeviceProvider* device_provider) override; | 36 bool RequestWebVRPresent( |
| 37 base::WeakPtr<device::GvrDeviceProvider> device_provider) override; |
| 31 void ExitWebVRPresent() override; | 38 void ExitWebVRPresent() override; |
| 32 device::GvrDelegate* GetNonPresentingDelegate() override; | 39 base::WeakPtr<device::GvrDelegate> GetNonPresentingDelegate() override; |
| 33 void DestroyNonPresentingDelegate() override; | 40 void DestroyNonPresentingDelegate() override; |
| 34 | 41 |
| 35 // Called from VRShell | |
| 36 void OnVrShellReady(VrShell* vr_shell); | |
| 37 | |
| 38 private: | 42 private: |
| 39 std::unique_ptr<device::GvrDelegate> non_presenting_delegate_; | 43 std::unique_ptr<device::GvrDelegate> non_presenting_delegate_; |
| 40 base::android::ScopedJavaGlobalRef<jobject> j_vr_shell_delegate_; | 44 base::android::ScopedJavaGlobalRef<jobject> j_vr_shell_delegate_; |
| 41 device::GvrDeviceProvider* device_provider_; | 45 base::WeakPtr<device::GvrDeviceProvider> device_provider_; |
| 42 | 46 |
| 43 DISALLOW_COPY_AND_ASSIGN(VrShellDelegate); | 47 DISALLOW_COPY_AND_ASSIGN(VrShellDelegate); |
| 44 }; | 48 }; |
| 45 | 49 |
| 46 bool RegisterVrShellDelegate(JNIEnv* env); | 50 bool RegisterVrShellDelegate(JNIEnv* env); |
| 47 | 51 |
| 48 } // namespace vr_shell | 52 } // namespace vr_shell |
| 49 | 53 |
| 50 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_DELEGATE_H_ | 54 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_DELEGATE_H_ |
| OLD | NEW |