| 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/themes/theme_service.h" | 5 #include "chrome/browser/themes/theme_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/ref_counted_memory.h" | 8 #include "base/memory/ref_counted_memory.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 gfx::Image image; | 111 gfx::Image image; |
| 112 if (theme_supplier_.get()) | 112 if (theme_supplier_.get()) |
| 113 image = theme_supplier_->GetImageNamed(id); | 113 image = theme_supplier_->GetImageNamed(id); |
| 114 | 114 |
| 115 if (image.IsEmpty()) | 115 if (image.IsEmpty()) |
| 116 image = rb_.GetNativeImageNamed(id); | 116 image = rb_.GetNativeImageNamed(id); |
| 117 | 117 |
| 118 return image; | 118 return image; |
| 119 } | 119 } |
| 120 | 120 |
| 121 bool ThemeService::UsingNativeTheme() const { |
| 122 return UsingDefaultTheme(); |
| 123 } |
| 124 |
| 121 gfx::ImageSkia* ThemeService::GetImageSkiaNamed(int id) const { | 125 gfx::ImageSkia* ThemeService::GetImageSkiaNamed(int id) const { |
| 122 gfx::Image image = GetImageNamed(id); | 126 gfx::Image image = GetImageNamed(id); |
| 123 if (image.IsEmpty()) | 127 if (image.IsEmpty()) |
| 124 return NULL; | 128 return NULL; |
| 125 // TODO(pkotwicz): Remove this const cast. The gfx::Image interface returns | 129 // TODO(pkotwicz): Remove this const cast. The gfx::Image interface returns |
| 126 // its images const. GetImageSkiaNamed() also should but has many callsites. | 130 // its images const. GetImageSkiaNamed() also should but has many callsites. |
| 127 return const_cast<gfx::ImageSkia*>(image.ToImageSkia()); | 131 return const_cast<gfx::ImageSkia*>(image.ToImageSkia()); |
| 128 } | 132 } |
| 129 | 133 |
| 130 SkColor ThemeService::GetColor(int id) const { | 134 SkColor ThemeService::GetColor(int id) const { |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 void ThemeService::SetNativeTheme() { | 381 void ThemeService::SetNativeTheme() { |
| 378 UseDefaultTheme(); | 382 UseDefaultTheme(); |
| 379 } | 383 } |
| 380 | 384 |
| 381 bool ThemeService::UsingDefaultTheme() const { | 385 bool ThemeService::UsingDefaultTheme() const { |
| 382 std::string id = GetThemeID(); | 386 std::string id = GetThemeID(); |
| 383 return id == ThemeService::kDefaultThemeID || | 387 return id == ThemeService::kDefaultThemeID || |
| 384 id == kDefaultThemeGalleryID; | 388 id == kDefaultThemeGalleryID; |
| 385 } | 389 } |
| 386 | 390 |
| 387 bool ThemeService::UsingNativeTheme() const { | |
| 388 return UsingDefaultTheme(); | |
| 389 } | |
| 390 | |
| 391 std::string ThemeService::GetThemeID() const { | 391 std::string ThemeService::GetThemeID() const { |
| 392 return profile_->GetPrefs()->GetString(prefs::kCurrentThemeID); | 392 return profile_->GetPrefs()->GetString(prefs::kCurrentThemeID); |
| 393 } | 393 } |
| 394 | 394 |
| 395 color_utils::HSL ThemeService::GetTint(int id) const { | 395 color_utils::HSL ThemeService::GetTint(int id) const { |
| 396 DCHECK(CalledOnValidThread()); | 396 DCHECK(CalledOnValidThread()); |
| 397 | 397 |
| 398 color_utils::HSL hsl; | 398 color_utils::HSL hsl; |
| 399 if (theme_supplier_.get() && theme_supplier_->GetTint(id, &hsl)) | 399 if (theme_supplier_.get() && theme_supplier_->GetTint(id, &hsl)) |
| 400 return hsl; | 400 return hsl; |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 void ThemeService::OnInfobarDestroyed() { | 593 void ThemeService::OnInfobarDestroyed() { |
| 594 number_of_infobars_--; | 594 number_of_infobars_--; |
| 595 | 595 |
| 596 if (number_of_infobars_ == 0) | 596 if (number_of_infobars_ == 0) |
| 597 RemoveUnusedThemes(false); | 597 RemoveUnusedThemes(false); |
| 598 } | 598 } |
| 599 | 599 |
| 600 ThemeSyncableService* ThemeService::GetThemeSyncableService() const { | 600 ThemeSyncableService* ThemeService::GetThemeSyncableService() const { |
| 601 return theme_syncable_service_.get(); | 601 return theme_syncable_service_.get(); |
| 602 } | 602 } |
| OLD | NEW |