| 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 "services/device/device_service.h" | 5 #include "services/device/device_service.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/feature_list.h" |
| 10 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 11 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 12 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 13 #include "base/threading/thread_task_runner_handle.h" | 14 #include "base/threading/thread_task_runner_handle.h" |
| 14 #include "device/battery/battery_monitor.mojom.h" | 15 #include "device/battery/battery_monitor.mojom.h" |
| 15 #include "device/battery/battery_monitor_impl.h" | 16 #include "device/battery/battery_monitor_impl.h" |
| 16 #include "device/battery/battery_status_service.h" | 17 #include "device/battery/battery_status_service.h" |
| 18 #include "device/generic_sensor/sensor_provider_impl.h" |
| 17 #include "device/sensors/device_sensor_host.h" | 19 #include "device/sensors/device_sensor_host.h" |
| 18 #include "device/wake_lock/wake_lock_context_provider.h" | 20 #include "device/wake_lock/wake_lock_context_provider.h" |
| 19 #include "mojo/public/cpp/system/message_pipe.h" | 21 #include "mojo/public/cpp/system/message_pipe.h" |
| 20 #include "services/device/fingerprint/fingerprint.h" | 22 #include "services/device/fingerprint/fingerprint.h" |
| 21 #include "services/device/power_monitor/power_monitor_message_broadcaster.h" | 23 #include "services/device/power_monitor/power_monitor_message_broadcaster.h" |
| 24 #include "services/device/public/cpp/device_features.h" |
| 22 #include "services/device/time_zone_monitor/time_zone_monitor.h" | 25 #include "services/device/time_zone_monitor/time_zone_monitor.h" |
| 23 #include "services/service_manager/public/cpp/connection.h" | 26 #include "services/service_manager/public/cpp/connection.h" |
| 24 #include "services/service_manager/public/cpp/interface_registry.h" | 27 #include "services/service_manager/public/cpp/interface_registry.h" |
| 25 #include "services/service_manager/public/cpp/service_info.h" | 28 #include "services/service_manager/public/cpp/service_info.h" |
| 26 #include "ui/gfx/native_widget_types.h" | 29 #include "ui/gfx/native_widget_types.h" |
| 27 | 30 |
| 28 #if defined(OS_ANDROID) | 31 #if defined(OS_ANDROID) |
| 29 #include "base/android/context_utils.h" | 32 #include "base/android/context_utils.h" |
| 30 #include "base/android/jni_android.h" | 33 #include "base/android/jni_android.h" |
| 31 #include "jni/InterfaceRegistrar_jni.h" | 34 #include "jni/InterfaceRegistrar_jni.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 90 |
| 88 bool DeviceService::OnConnect(const service_manager::ServiceInfo& remote_info, | 91 bool DeviceService::OnConnect(const service_manager::ServiceInfo& remote_info, |
| 89 service_manager::InterfaceRegistry* registry) { | 92 service_manager::InterfaceRegistry* registry) { |
| 90 registry->AddInterface<mojom::Fingerprint>(this); | 93 registry->AddInterface<mojom::Fingerprint>(this); |
| 91 registry->AddInterface<mojom::LightSensor>(this); | 94 registry->AddInterface<mojom::LightSensor>(this); |
| 92 registry->AddInterface<mojom::MotionSensor>(this); | 95 registry->AddInterface<mojom::MotionSensor>(this); |
| 93 registry->AddInterface<mojom::OrientationSensor>(this); | 96 registry->AddInterface<mojom::OrientationSensor>(this); |
| 94 registry->AddInterface<mojom::OrientationAbsoluteSensor>(this); | 97 registry->AddInterface<mojom::OrientationAbsoluteSensor>(this); |
| 95 registry->AddInterface<mojom::PowerMonitor>(this); | 98 registry->AddInterface<mojom::PowerMonitor>(this); |
| 96 registry->AddInterface<mojom::ScreenOrientationListener>(this); | 99 registry->AddInterface<mojom::ScreenOrientationListener>(this); |
| 100 if (base::FeatureList::IsEnabled(features::kGenericSensor)) { |
| 101 registry->AddInterface<mojom::SensorProvider>(this); |
| 102 } |
| 97 registry->AddInterface<mojom::TimeZoneMonitor>(this); | 103 registry->AddInterface<mojom::TimeZoneMonitor>(this); |
| 98 registry->AddInterface<mojom::WakeLockContextProvider>(this); | 104 registry->AddInterface<mojom::WakeLockContextProvider>(this); |
| 99 | 105 |
| 100 #if defined(OS_ANDROID) | 106 #if defined(OS_ANDROID) |
| 101 registry->AddInterface( | 107 registry->AddInterface( |
| 102 GetJavaInterfaceProvider()->CreateInterfaceFactory<BatteryMonitor>()); | 108 GetJavaInterfaceProvider()->CreateInterfaceFactory<BatteryMonitor>()); |
| 103 registry->AddInterface( | 109 registry->AddInterface( |
| 104 GetJavaInterfaceProvider() | 110 GetJavaInterfaceProvider() |
| 105 ->CreateInterfaceFactory<mojom::VibrationManager>()); | 111 ->CreateInterfaceFactory<mojom::VibrationManager>()); |
| 106 #else | 112 #else |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 #if defined(OS_ANDROID) | 214 #if defined(OS_ANDROID) |
| 209 if (io_task_runner_) { | 215 if (io_task_runner_) { |
| 210 io_task_runner_->PostTask( | 216 io_task_runner_->PostTask( |
| 211 FROM_HERE, base::Bind(&ScreenOrientationListenerAndroid::Create, | 217 FROM_HERE, base::Bind(&ScreenOrientationListenerAndroid::Create, |
| 212 base::Passed(&request))); | 218 base::Passed(&request))); |
| 213 } | 219 } |
| 214 #endif | 220 #endif |
| 215 } | 221 } |
| 216 | 222 |
| 217 void DeviceService::Create(const service_manager::Identity& remote_identity, | 223 void DeviceService::Create(const service_manager::Identity& remote_identity, |
| 224 mojom::SensorProviderRequest request) { |
| 225 if (io_task_runner_) { |
| 226 io_task_runner_->PostTask( |
| 227 FROM_HERE, base::Bind(&device::SensorProviderImpl::Create, |
| 228 file_task_runner_, base::Passed(&request))); |
| 229 } |
| 230 } |
| 231 |
| 232 void DeviceService::Create(const service_manager::Identity& remote_identity, |
| 218 mojom::TimeZoneMonitorRequest request) { | 233 mojom::TimeZoneMonitorRequest request) { |
| 219 if (!time_zone_monitor_) | 234 if (!time_zone_monitor_) |
| 220 time_zone_monitor_ = TimeZoneMonitor::Create(file_task_runner_); | 235 time_zone_monitor_ = TimeZoneMonitor::Create(file_task_runner_); |
| 221 time_zone_monitor_->Bind(std::move(request)); | 236 time_zone_monitor_->Bind(std::move(request)); |
| 222 } | 237 } |
| 223 | 238 |
| 224 void DeviceService::Create(const service_manager::Identity& remote_identity, | 239 void DeviceService::Create(const service_manager::Identity& remote_identity, |
| 225 mojom::WakeLockContextProviderRequest request) { | 240 mojom::WakeLockContextProviderRequest request) { |
| 226 WakeLockContextProvider::Create(std::move(request), file_task_runner_, | 241 WakeLockContextProvider::Create(std::move(request), file_task_runner_, |
| 227 wake_lock_context_callback_); | 242 wake_lock_context_callback_); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 238 java_interface_provider_.Bind(std::move(provider)); | 253 java_interface_provider_.Bind(std::move(provider)); |
| 239 | 254 |
| 240 java_interface_provider_initialized_ = true; | 255 java_interface_provider_initialized_ = true; |
| 241 } | 256 } |
| 242 | 257 |
| 243 return &java_interface_provider_; | 258 return &java_interface_provider_; |
| 244 } | 259 } |
| 245 #endif | 260 #endif |
| 246 | 261 |
| 247 } // namespace device | 262 } // namespace device |
| OLD | NEW |