proximity_monitor.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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
  3. // found in the LICENSE file.
  4. #ifndef ASH_COMPONENTS_PROXIMITY_AUTH_PROXIMITY_MONITOR_H_
  5. #define ASH_COMPONENTS_PROXIMITY_AUTH_PROXIMITY_MONITOR_H_
  6. #include "ash/components/proximity_auth/proximity_monitor_observer.h"
  7. #include "base/observer_list.h"
  8. namespace proximity_auth {
  9. // An interface that is responsible for tracking whether the remote device is
  10. // sufficiently close to the local device to permit unlocking.
  11. class ProximityMonitor {
  12. public:
  13. ProximityMonitor();
  14. virtual ~ProximityMonitor();
  15. void AddObserver(ProximityMonitorObserver* observer);
  16. void RemoveObserver(ProximityMonitorObserver* observer);
  17. // Activates the proximity monitor. No-op if the proximity monitor is already
  18. // active.
  19. virtual void Start() = 0;
  20. // Deactivates the proximity monitor. No-op if the proximity monitor is
  21. // already inactive.
  22. virtual void Stop() = 0;
  23. // Returns |true| iff the remote device is close enough to the local device,
  24. // given the user's current settings.
  25. virtual bool IsUnlockAllowed() const = 0;
  26. // Records the current proximity measurements to UMA. This should be called
  27. // when the user successfully authenticates using proximity auth.
  28. virtual void RecordProximityMetricsOnAuthSuccess() = 0;
  29. protected:
  30. void NotifyProximityStateChanged();
  31. private:
  32. // The observers attached to the ProximityMonitor.
  33. base::ObserverList<ProximityMonitorObserver>::Unchecked observers_;
  34. };
  35. } // namespace proximity_auth
  36. #endif // ASH_COMPONENTS_PROXIMITY_AUTH_PROXIMITY_MONITOR_H_