account_status_change_delegate_notifier.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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_ACCOUNT_STATUS_CHANGE_DELEGATE_NOTIFIER_H_
  5. #define ASH_SERVICES_MULTIDEVICE_SETUP_ACCOUNT_STATUS_CHANGE_DELEGATE_NOTIFIER_H_
  6. #include "ash/services/multidevice_setup/public/mojom/multidevice_setup.mojom.h"
  7. #include "mojo/public/cpp/bindings/pending_remote.h"
  8. #include "mojo/public/cpp/bindings/remote.h"
  9. namespace ash {
  10. namespace multidevice_setup {
  11. // Notifies the delegate of MultiDeviceSetup for each of the following changes:
  12. // (1) a potential host is found for someone who has not gone through the setup
  13. // flow before,
  14. // (2) the host has switched for someone who has, or
  15. // (3) a new Chromebook has been added to an account for someone who has.
  16. class AccountStatusChangeDelegateNotifier {
  17. public:
  18. AccountStatusChangeDelegateNotifier(
  19. const AccountStatusChangeDelegateNotifier&) = delete;
  20. AccountStatusChangeDelegateNotifier& operator=(
  21. const AccountStatusChangeDelegateNotifier&) = delete;
  22. virtual ~AccountStatusChangeDelegateNotifier();
  23. void SetAccountStatusChangeDelegateRemote(
  24. mojo::PendingRemote<mojom::AccountStatusChangeDelegate> delegate_remote);
  25. protected:
  26. AccountStatusChangeDelegateNotifier();
  27. // Derived classes should override this function to be alerted when
  28. // SetAccountStatusChangeDelegateRemote() is called.
  29. virtual void OnDelegateSet();
  30. mojom::AccountStatusChangeDelegate* delegate() {
  31. return delegate_remote_.is_bound() ? delegate_remote_.get() : nullptr;
  32. }
  33. private:
  34. friend class MultiDeviceSetupImpl;
  35. friend class MultiDeviceSetupAccountStatusChangeDelegateNotifierTest;
  36. friend class MultiDeviceSetupImplTest;
  37. friend class MultiDeviceSetupWifiSyncNotificationControllerTest;
  38. friend class WifiSyncNotificationController;
  39. void FlushForTesting();
  40. mojo::Remote<mojom::AccountStatusChangeDelegate> delegate_remote_;
  41. };
  42. } // namespace multidevice_setup
  43. } // namespace ash
  44. #endif // ASH_SERVICES_MULTIDEVICE_SETUP_ACCOUNT_STATUS_CHANGE_DELEGATE_NOTIFIER_H_