OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/themes/theme_service_aurax11.h" | 5 #include "chrome/browser/themes/theme_service_aurax11.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/themes/custom_theme_supplier.h" | 10 #include "chrome/browser/themes/custom_theme_supplier.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 } | 57 } |
58 | 58 |
59 bool NativeThemeX11::HasCustomImage(int id) const { | 59 bool NativeThemeX11::HasCustomImage(int id) const { |
60 return linux_ui_ && linux_ui_->HasCustomImage(id); | 60 return linux_ui_ && linux_ui_->HasCustomImage(id); |
61 } | 61 } |
62 | 62 |
63 NativeThemeX11::~NativeThemeX11() {} | 63 NativeThemeX11::~NativeThemeX11() {} |
64 | 64 |
65 } // namespace | 65 } // namespace |
66 | 66 |
67 ThemeServiceAuraX11::ThemeServiceAuraX11() { | 67 ThemeServiceAuraX11::ThemeServiceAuraX11() {} |
68 views::LinuxUI* linux_ui = views::LinuxUI::instance(); | |
69 if (linux_ui) | |
70 linux_ui->AddNativeThemeChangeObserver(this); | |
71 } | |
72 | 68 |
73 ThemeServiceAuraX11::~ThemeServiceAuraX11() { | 69 ThemeServiceAuraX11::~ThemeServiceAuraX11() {} |
74 views::LinuxUI* linux_ui = views::LinuxUI::instance(); | |
75 if (linux_ui) | |
76 linux_ui->RemoveNativeThemeChangeObserver(this); | |
77 } | |
78 | 70 |
79 bool ThemeServiceAuraX11::ShouldInitWithNativeTheme() const { | 71 bool ThemeServiceAuraX11::ShouldInitWithNativeTheme() const { |
80 return profile()->GetPrefs()->GetBoolean(prefs::kUsesSystemTheme); | 72 return profile()->GetPrefs()->GetBoolean(prefs::kUsesSystemTheme); |
81 } | 73 } |
82 | 74 |
83 void ThemeServiceAuraX11::SetNativeTheme() { | 75 void ThemeServiceAuraX11::SetNativeTheme() { |
84 SetCustomDefaultTheme(new NativeThemeX11(profile()->GetPrefs())); | 76 SetCustomDefaultTheme(new NativeThemeX11(profile()->GetPrefs())); |
85 } | 77 } |
86 | 78 |
87 bool ThemeServiceAuraX11::UsingDefaultTheme() const { | 79 bool ThemeServiceAuraX11::UsingDefaultTheme() const { |
88 return ThemeService::UsingDefaultTheme() && !UsingNativeTheme(); | 80 return ThemeService::UsingDefaultTheme() && !UsingNativeTheme(); |
89 } | 81 } |
90 | 82 |
91 bool ThemeServiceAuraX11::UsingNativeTheme() const { | 83 bool ThemeServiceAuraX11::UsingNativeTheme() const { |
92 const CustomThemeSupplier* theme_supplier = get_theme_supplier(); | 84 const CustomThemeSupplier* theme_supplier = get_theme_supplier(); |
93 return theme_supplier && | 85 return theme_supplier && |
94 theme_supplier->get_theme_type() == CustomThemeSupplier::NATIVE_X11; | 86 theme_supplier->get_theme_type() == CustomThemeSupplier::NATIVE_X11; |
95 } | 87 } |
96 | |
97 void ThemeServiceAuraX11::OnNativeThemeChanged() { | |
98 if (UsingNativeTheme()) | |
99 NotifyThemeChanged(); | |
100 } | |
OLD | NEW |