1// Copyright (c) 2011 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_CHROMEOS_CAMERA_DETECTOR_H_
6#define CHROME_BROWSER_CHROMEOS_CAMERA_DETECTOR_H_
7
8#include "base/callback.h"
9
10namespace chromeos {
11
12// Class used to check for camera presence.
13class CameraDetector {
14 public:
15  enum CameraPresence {
16    kCameraPresenceUnknown = 0,
17    kCameraAbsent,
18    kCameraPresent
19  };
20
21  // Returns result of the last presence check. If no check has been performed
22  // yet, returns |kCameraPresenceUnknown|.
23  static CameraPresence camera_presence() {
24    return camera_presence_;
25  }
26
27  // Checks asynchronously for camera device presence. Only one
28  // presence check can be running at a time. Calls |check_done|
29  // on current thread when the check has been completed.
30  static void StartPresenceCheck(const base::Closure& check_done);
31
32 private:
33  // Called back on UI thread after check has been performed.
34  static void OnPresenceCheckDone(const base::Closure& callback, bool present);
35
36  // Checks for camera presence. Runs on a thread that allows I/O.
37  static bool CheckPresence();
38
39  // Result of the last presence check.
40  static CameraPresence camera_presence_;
41
42  static bool presence_check_in_progress_;
43
44  DISALLOW_COPY_AND_ASSIGN(CameraDetector);
45};
46
47}  // namespace chromeos
48
49#endif  // CHROME_BROWSER_CHROMEOS_CAMERA_DETECTOR_H_
50