Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: chrome/browser/themes/theme_service_aurax11.cc

Issue 244893004: Improve some naming (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: mac and win Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "chrome/common/pref_names.h" 11 #include "chrome/common/pref_names.h"
12 #include "ui/gfx/image/image.h" 12 #include "ui/gfx/image/image.h"
13 #include "ui/native_theme/native_theme_aura.h" 13 #include "ui/native_theme/native_theme_aura.h"
14 #include "ui/views/linux_ui/linux_ui.h" 14 #include "ui/views/linux_ui/linux_ui.h"
15 15
16 namespace { 16 namespace {
17 17
18 class NativeThemeX11 : public CustomThemeSupplier { 18 class SystemThemeX11 : public CustomThemeSupplier {
19 public: 19 public:
20 explicit NativeThemeX11(PrefService* pref_service); 20 explicit SystemThemeX11(PrefService* pref_service);
21 21
22 // Overridden from CustomThemeSupplier: 22 // Overridden from CustomThemeSupplier:
23 virtual void StartUsingTheme() OVERRIDE; 23 virtual void StartUsingTheme() OVERRIDE;
24 virtual void StopUsingTheme() OVERRIDE; 24 virtual void StopUsingTheme() OVERRIDE;
25 virtual bool GetColor(int id, SkColor* color) const OVERRIDE; 25 virtual bool GetColor(int id, SkColor* color) const OVERRIDE;
26 virtual gfx::Image GetImageNamed(int id) OVERRIDE; 26 virtual gfx::Image GetImageNamed(int id) OVERRIDE;
27 virtual bool HasCustomImage(int id) const OVERRIDE; 27 virtual bool HasCustomImage(int id) const OVERRIDE;
28 28
29 private: 29 private:
30 virtual ~NativeThemeX11(); 30 virtual ~SystemThemeX11();
31 31
32 // These pointers are not owned by us. 32 // These pointers are not owned by us.
33 views::LinuxUI* const linux_ui_; 33 views::LinuxUI* const linux_ui_;
34 PrefService* const pref_service_; 34 PrefService* const pref_service_;
35 35
36 DISALLOW_COPY_AND_ASSIGN(NativeThemeX11); 36 DISALLOW_COPY_AND_ASSIGN(SystemThemeX11);
37 }; 37 };
38 38
39 NativeThemeX11::NativeThemeX11(PrefService* pref_service) 39 SystemThemeX11::SystemThemeX11(PrefService* pref_service)
40 : CustomThemeSupplier(NATIVE_X11), 40 : CustomThemeSupplier(NATIVE_X11),
41 linux_ui_(views::LinuxUI::instance()), 41 linux_ui_(views::LinuxUI::instance()),
42 pref_service_(pref_service) {} 42 pref_service_(pref_service) {}
43 43
44 void NativeThemeX11::StartUsingTheme() { 44 void SystemThemeX11::StartUsingTheme() {
45 pref_service_->SetBoolean(prefs::kUsesSystemTheme, true); 45 pref_service_->SetBoolean(prefs::kUsesSystemTheme, true);
46 // Have the former theme notify its observers of change. 46 // Have the former theme notify its observers of change.
47 ui::NativeThemeAura::instance()->NotifyObservers(); 47 ui::NativeThemeAura::instance()->NotifyObservers();
48 } 48 }
49 49
50 void NativeThemeX11::StopUsingTheme() { 50 void SystemThemeX11::StopUsingTheme() {
51 pref_service_->SetBoolean(prefs::kUsesSystemTheme, false); 51 pref_service_->SetBoolean(prefs::kUsesSystemTheme, false);
52 // Have the former theme notify its observers of change. 52 // Have the former theme notify its observers of change.
53 if (linux_ui_) 53 if (linux_ui_)
54 linux_ui_->GetNativeTheme(NULL)->NotifyObservers(); 54 linux_ui_->GetNativeTheme(NULL)->NotifyObservers();
55 } 55 }
56 56
57 bool NativeThemeX11::GetColor(int id, SkColor* color) const { 57 bool SystemThemeX11::GetColor(int id, SkColor* color) const {
58 return linux_ui_ && linux_ui_->GetColor(id, color); 58 return linux_ui_ && linux_ui_->GetColor(id, color);
59 } 59 }
60 60
61 gfx::Image NativeThemeX11::GetImageNamed(int id) { 61 gfx::Image SystemThemeX11::GetImageNamed(int id) {
62 return linux_ui_ ? linux_ui_->GetThemeImageNamed(id) : gfx::Image(); 62 return linux_ui_ ? linux_ui_->GetThemeImageNamed(id) : gfx::Image();
63 } 63 }
64 64
65 bool NativeThemeX11::HasCustomImage(int id) const { 65 bool SystemThemeX11::HasCustomImage(int id) const {
66 return linux_ui_ && linux_ui_->HasCustomImage(id); 66 return linux_ui_ && linux_ui_->HasCustomImage(id);
67 } 67 }
68 68
69 NativeThemeX11::~NativeThemeX11() {} 69 SystemThemeX11::~SystemThemeX11() {}
70 70
71 } // namespace 71 } // namespace
72 72
73 ThemeServiceAuraX11::ThemeServiceAuraX11() {} 73 ThemeServiceAuraX11::ThemeServiceAuraX11() {}
74 74
75 ThemeServiceAuraX11::~ThemeServiceAuraX11() {} 75 ThemeServiceAuraX11::~ThemeServiceAuraX11() {}
76 76
77 bool ThemeServiceAuraX11::ShouldInitWithNativeTheme() const { 77 bool ThemeServiceAuraX11::ShouldInitWithSystemTheme() const {
78 return profile()->GetPrefs()->GetBoolean(prefs::kUsesSystemTheme); 78 return profile()->GetPrefs()->GetBoolean(prefs::kUsesSystemTheme);
79 } 79 }
80 80
81 void ThemeServiceAuraX11::SetNativeTheme() { 81 void ThemeServiceAuraX11::UseSystemTheme() {
82 SetCustomDefaultTheme(new NativeThemeX11(profile()->GetPrefs())); 82 SetCustomDefaultTheme(new SystemThemeX11(profile()->GetPrefs()));
83 } 83 }
84 84
85 bool ThemeServiceAuraX11::UsingDefaultTheme() const { 85 bool ThemeServiceAuraX11::UsingDefaultTheme() const {
86 return ThemeService::UsingDefaultTheme() && !UsingNativeTheme(); 86 return ThemeService::UsingDefaultTheme() && !UsingSystemTheme();
87 } 87 }
88 88
89 bool ThemeServiceAuraX11::UsingNativeTheme() const { 89 bool ThemeServiceAuraX11::UsingSystemTheme() const {
90 const CustomThemeSupplier* theme_supplier = get_theme_supplier(); 90 const CustomThemeSupplier* theme_supplier = get_theme_supplier();
91 return theme_supplier && 91 return theme_supplier &&
92 theme_supplier->get_theme_type() == CustomThemeSupplier::NATIVE_X11; 92 theme_supplier->get_theme_type() == CustomThemeSupplier::NATIVE_X11;
93 } 93 }
OLDNEW
« no previous file with comments | « chrome/browser/themes/theme_service_aurax11.h ('k') | chrome/browser/themes/theme_service_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698