isherman | ea46407 | 2015-06-19 21:56:34 | [diff] [blame] | 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 | |
James Hawkins | 813085e | 2018-03-30 18:56:41 | [diff] [blame] | 5 | #ifndef CHROMEOS_COMPONENTS_PROXIMITY_AUTH_PROXIMITY_MONITOR_H_ |
| 6 | #define CHROMEOS_COMPONENTS_PROXIMITY_AUTH_PROXIMITY_MONITOR_H_ |
isherman | ea46407 | 2015-06-19 21:56:34 | [diff] [blame] | 7 | |
Ryan Hansberry | 0bc9cb6 | 2018-12-10 20:02:45 | [diff] [blame] | 8 | #include "base/observer_list.h" |
James Hawkins | 813085e | 2018-03-30 18:56:41 | [diff] [blame] | 9 | #include "chromeos/components/proximity_auth/proximity_monitor_observer.h" |
tengs | ae50e97 | 2015-10-02 04:00:40 | [diff] [blame] | 10 | |
isherman | ea46407 | 2015-06-19 21:56:34 | [diff] [blame] | 11 | namespace 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. |
| 15 | class ProximityMonitor { |
| 16 | public: |
Ryan Hansberry | 0bc9cb6 | 2018-12-10 20:02:45 | [diff] [blame] | 17 | ProximityMonitor(); |
| 18 | virtual ~ProximityMonitor(); |
| 19 | |
| 20 | void AddObserver(ProximityMonitorObserver* observer); |
| 21 | void RemoveObserver(ProximityMonitorObserver* observer); |
isherman | ea46407 | 2015-06-19 21:56:34 | [diff] [blame] | 22 | |
| 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 | |
isherman | ea46407 | 2015-06-19 21:56:34 | [diff] [blame] | 31 | // 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 | |
isherman | ea46407 | 2015-06-19 21:56:34 | [diff] [blame] | 35 | // 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; |
tengs | ae50e97 | 2015-10-02 04:00:40 | [diff] [blame] | 38 | |
Ryan Hansberry | 0bc9cb6 | 2018-12-10 20:02:45 | [diff] [blame] | 39 | protected: |
| 40 | void NotifyProximityStateChanged(); |
tengs | ae50e97 | 2015-10-02 04:00:40 | [diff] [blame] | 41 | |
Ryan Hansberry | 0bc9cb6 | 2018-12-10 20:02:45 | [diff] [blame] | 42 | private: |
| 43 | // The observers attached to the ProximityMonitor. |
| 44 | base::ObserverList<ProximityMonitorObserver>::Unchecked observers_; |
isherman | ea46407 | 2015-06-19 21:56:34 | [diff] [blame] | 45 | }; |
| 46 | |
| 47 | } // namespace proximity_auth |
| 48 | |
James Hawkins | 813085e | 2018-03-30 18:56:41 | [diff] [blame] | 49 | #endif // CHROMEOS_COMPONENTS_PROXIMITY_AUTH_PROXIMITY_MONITOR_H_ |