Index: device/vr/vr_device_manager.cc |
diff --git a/device/vr/vr_device_manager.cc b/device/vr/vr_device_manager.cc |
index a1d0144f0d93e356025cc69485026f9d8ee53d66..1f08be9c81e5dd884d8d945ed0e37ff3994549a8 100644 |
--- a/device/vr/vr_device_manager.cc |
+++ b/device/vr/vr_device_manager.cc |
@@ -24,7 +24,8 @@ VRDeviceManager* g_vr_device_manager = nullptr; |
VRDeviceManager::VRDeviceManager() |
: vr_initialized_(false), |
keep_alive_(false), |
- has_scheduled_poll_(false) { |
+ has_scheduled_poll_(false), |
+ has_activate_listeners_(false) { |
// Register VRDeviceProviders for the current platform |
#if defined(OS_ANDROID) |
RegisterProvider(base::MakeUnique<GvrDeviceProvider>()); |
@@ -80,6 +81,10 @@ void VRDeviceManager::RemoveService(VRServiceImpl* service) { |
device.second->RemoveService(service); |
} |
+ if (service->listening_for_activate()) { |
+ ListeningForActivateChanged(false); |
+ } |
+ |
if (services_.empty() && !keep_alive_) { |
// Delete the device manager when it has no active connections. |
delete g_vr_device_manager; |
@@ -117,6 +122,27 @@ unsigned int VRDeviceManager::GetNumberOfConnectedDevices() { |
return static_cast<unsigned int>(devices_.size()); |
} |
+void VRDeviceManager::ListeningForActivateChanged(bool listening) { |
+ DCHECK(thread_checker_.CalledOnValidThread()); |
+ |
+ bool activate_listeners = listening; |
+ if (!activate_listeners) { |
+ for (const auto& service : services_) { |
+ if (service->listening_for_activate()) { |
+ activate_listeners = true; |
+ break; |
+ } |
+ } |
+ } |
+ |
+ // Notify all the providers if this changes |
+ if (has_activate_listeners_ != activate_listeners) { |
+ has_activate_listeners_ = activate_listeners; |
+ for (const auto& provider : providers_) |
+ provider->SetListeningForActivate(has_activate_listeners_); |
+ } |
+} |
+ |
VRDevice* VRDeviceManager::GetDevice(unsigned int index) { |
DCHECK(thread_checker_.CalledOnValidThread()); |