| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/gtk/gtk_theme_service.h" | 5 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 // We have to call this because FreePlatformCached() in ~ThemeService | 287 // We have to call this because FreePlatformCached() in ~ThemeService |
| 288 // doesn't call the right virutal FreePlatformCaches. | 288 // doesn't call the right virutal FreePlatformCaches. |
| 289 FreePlatformCaches(); | 289 FreePlatformCaches(); |
| 290 } | 290 } |
| 291 | 291 |
| 292 void GtkThemeService::Init(Profile* profile) { | 292 void GtkThemeService::Init(Profile* profile) { |
| 293 registrar_.Init(profile->GetPrefs()); | 293 registrar_.Init(profile->GetPrefs()); |
| 294 registrar_.Add(prefs::kUsesSystemTheme, | 294 registrar_.Add(prefs::kUsesSystemTheme, |
| 295 base::Bind(&GtkThemeService::OnUsesSystemThemeChanged, | 295 base::Bind(&GtkThemeService::OnUsesSystemThemeChanged, |
| 296 base::Unretained(this))); | 296 base::Unretained(this))); |
| 297 use_gtk_ = profile->GetPrefs()->GetBoolean(prefs::kUsesSystemTheme); |
| 297 ThemeService::Init(profile); | 298 ThemeService::Init(profile); |
| 298 } | 299 } |
| 299 | 300 |
| 300 gfx::ImageSkia* GtkThemeService::GetImageSkiaNamed(int id) const { | 301 gfx::ImageSkia* GtkThemeService::GetImageSkiaNamed(int id) const { |
| 301 // TODO(pkotwicz): Remove this const cast. The gfx::Image interface returns | 302 // TODO(pkotwicz): Remove this const cast. The gfx::Image interface returns |
| 302 // its images const. GetImageSkiaNamed() also should but has many callsites. | 303 // its images const. GetImageSkiaNamed() also should but has many callsites. |
| 303 return const_cast<gfx::ImageSkia*>(GetImageNamed(id).ToImageSkia()); | 304 return const_cast<gfx::ImageSkia*>(GetImageNamed(id).ToImageSkia()); |
| 304 } | 305 } |
| 305 | 306 |
| 306 gfx::Image GtkThemeService::GetImageNamed(int id) const { | 307 gfx::Image GtkThemeService::GetImageNamed(int id) const { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 328 return ThemeService::GetColor(id); | 329 return ThemeService::GetColor(id); |
| 329 } | 330 } |
| 330 | 331 |
| 331 bool GtkThemeService::HasCustomImage(int id) const { | 332 bool GtkThemeService::HasCustomImage(int id) const { |
| 332 if (use_gtk_) | 333 if (use_gtk_) |
| 333 return IsOverridableImage(id); | 334 return IsOverridableImage(id); |
| 334 | 335 |
| 335 return ThemeService::HasCustomImage(id); | 336 return ThemeService::HasCustomImage(id); |
| 336 } | 337 } |
| 337 | 338 |
| 338 void GtkThemeService::InitThemesFor(content::NotificationObserver* observer) { | 339 void GtkThemeService::InitThemesFor(NotificationObserver* observer) { |
| 339 observer->Observe(chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | 340 observer->Observe(chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
| 340 content::Source<ThemeService>(this), | 341 content::Source<ThemeService>(this), |
| 341 content::NotificationService::NoDetails()); | 342 content::NotificationService::NoDetails()); |
| 342 } | 343 } |
| 343 | 344 |
| 344 void GtkThemeService::SetTheme(const extensions::Extension* extension) { | 345 void GtkThemeService::SetTheme(const extensions::Extension* extension) { |
| 345 profile()->GetPrefs()->SetBoolean(prefs::kUsesSystemTheme, false); | 346 profile()->GetPrefs()->SetBoolean(prefs::kUsesSystemTheme, false); |
| 346 LoadDefaultValues(); | 347 LoadDefaultValues(); |
| 347 ThemeService::SetTheme(extension); | 348 ThemeService::SetTheme(extension); |
| 348 } | 349 } |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 } | 613 } |
| 613 | 614 |
| 614 void GtkThemeService::ClearAllThemeData() { | 615 void GtkThemeService::ClearAllThemeData() { |
| 615 colors_.clear(); | 616 colors_.clear(); |
| 616 tints_.clear(); | 617 tints_.clear(); |
| 617 | 618 |
| 618 ThemeService::ClearAllThemeData(); | 619 ThemeService::ClearAllThemeData(); |
| 619 } | 620 } |
| 620 | 621 |
| 621 void GtkThemeService::LoadThemePrefs() { | 622 void GtkThemeService::LoadThemePrefs() { |
| 622 if (ThemeService::UsingDefaultTheme()) { | |
| 623 use_gtk_ = profile()->GetPrefs()->GetBoolean(prefs::kUsesSystemTheme); | |
| 624 } else { | |
| 625 // Do this here since ThemeServiceFactory::SetThemeForProfile() | |
| 626 // doesn't know to set kUsesSystemTheme to false. | |
| 627 profile()->GetPrefs()->SetBoolean(prefs::kUsesSystemTheme, false); | |
| 628 use_gtk_ = false; | |
| 629 } | |
| 630 if (use_gtk_) { | 623 if (use_gtk_) { |
| 631 LoadGtkValues(); | 624 LoadGtkValues(); |
| 632 } else { | 625 } else { |
| 633 LoadDefaultValues(); | 626 LoadDefaultValues(); |
| 634 ThemeService::LoadThemePrefs(); | 627 ThemeService::LoadThemePrefs(); |
| 635 } | 628 } |
| 636 | 629 |
| 637 RebuildMenuIconSets(); | 630 RebuildMenuIconSets(); |
| 638 } | 631 } |
| 639 | 632 |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1151 cairo_stroke(cr); | 1144 cairo_stroke(cr); |
| 1152 cairo_destroy(cr); | 1145 cairo_destroy(cr); |
| 1153 cairo_pattern_destroy(pattern); | 1146 cairo_pattern_destroy(pattern); |
| 1154 | 1147 |
| 1155 return TRUE; | 1148 return TRUE; |
| 1156 } | 1149 } |
| 1157 | 1150 |
| 1158 void GtkThemeService::OnUsesSystemThemeChanged() { | 1151 void GtkThemeService::OnUsesSystemThemeChanged() { |
| 1159 use_gtk_ = profile()->GetPrefs()->GetBoolean(prefs::kUsesSystemTheme); | 1152 use_gtk_ = profile()->GetPrefs()->GetBoolean(prefs::kUsesSystemTheme); |
| 1160 } | 1153 } |
| OLD | NEW |