blob: 0f56a214311408e853314a5d282e9d3145556d24 [file] [log] [blame]
ishermanea464072015-06-19 21:56:341// 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
James Hawkins813085e2018-03-30 18:56:415#ifndef CHROMEOS_COMPONENTS_PROXIMITY_AUTH_PROXIMITY_MONITOR_H_
6#define CHROMEOS_COMPONENTS_PROXIMITY_AUTH_PROXIMITY_MONITOR_H_
ishermanea464072015-06-19 21:56:347
Ryan Hansberry0bc9cb62018-12-10 20:02:458#include "base/observer_list.h"
James Hawkins813085e2018-03-30 18:56:419#include "chromeos/components/proximity_auth/proximity_monitor_observer.h"
tengsae50e972015-10-02 04:00:4010
ishermanea464072015-06-19 21:56:3411namespace proximity_auth {
12
13// An interface that is responsible for tracking whether the remote device is
14// sufficiently close to the local device to permit unlocking.
15class ProximityMonitor {
16 public:
Ryan Hansberry0bc9cb62018-12-10 20:02:4517 ProximityMonitor();
18 virtual ~ProximityMonitor();
19
20 void AddObserver(ProximityMonitorObserver* observer);
21 void RemoveObserver(ProximityMonitorObserver* observer);
ishermanea464072015-06-19 21:56:3422
23 // Activates the proximity monitor. No-op if the proximity monitor is already
24 // active.
25 virtual void Start() = 0;
26
27 // Deactivates the proximity monitor. No-op if the proximity monitor is
28 // already inactive.
29 virtual void Stop() = 0;
30
ishermanea464072015-06-19 21:56:3431 // Returns |true| iff the remote device is close enough to the local device,
32 // given the user's current settings.
33 virtual bool IsUnlockAllowed() const = 0;
34
ishermanea464072015-06-19 21:56:3435 // Records the current proximity measurements to UMA. This should be called
36 // when the user successfully authenticates using proximity auth.
37 virtual void RecordProximityMetricsOnAuthSuccess() = 0;
tengsae50e972015-10-02 04:00:4038
Ryan Hansberry0bc9cb62018-12-10 20:02:4539 protected:
40 void NotifyProximityStateChanged();
tengsae50e972015-10-02 04:00:4041
Ryan Hansberry0bc9cb62018-12-10 20:02:4542 private:
43 // The observers attached to the ProximityMonitor.
44 base::ObserverList<ProximityMonitorObserver>::Unchecked observers_;
ishermanea464072015-06-19 21:56:3445};
46
47} // namespace proximity_auth
48
James Hawkins813085e2018-03-30 18:56:4149#endif // CHROMEOS_COMPONENTS_PROXIMITY_AUTH_PROXIMITY_MONITOR_H_