| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef CONTENT_BROWSER_DEVICE_SENSORS_AMBIENT_LIGHT_MAC_H_ | 5 #ifndef DEVICE_GENERIC_SENSOR_AMBIENT_LIGHT_MAC_H_ |
| 6 #define CONTENT_BROWSER_DEVICE_SENSORS_AMBIENT_LIGHT_MAC_H_ | 6 #define DEVICE_GENERIC_SENSOR_AMBIENT_LIGHT_MAC_H_ |
| 7 | 7 |
| 8 #include <IOKit/IOKitLib.h> | 8 #include <IOKit/IOKitLib.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <memory> | 11 #include <memory> |
| 12 | 12 |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 | 14 |
| 15 namespace content { | 15 namespace device { |
| 16 | 16 |
| 17 // Provides an interface to retrieve ambient light data from MacBooks. | 17 // Provides an interface to retrieve ambient light data from MacBooks. |
| 18 class AmbientLightSensor { | 18 class AmbientLightSensor { |
| 19 public: | 19 public: |
| 20 // Create AmbientLightSensor object, return NULL if no valid is sensor found. | 20 // Create AmbientLightSensor object, return NULL if no valid is sensor found. |
| 21 static std::unique_ptr<AmbientLightSensor> Create(); | 21 static std::unique_ptr<AmbientLightSensor> Create(); |
| 22 | 22 |
| 23 static double LMUvalueToLux(uint64_t raw_value); |
| 24 |
| 23 ~AmbientLightSensor(); | 25 ~AmbientLightSensor(); |
| 24 | 26 |
| 25 // Retrieve lux values from Ambient Light Sensor. | 27 // Retrieve lux values from Ambient Light Sensor. |
| 26 bool ReadSensorValue(uint64_t lux_value[2]); | 28 bool ReadSensorValue(uint64_t lux_value[2]); |
| 27 | 29 |
| 28 private: | 30 private: |
| 29 AmbientLightSensor(); | 31 AmbientLightSensor(); |
| 30 | 32 |
| 31 // Probe the local hardware looking for Ambient Light sensor and | 33 // Probe the local hardware looking for Ambient Light sensor and |
| 32 // initialize an I/O connection to it. | 34 // initialize an I/O connection to it. |
| 33 bool Init(); | 35 bool Init(); |
| 34 | 36 |
| 35 // IOKit connection to the local sensor. | 37 // IOKit connection to the local sensor. |
| 36 io_connect_t io_connection_; | 38 io_connect_t io_connection_; |
| 37 | 39 |
| 38 DISALLOW_COPY_AND_ASSIGN(AmbientLightSensor); | 40 DISALLOW_COPY_AND_ASSIGN(AmbientLightSensor); |
| 39 }; | 41 }; |
| 40 | 42 |
| 41 } // namespace content | 43 } // namespace device |
| 42 | 44 |
| 43 #endif // CONTENT_BROWSER_DEVICE_SENSORS_AMBIENT_LIGHT_MAC_H_ | 45 #endif // DEVICE_GENERIC_SENSOR_AMBIENT_LIGHT_MAC_H_ |
| OLD | NEW |