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 #include "device/vr/android/gvr/gvr_device_provider.h" | 5 #include "device/vr/android/gvr/gvr_device_provider.h" |
6 | 6 |
7 #include <jni.h> | 7 #include <jni.h> |
8 | 8 |
9 #include "base/android/context_utils.h" | 9 #include "base/android/context_utils.h" |
10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 device::GvrDelegateProvider::GetInstance(); | 49 device::GvrDelegateProvider::GetInstance(); |
50 if (!delegate_provider) | 50 if (!delegate_provider) |
51 return; | 51 return; |
52 | 52 |
53 if (!vr_device_) { | 53 if (!vr_device_) { |
54 vr_device_.reset( | 54 vr_device_.reset( |
55 new GvrDevice(this, delegate_provider->GetNonPresentingDelegate())); | 55 new GvrDevice(this, delegate_provider->GetNonPresentingDelegate())); |
56 } | 56 } |
57 } | 57 } |
58 | 58 |
59 bool GvrDeviceProvider::RequestPresent() { | 59 void GvrDeviceProvider::RequestPresent( |
| 60 const base::Callback<void(bool)>& callback) { |
60 device::GvrDelegateProvider* delegate_provider = | 61 device::GvrDelegateProvider* delegate_provider = |
61 device::GvrDelegateProvider::GetInstance(); | 62 device::GvrDelegateProvider::GetInstance(); |
62 if (!delegate_provider) | 63 if (!delegate_provider) |
63 return false; | 64 return callback.Run(false); |
64 | 65 |
65 // RequestWebVRPresent is async as a render thread may be created. | 66 // RequestWebVRPresent is async as a render thread may be created. |
66 return delegate_provider->RequestWebVRPresent(weak_ptr_factory_.GetWeakPtr()); | 67 delegate_provider->RequestWebVRPresent(weak_ptr_factory_.GetWeakPtr(), |
| 68 callback); |
67 } | 69 } |
68 | 70 |
69 // VR presentation exit requested by the API. | 71 // VR presentation exit requested by the API. |
70 void GvrDeviceProvider::ExitPresent() { | 72 void GvrDeviceProvider::ExitPresent() { |
71 SwitchToNonPresentingDelegate(); | 73 SwitchToNonPresentingDelegate(); |
72 } | 74 } |
73 | 75 |
74 void GvrDeviceProvider::OnGvrDelegateReady( | 76 void GvrDeviceProvider::OnGvrDelegateReady( |
75 const base::WeakPtr<GvrDelegate>& delegate) { | 77 const base::WeakPtr<GvrDelegate>& delegate) { |
76 if (!vr_device_) | 78 if (!vr_device_) |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 | 112 |
111 // Remove GVR gamepad polling. | 113 // Remove GVR gamepad polling. |
112 GamepadDataFetcherManager::GetInstance()->RemoveSourceFactory( | 114 GamepadDataFetcherManager::GetInstance()->RemoveSourceFactory( |
113 GAMEPAD_SOURCE_GVR); | 115 GAMEPAD_SOURCE_GVR); |
114 | 116 |
115 // If we're presenting currently stop. | 117 // If we're presenting currently stop. |
116 delegate_provider->ExitWebVRPresent(); | 118 delegate_provider->ExitWebVRPresent(); |
117 } | 119 } |
118 | 120 |
119 } // namespace device | 121 } // namespace device |
OLD | NEW |