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

Unified Diff: chrome/browser/themes/theme_service_aurax11.cc

Issue 17494005: linux_aura: Three fixes for switching themes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/themes/theme_service_aurax11.cc
diff --git a/chrome/browser/themes/theme_service_aurax11.cc b/chrome/browser/themes/theme_service_aurax11.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2caaa66d517b68936d077d4fdf7285967adc3277
--- /dev/null
+++ b/chrome/browser/themes/theme_service_aurax11.cc
@@ -0,0 +1,87 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/themes/theme_service_aurax11.h"
+
+#include "base/bind.h"
+#include "base/prefs/pref_service.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/pref_names.h"
+#include "ui/gfx/image/image.h"
+#include "ui/linux_ui/linux_ui.h"
+
+ThemeServiceAuraX11::ThemeServiceAuraX11()
+ : ThemeService(),
Evan Stade 2013/06/20 22:24:35 is this necessary?
+ use_system_theme_(false) {
+}
+
+ThemeServiceAuraX11::~ThemeServiceAuraX11() {
Evan Stade 2013/06/20 22:24:35 {} on one line
+}
+
+void ThemeServiceAuraX11::Init(Profile* profile) {
+ registrar_.Init(profile->GetPrefs());
+ registrar_.Add(prefs::kUsesSystemTheme,
+ base::Bind(&ThemeServiceAuraX11::OnUsesSystemThemeChanged,
+ base::Unretained(this)));
+ use_system_theme_ = profile->GetPrefs()->GetBoolean(prefs::kUsesSystemTheme);
+
+ ThemeService::Init(profile);
+}
+
+gfx::Image ThemeServiceAuraX11::GetImageNamed(int id) const {
+ const ui::LinuxUI* linux_ui = ui::LinuxUI::instance();
+ if (use_system_theme_ && linux_ui) {
+ gfx::Image image = linux_ui->GetThemeImageNamed(id);
+ if (!image.IsEmpty())
+ return image;
+ }
+
+ return ThemeService::GetImageNamed(id);
+}
+
+SkColor ThemeServiceAuraX11::GetColor(int id) const {
+ const ui::LinuxUI* linux_ui = ui::LinuxUI::instance();
+ SkColor color;
+ if (use_system_theme_ && linux_ui && linux_ui->GetColor(id, &color))
+ return color;
+
+ return ThemeService::GetColor(id);
+}
+
+bool ThemeServiceAuraX11::HasCustomImage(int id) const {
+ const ui::LinuxUI* linux_ui = ui::LinuxUI::instance();
+ if (use_system_theme_ && linux_ui)
+ return linux_ui->HasCustomImage(id);
+
+ return ThemeService::HasCustomImage(id);
+}
+
+void ThemeServiceAuraX11::SetTheme(const extensions::Extension* extension) {
+ profile()->GetPrefs()->SetBoolean(prefs::kUsesSystemTheme, false);
+ ThemeService::SetTheme(extension);
+}
+
+void ThemeServiceAuraX11::UseDefaultTheme() {
+ profile()->GetPrefs()->SetBoolean(prefs::kUsesSystemTheme, false);
+ ThemeService::UseDefaultTheme();
+}
+
+void ThemeServiceAuraX11::SetNativeTheme() {
+ profile()->GetPrefs()->SetBoolean(prefs::kUsesSystemTheme, true);
+ ClearAllThemeData();
+ NotifyThemeChanged();
+}
+
+bool ThemeServiceAuraX11::UsingDefaultTheme() const {
+ return !use_system_theme_ && ThemeService::UsingDefaultTheme();
+}
+
+bool ThemeServiceAuraX11::UsingNativeTheme() const {
+ return use_system_theme_;
+}
+
+void ThemeServiceAuraX11::OnUsesSystemThemeChanged() {
+ use_system_theme_ =
+ profile()->GetPrefs()->GetBoolean(prefs::kUsesSystemTheme);
+}

Powered by Google App Engine
This is Rietveld 408576698