ui_broker_impl.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright 2021 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_QUICK_PAIR_UI_UI_BROKER_IMPL_H_
  5. #define ASH_QUICK_PAIR_UI_UI_BROKER_IMPL_H_
  6. #include <memory>
  7. #include "ash/quick_pair/ui/actions.h"
  8. #include "ash/quick_pair/ui/ui_broker.h"
  9. #include "base/memory/weak_ptr.h"
  10. #include "base/observer_list.h"
  11. namespace ash {
  12. namespace quick_pair {
  13. class FastPairPresenter;
  14. struct Device;
  15. class UIBrokerImpl final : public UIBroker {
  16. public:
  17. UIBrokerImpl();
  18. UIBrokerImpl(const UIBrokerImpl&) = delete;
  19. UIBrokerImpl& operator=(const UIBrokerImpl&) = delete;
  20. ~UIBrokerImpl() override;
  21. // UIBroker:
  22. void AddObserver(Observer* observer) override;
  23. void RemoveObserver(Observer* observer) override;
  24. void ShowDiscovery(scoped_refptr<Device> device) override;
  25. void ShowPairing(scoped_refptr<Device> device) override;
  26. void ShowPairingFailed(scoped_refptr<Device> device) override;
  27. void ShowAssociateAccount(scoped_refptr<Device> device) override;
  28. void ShowCompanionApp(scoped_refptr<Device> device) override;
  29. void RemoveNotifications() override;
  30. private:
  31. void NotifyDiscoveryAction(scoped_refptr<Device> device,
  32. DiscoveryAction action);
  33. void NotifyPairingFailedAction(scoped_refptr<Device> device,
  34. PairingFailedAction action);
  35. void NotifyAssociateAccountAction(scoped_refptr<Device> device,
  36. AssociateAccountAction action);
  37. void NotifyCompanionAppAction(scoped_refptr<Device> device,
  38. CompanionAppAction action);
  39. std::unique_ptr<FastPairPresenter> fast_pair_presenter_;
  40. base::ObserverList<Observer> observers_;
  41. base::WeakPtrFactory<UIBrokerImpl> weak_pointer_factory_{this};
  42. };
  43. } // namespace quick_pair
  44. } // namespace ash
  45. #endif // ASH_QUICK_PAIR_UI_UI_BROKER_IMPL_H_