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 : use_system_theme_(false) { |
| 16 } |
| 17 |
| 18 ThemeServiceAuraX11::~ThemeServiceAuraX11() {} |
| 19 |
| 20 void ThemeServiceAuraX11::Init(Profile* profile) { |
| 21 registrar_.Init(profile->GetPrefs()); |
| 22 registrar_.Add(prefs::kUsesSystemTheme, |
| 23 base::Bind(&ThemeServiceAuraX11::OnUsesSystemThemeChanged, |
| 24 base::Unretained(this))); |
| 25 use_system_theme_ = profile->GetPrefs()->GetBoolean(prefs::kUsesSystemTheme); |
| 26 |
| 27 ThemeService::Init(profile); |
| 28 } |
| 29 |
| 30 gfx::Image ThemeServiceAuraX11::GetImageNamed(int id) const { |
| 31 const ui::LinuxUI* linux_ui = ui::LinuxUI::instance(); |
| 32 if (use_system_theme_ && linux_ui) { |
| 33 gfx::Image image = linux_ui->GetThemeImageNamed(id); |
| 34 if (!image.IsEmpty()) |
| 35 return image; |
| 36 } |
| 37 |
| 38 return ThemeService::GetImageNamed(id); |
| 39 } |
| 40 |
| 41 SkColor ThemeServiceAuraX11::GetColor(int id) const { |
| 42 const ui::LinuxUI* linux_ui = ui::LinuxUI::instance(); |
| 43 SkColor color; |
| 44 if (use_system_theme_ && linux_ui && linux_ui->GetColor(id, &color)) |
| 45 return color; |
| 46 |
| 47 return ThemeService::GetColor(id); |
| 48 } |
| 49 |
| 50 bool ThemeServiceAuraX11::HasCustomImage(int id) const { |
| 51 const ui::LinuxUI* linux_ui = ui::LinuxUI::instance(); |
| 52 if (use_system_theme_ && linux_ui) |
| 53 return linux_ui->HasCustomImage(id); |
| 54 |
| 55 return ThemeService::HasCustomImage(id); |
| 56 } |
| 57 |
| 58 void ThemeServiceAuraX11::SetTheme(const extensions::Extension* extension) { |
| 59 profile()->GetPrefs()->SetBoolean(prefs::kUsesSystemTheme, false); |
| 60 ThemeService::SetTheme(extension); |
| 61 } |
| 62 |
| 63 void ThemeServiceAuraX11::UseDefaultTheme() { |
| 64 profile()->GetPrefs()->SetBoolean(prefs::kUsesSystemTheme, false); |
| 65 ThemeService::UseDefaultTheme(); |
| 66 } |
| 67 |
| 68 void ThemeServiceAuraX11::SetNativeTheme() { |
| 69 profile()->GetPrefs()->SetBoolean(prefs::kUsesSystemTheme, true); |
| 70 ClearAllThemeData(); |
| 71 NotifyThemeChanged(); |
| 72 } |
| 73 |
| 74 bool ThemeServiceAuraX11::UsingDefaultTheme() const { |
| 75 return !use_system_theme_ && ThemeService::UsingDefaultTheme(); |
| 76 } |
| 77 |
| 78 bool ThemeServiceAuraX11::UsingNativeTheme() const { |
| 79 return use_system_theme_; |
| 80 } |
| 81 |
| 82 void ThemeServiceAuraX11::OnUsesSystemThemeChanged() { |
| 83 use_system_theme_ = |
| 84 profile()->GetPrefs()->GetBoolean(prefs::kUsesSystemTheme); |
| 85 } |
OLD | NEW |