| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/string_split.h" | 7 #include "base/string_split.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 | 211 |
| 212 registrar_.Add(this, | 212 registrar_.Add(this, |
| 213 NotificationType::THEME_INSTALLED, | 213 NotificationType::THEME_INSTALLED, |
| 214 Source<Profile>(profile_)); | 214 Source<Profile>(profile_)); |
| 215 | 215 |
| 216 LoadThemePrefs(); | 216 LoadThemePrefs(); |
| 217 } | 217 } |
| 218 | 218 |
| 219 SkBitmap* ThemeService::GetBitmapNamed(int id) const { | 219 SkBitmap* ThemeService::GetBitmapNamed(int id) const { |
| 220 DCHECK(CalledOnValidThread()); | 220 DCHECK(CalledOnValidThread()); |
| 221 std::vector<SkBitmap*> bitmaps; |
| 222 if (!GetBitmapsNamed(id, bitmaps)) |
| 223 return NULL; |
| 221 | 224 |
| 222 SkBitmap* bitmap = NULL; | 225 if (!bitmaps.empty()) |
| 226 return *bitmaps.begin(); |
| 223 | 227 |
| 224 if (theme_pack_.get()) | 228 return NULL; |
| 225 bitmap = theme_pack_->GetBitmapNamed(id); | 229 } |
| 226 | 230 |
| 227 if (!bitmap) | 231 bool ThemeService::GetBitmapsNamed(int id, std::vector<SkBitmap*>& bitmaps) |
| 228 bitmap = rb_.GetBitmapNamed(id); | 232 const { |
| 233 DCHECK(CalledOnValidThread()); |
| 229 | 234 |
| 230 return bitmap; | 235 if (theme_pack_.get() && theme_pack_->GetBitmapsNamed(id, bitmaps)) |
| 236 return true; |
| 237 |
| 238 return rb_.GetBitmapsNamed(id, bitmaps); |
| 231 } | 239 } |
| 232 | 240 |
| 233 SkColor ThemeService::GetColor(int id) const { | 241 SkColor ThemeService::GetColor(int id) const { |
| 234 DCHECK(CalledOnValidThread()); | 242 DCHECK(CalledOnValidThread()); |
| 235 | 243 |
| 236 SkColor color; | 244 SkColor color; |
| 237 if (theme_pack_.get() && theme_pack_->GetColor(id, &color)) | 245 if (theme_pack_.get() && theme_pack_->GetColor(id, &color)) |
| 238 return color; | 246 return color; |
| 239 | 247 |
| 240 // For backward compat with older themes, some newer colors are generated from | 248 // For backward compat with older themes, some newer colors are generated from |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 void ThemeService::OnInfobarDisplayed() { | 655 void ThemeService::OnInfobarDisplayed() { |
| 648 number_of_infobars_++; | 656 number_of_infobars_++; |
| 649 } | 657 } |
| 650 | 658 |
| 651 void ThemeService::OnInfobarDestroyed() { | 659 void ThemeService::OnInfobarDestroyed() { |
| 652 number_of_infobars_--; | 660 number_of_infobars_--; |
| 653 | 661 |
| 654 if (number_of_infobars_ == 0) | 662 if (number_of_infobars_ == 0) |
| 655 RemoveUnusedThemes(); | 663 RemoveUnusedThemes(); |
| 656 } | 664 } |
| OLD | NEW |