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

Side by Side Diff: chrome/browser/android/vr_shell/vr_shell_delegate.cc

Issue 2471433002: Implement WebVR presentation pausing for VR Shell Menu Mode (Closed)
Patch Set: Add comments to VRDisplay Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
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 #include "chrome/browser/android/vr_shell/vr_shell_delegate.h" 5 #include "chrome/browser/android/vr_shell/vr_shell_delegate.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "chrome/browser/android/vr_shell/vr_shell.h" 8 #include "chrome/browser/android/vr_shell/vr_shell.h"
9 #include "device/vr/android/gvr/gvr_device_provider.h"
9 #include "jni/VrShellDelegate_jni.h" 10 #include "jni/VrShellDelegate_jni.h"
10 11
11 using base::android::JavaParamRef; 12 using base::android::JavaParamRef;
12 using base::android::AttachCurrentThread; 13 using base::android::AttachCurrentThread;
13 14
14 namespace vr_shell { 15 namespace vr_shell {
15 16
16 // A non presenting delegate for magic window mode. 17 // A non presenting delegate for magic window mode.
17 class GvrNonPresentingDelegate : public device::GvrDelegate { 18 class GvrNonPresentingDelegate : public device::GvrDelegate {
18 public: 19 public:
(...skipping 23 matching lines...) Expand all
42 VrShellDelegate::VrShellDelegate(JNIEnv* env, jobject obj) 43 VrShellDelegate::VrShellDelegate(JNIEnv* env, jobject obj)
43 : device_provider_(nullptr) { 44 : device_provider_(nullptr) {
44 j_vr_shell_delegate_.Reset(env, obj); 45 j_vr_shell_delegate_.Reset(env, obj);
45 GvrDelegateProvider::SetInstance(this); 46 GvrDelegateProvider::SetInstance(this);
46 } 47 }
47 48
48 VrShellDelegate::~VrShellDelegate() { 49 VrShellDelegate::~VrShellDelegate() {
49 GvrDelegateProvider::SetInstance(nullptr); 50 GvrDelegateProvider::SetInstance(nullptr);
50 } 51 }
51 52
52 VrShellDelegate* VrShellDelegate::getNativeDelegate( 53 VrShellDelegate* VrShellDelegate::GetNativeDelegate(
53 JNIEnv* env, jobject jdelegate) { 54 JNIEnv* env, jobject jdelegate) {
54 long native_delegate = Java_VrShellDelegate_getNativePointer(env, jdelegate); 55 long native_delegate = Java_VrShellDelegate_getNativePointer(env, jdelegate);
55 return reinterpret_cast<VrShellDelegate*>(native_delegate); 56 return reinterpret_cast<VrShellDelegate*>(native_delegate);
56 } 57 }
57 58
59 scoped_refptr<device::GvrDeviceProvider> VrShellDelegate::GetDeviceProvider() {
60 return device_provider_;
61 }
62
58 void VrShellDelegate::ExitWebVRIfNecessary(JNIEnv* env, jobject obj) { 63 void VrShellDelegate::ExitWebVRIfNecessary(JNIEnv* env, jobject obj) {
59 if (!device_provider_) 64 if (!device_provider_)
60 return; 65 return;
61 66
62 device_provider_->OnGvrDelegateRemoved(); 67 device_provider_->OnGvrDelegateRemoved();
63 } 68 }
64 69
65 bool VrShellDelegate::RequestWebVRPresent( 70 bool VrShellDelegate::RequestWebVRPresent(
66 device::GvrDeviceProvider* device_provider) { 71 scoped_refptr<device::GvrDeviceProvider> device_provider) {
67 // Only set one device provider at a time 72 // Only set one device provider at a time
68 DCHECK(!device_provider_); 73 DCHECK(!device_provider_.get());
dcheng 2016/11/11 00:48:21 Nit: no .get()
mthiesse 2016/11/11 20:19:21 Done.
69 device_provider_ = device_provider; 74 device_provider_ = std::move(device_provider);
70 75
71 // If/When VRShell is ready for use it will call OnVrShellReady. 76 // If/When VRShell is ready for use it will call OnVrShellReady.
72 JNIEnv* env = AttachCurrentThread(); 77 JNIEnv* env = AttachCurrentThread();
73 return Java_VrShellDelegate_enterVRIfNecessary(env, 78 return Java_VrShellDelegate_enterVRIfNecessary(env,
74 j_vr_shell_delegate_.obj(), 79 j_vr_shell_delegate_.obj(),
75 true); 80 true);
76 } 81 }
77 82
78 void VrShellDelegate::ExitWebVRPresent() { 83 void VrShellDelegate::ExitWebVRPresent() {
79 if (!device_provider_) 84 if (!device_provider_)
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 123
119 bool RegisterVrShellDelegate(JNIEnv* env) { 124 bool RegisterVrShellDelegate(JNIEnv* env) {
120 return RegisterNativesImpl(env); 125 return RegisterNativesImpl(env);
121 } 126 }
122 127
123 jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { 128 jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) {
124 return reinterpret_cast<intptr_t>(new VrShellDelegate(env, obj)); 129 return reinterpret_cast<intptr_t>(new VrShellDelegate(env, obj));
125 } 130 }
126 131
127 } // namespace vr_shell 132 } // namespace vr_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698