| 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 16 matching lines...) Expand all Loading... |
| 27 device::GvrDelegateProvider* delegate_provider = | 27 device::GvrDelegateProvider* delegate_provider = |
| 28 device::GvrDelegateProvider::GetInstance(); | 28 device::GvrDelegateProvider::GetInstance(); |
| 29 if (delegate_provider) { | 29 if (delegate_provider) { |
| 30 delegate_provider->ExitWebVRPresent(); | 30 delegate_provider->ExitWebVRPresent(); |
| 31 delegate_provider->ClearDeviceProvider(); | 31 delegate_provider->ClearDeviceProvider(); |
| 32 } | 32 } |
| 33 } | 33 } |
| 34 | 34 |
| 35 void GvrDeviceProvider::GetDevices(std::vector<VRDevice*>* devices) { | 35 void GvrDeviceProvider::GetDevices(std::vector<VRDevice*>* devices) { |
| 36 Initialize(); | 36 Initialize(); |
| 37 devices->push_back(vr_device_.get()); | 37 if (initialized_) |
| 38 devices->push_back(vr_device_.get()); |
| 38 } | 39 } |
| 39 | 40 |
| 40 void GvrDeviceProvider::Initialize() { | 41 void GvrDeviceProvider::Initialize() { |
| 41 // TODO(mthiesse): Clean up how we connect the GvrDelegateProvider to the | 42 // TODO(mthiesse): Clean up how we connect the GvrDelegateProvider to the |
| 42 // GvrDeviceProvider so we don't have to call this function multiple times. | 43 // GvrDeviceProvider so we don't have to call this function multiple times. |
| 43 // Ideally the DelegateProvider would always be available, and GetInstance() | 44 // Ideally the DelegateProvider would always be available, and GetInstance() |
| 44 // would create it. | 45 // would create it. |
| 45 if (initialized_) | 46 if (initialized_) |
| 46 return; | 47 return; |
| 47 device::GvrDelegateProvider* delegate_provider = | 48 device::GvrDelegateProvider* delegate_provider = |
| (...skipping 29 matching lines...) Expand all Loading... |
| 77 Initialize(); | 78 Initialize(); |
| 78 device::GvrDelegateProvider* delegate_provider = | 79 device::GvrDelegateProvider* delegate_provider = |
| 79 device::GvrDelegateProvider::GetInstance(); | 80 device::GvrDelegateProvider::GetInstance(); |
| 80 if (!delegate_provider) | 81 if (!delegate_provider) |
| 81 return; | 82 return; |
| 82 | 83 |
| 83 delegate_provider->SetListeningForActivate(listening); | 84 delegate_provider->SetListeningForActivate(listening); |
| 84 } | 85 } |
| 85 | 86 |
| 86 } // namespace device | 87 } // namespace device |
| OLD | NEW |