host_verifier.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // Copyright 2018 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_SERVICES_MULTIDEVICE_SETUP_HOST_VERIFIER_H_
  5. #define ASH_SERVICES_MULTIDEVICE_SETUP_HOST_VERIFIER_H_
  6. #include "base/observer_list.h"
  7. namespace ash {
  8. namespace multidevice_setup {
  9. // Verifies that this device can connect to the currently-set MultiDevice host.
  10. // In order for a host device to be considered set, its BETTER_TOGETHER_HOST
  11. // software feature must be enabled. In order for a host device to be
  12. // considered verified,
  13. // * at least one of its other host software features must be enabled, and
  14. // * the host device's public key, persistent symmetric key, and beacon
  15. // seeds--data necessary for Bluetooth communication with the MultiDevice
  16. // client--must be available.
  17. //
  18. // HostVerifier waits for that situation to occur and has the ability (via its
  19. // AttemptVerificationNow() function) to send a tickle message to the phone to
  20. // ask it to enable its software features.
  21. class HostVerifier {
  22. public:
  23. class Observer {
  24. public:
  25. virtual ~Observer() = default;
  26. virtual void OnHostVerified() = 0;
  27. };
  28. HostVerifier(const HostVerifier&) = delete;
  29. HostVerifier& operator=(const HostVerifier&) = delete;
  30. virtual ~HostVerifier();
  31. // Returns whether verification for the current MultiDevice host device has
  32. // completed (see description above). If no MultiDevice host is set at all,
  33. // false is returned.
  34. virtual bool IsHostVerified() = 0;
  35. // Attempts the verification flow; successful completion of the flow is
  36. // communicated via the OnHostVerified() delegate callback.
  37. void AttemptVerificationNow();
  38. void AddObserver(Observer* observer);
  39. void RemoveObserver(Observer* observer);
  40. protected:
  41. HostVerifier();
  42. virtual void PerformAttemptVerificationNow() = 0;
  43. void NotifyHostVerified();
  44. private:
  45. base::ObserverList<Observer>::Unchecked observer_list_;
  46. };
  47. } // namespace multidevice_setup
  48. } // namespace ash
  49. #endif // ASH_SERVICES_MULTIDEVICE_SETUP_HOST_VERIFIER_H_