native_theme_cache.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 CHROMEOS_LACROS_NATIVE_THEME_CACHE_H_
  5. #define CHROMEOS_LACROS_NATIVE_THEME_CACHE_H_
  6. #include "chromeos/crosapi/mojom/native_theme.mojom.h"
  7. #include "mojo/public/cpp/bindings/receiver.h"
  8. namespace chromeos {
  9. // This instance connects to ash-chrome, listens to native theme info changes,
  10. // and caches the info for later synchronous reads using getters.
  11. class COMPONENT_EXPORT(CHROMEOS_LACROS) NativeThemeCache
  12. : public crosapi::mojom::NativeThemeInfoObserver {
  13. public:
  14. explicit NativeThemeCache(const crosapi::mojom::NativeThemeInfo& info);
  15. NativeThemeCache(const NativeThemeCache&) = delete;
  16. NativeThemeCache& operator=(const NativeThemeCache&) = delete;
  17. ~NativeThemeCache() override;
  18. // Start observing native theme info changes in ash-chrome.
  19. // This is a post-construction step to decouple from LacrosService.
  20. void Start();
  21. private:
  22. // crosapi::mojom::NativeThemeInfoObserver:
  23. void OnNativeThemeInfoChanged(
  24. crosapi::mojom::NativeThemeInfoPtr info) override;
  25. void SetNativeThemeInfo();
  26. // Cached native theme info.
  27. crosapi::mojom::NativeThemeInfoPtr info_;
  28. // Receives mojo messages from ash-chromem (under Streaming mode).
  29. mojo::Receiver<crosapi::mojom::NativeThemeInfoObserver> receiver_{this};
  30. };
  31. } // namespace chromeos
  32. #endif // CHROMEOS_LACROS_NATIVE_THEME_CACHE_H_