1 // Copyright 2014 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.
5 #ifndef CHROME_BROWSER_CHROMEOS_CAMERA_PRESENCE_NOTIFIER_H_
6 #define CHROME_BROWSER_CHROMEOS_CAMERA_PRESENCE_NOTIFIER_H_
8 #include "base/memory/singleton.h"
9 #include "base/memory/weak_ptr.h"
10 #include "base/observer_list.h"
11 #include "base/timer/timer.h"
15 // Camera presence status dispatcher.
16 class CameraPresenceNotifier
{
20 virtual void OnCameraPresenceCheckDone(bool is_camera_present
) = 0;
22 virtual ~Observer() {}
25 static CameraPresenceNotifier
* GetInstance();
27 void AddObserver(CameraPresenceNotifier::Observer
* observer
);
28 void RemoveObserver(CameraPresenceNotifier::Observer
* observer
);
31 friend struct DefaultSingletonTraits
<CameraPresenceNotifier
>;
32 CameraPresenceNotifier();
33 ~CameraPresenceNotifier();
35 void CheckCameraPresence();
37 // Sends out a camera presence status notification.
38 void OnCameraPresenceCheckDone();
40 bool camera_present_on_last_check_
;
42 // Timer for camera check cycle.
43 base::RepeatingTimer
<CameraPresenceNotifier
> camera_check_timer_
;
45 ObserverList
<Observer
> observers_
;
47 base::WeakPtrFactory
<CameraPresenceNotifier
> weak_factory_
;
49 DISALLOW_COPY_AND_ASSIGN(CameraPresenceNotifier
);
52 } // namespace chromeos
54 #endif // CHROME_BROWSER_CHROMEOS_CAMERA_PRESENCE_NOTIFIER_H_