ash_color_provider_source.cc 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  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. #include "ash/style/ash_color_provider_source.h"
  5. #include "ui/color/color_provider.h"
  6. namespace ash {
  7. AshColorProviderSource::AshColorProviderSource() {
  8. native_theme_observation_.Observe(ui::NativeTheme::GetInstanceForNativeUi());
  9. }
  10. AshColorProviderSource::~AshColorProviderSource() = default;
  11. const ui::ColorProvider* AshColorProviderSource::GetColorProvider() const {
  12. return ui::ColorProviderManager::Get().GetColorProviderFor(
  13. GetColorProviderKey());
  14. }
  15. void AshColorProviderSource::OnNativeThemeUpdated(
  16. ui::NativeTheme* observed_theme) {
  17. DCHECK(native_theme_observation_.IsObservingSource(observed_theme));
  18. NotifyColorProviderChanged();
  19. }
  20. ui::ColorProviderManager::Key AshColorProviderSource::GetColorProviderKey()
  21. const {
  22. return ui::NativeTheme::GetInstanceForNativeUi()->GetColorProviderKey(
  23. nullptr);
  24. }
  25. } // namespace ash