OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013 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 | |
5 #include "chrome/browser/themes/theme_service_aurax11.h" | |
6 | |
7 #include "base/bind.h" | |
8 #include "base/prefs/pref_service.h" | |
9 #include "chrome/browser/profiles/profile.h" | |
10 #include "chrome/common/pref_names.h" | |
11 #include "ui/gfx/image/image.h" | |
12 #include "ui/linux_ui/linux_ui.h" | |
13 | |
14 ThemeServiceAuraX11::ThemeServiceAuraX11() | |
15 : ThemeService(), | |
Evan Stade
2013/06/20 22:24:35
is this necessary?
| |
16 use_system_theme_(false) { | |
17 } | |
18 | |
19 ThemeServiceAuraX11::~ThemeServiceAuraX11() { | |
Evan Stade
2013/06/20 22:24:35
{} on one line
| |
20 } | |
21 | |
22 void ThemeServiceAuraX11::Init(Profile* profile) { | |
23 registrar_.Init(profile->GetPrefs()); | |
24 registrar_.Add(prefs::kUsesSystemTheme, | |
25 base::Bind(&ThemeServiceAuraX11::OnUsesSystemThemeChanged, | |
26 base::Unretained(this))); | |
27 use_system_theme_ = profile->GetPrefs()->GetBoolean(prefs::kUsesSystemTheme); | |
28 | |
29 ThemeService::Init(profile); | |
30 } | |
31 | |
32 gfx::Image ThemeServiceAuraX11::GetImageNamed(int id) const { | |
33 const ui::LinuxUI* linux_ui = ui::LinuxUI::instance(); | |
34 if (use_system_theme_ && linux_ui) { | |
35 gfx::Image image = linux_ui->GetThemeImageNamed(id); | |
36 if (!image.IsEmpty()) | |
37 return image; | |
38 } | |
39 | |
40 return ThemeService::GetImageNamed(id); | |
41 } | |
42 | |
43 SkColor ThemeServiceAuraX11::GetColor(int id) const { | |
44 const ui::LinuxUI* linux_ui = ui::LinuxUI::instance(); | |
45 SkColor color; | |
46 if (use_system_theme_ && linux_ui && linux_ui->GetColor(id, &color)) | |
47 return color; | |
48 | |
49 return ThemeService::GetColor(id); | |
50 } | |
51 | |
52 bool ThemeServiceAuraX11::HasCustomImage(int id) const { | |
53 const ui::LinuxUI* linux_ui = ui::LinuxUI::instance(); | |
54 if (use_system_theme_ && linux_ui) | |
55 return linux_ui->HasCustomImage(id); | |
56 | |
57 return ThemeService::HasCustomImage(id); | |
58 } | |
59 | |
60 void ThemeServiceAuraX11::SetTheme(const extensions::Extension* extension) { | |
61 profile()->GetPrefs()->SetBoolean(prefs::kUsesSystemTheme, false); | |
62 ThemeService::SetTheme(extension); | |
63 } | |
64 | |
65 void ThemeServiceAuraX11::UseDefaultTheme() { | |
66 profile()->GetPrefs()->SetBoolean(prefs::kUsesSystemTheme, false); | |
67 ThemeService::UseDefaultTheme(); | |
68 } | |
69 | |
70 void ThemeServiceAuraX11::SetNativeTheme() { | |
71 profile()->GetPrefs()->SetBoolean(prefs::kUsesSystemTheme, true); | |
72 ClearAllThemeData(); | |
73 NotifyThemeChanged(); | |
74 } | |
75 | |
76 bool ThemeServiceAuraX11::UsingDefaultTheme() const { | |
77 return !use_system_theme_ && ThemeService::UsingDefaultTheme(); | |
78 } | |
79 | |
80 bool ThemeServiceAuraX11::UsingNativeTheme() const { | |
81 return use_system_theme_; | |
82 } | |
83 | |
84 void ThemeServiceAuraX11::OnUsesSystemThemeChanged() { | |
85 use_system_theme_ = | |
86 profile()->GetPrefs()->GetBoolean(prefs::kUsesSystemTheme); | |
87 } | |
OLD | NEW |