summaryrefslogtreecommitdiffstats
path: root/content/browser/device_sensors/ambient_light_mac.h
blob: 8d34e165b80bc6c26da60dec1084fd0872c69352 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_BROWSER_DEVICE_SENSORS_AMBIENT_LIGHT_MAC_H_
#define CONTENT_BROWSER_DEVICE_SENSORS_AMBIENT_LIGHT_MAC_H_

#include <IOKit/IOKitLib.h>

#include "base/memory/scoped_ptr.h"

namespace content {

// Provides an interface to retrieve ambient light data from MacBooks.
class AmbientLightSensor {
 public:
  // Create AmbientLightSensor object, return NULL if no valid is sensor found.
  static scoped_ptr<AmbientLightSensor> Create();

  ~AmbientLightSensor();

  // Retrieve lux values from Ambient Light Sensor.
  bool ReadSensorValue(uint64_t lux_value[2]);

 private:
  AmbientLightSensor();

  // Probe the local hardware looking for Ambient Light sensor and
  // initialize an I/O connection to it.
  bool Init();

  // IOKit connection to the local sensor.
  io_connect_t io_connection_;

  DISALLOW_COPY_AND_ASSIGN(AmbientLightSensor);
};

}  // namespace content

#endif  // CONTENT_BROWSER_DEVICE_SENSORS_AMBIENT_LIGHT_MAC_H_