ash_color_provider_source.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright 2022 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_STYLE_ASH_COLOR_PROVIDER_SOURCE_H_
  5. #define ASH_STYLE_ASH_COLOR_PROVIDER_SOURCE_H_
  6. #include "ash/ash_export.h"
  7. #include "base/scoped_observation.h"
  8. #include "ui/color/color_provider_source.h"
  9. #include "ui/native_theme/native_theme.h"
  10. #include "ui/native_theme/native_theme_observer.h"
  11. namespace ash {
  12. // A ColorProviderSource used when we need to apply color on an object which is
  13. // not in the view hierarchy and there's no related widget anywhere we can plumb
  14. // across from.
  15. class ASH_EXPORT AshColorProviderSource : public ui::ColorProviderSource,
  16. public ui::NativeThemeObserver {
  17. public:
  18. AshColorProviderSource();
  19. AshColorProviderSource(const AshColorProviderSource&) = delete;
  20. AshColorProviderSource& operator=(const AshColorProviderSource&) = delete;
  21. ~AshColorProviderSource() override;
  22. // ui::ColorProviderSource:
  23. const ui::ColorProvider* GetColorProvider() const override;
  24. // ui::NativeThemeObserver:
  25. void OnNativeThemeUpdated(ui::NativeTheme* observed_theme) override;
  26. protected:
  27. // ui::ColorProviderSource:
  28. ui::ColorProviderManager::Key GetColorProviderKey() const override;
  29. private:
  30. base::ScopedObservation<ui::NativeTheme, ui::NativeThemeObserver>
  31. native_theme_observation_{this};
  32. };
  33. } // namespace ash
  34. #endif // ASH_STYLE_ASH_COLOR_PROVIDER_SOURCE_H_