Chromium Code Reviews| 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/string_split.h" | 9 #include "base/string_split.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "chrome/browser/extensions/extension_service.h" | 12 #include "chrome/browser/extensions/extension_service.h" |
| 13 #include "chrome/browser/prefs/pref_service.h" | 13 #include "chrome/browser/prefs/pref_service.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/themes/browser_theme_pack.h" | 15 #include "chrome/browser/themes/browser_theme_pack.h" |
| 16 #include "chrome/common/chrome_constants.h" | 16 #include "chrome/common/chrome_constants.h" |
| 17 #include "chrome/common/chrome_notification_types.h" | 17 #include "chrome/common/chrome_notification_types.h" |
| 18 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
| 19 #include "content/public/browser/notification_service.h" | 19 #include "content/public/browser/notification_service.h" |
| 20 #include "content/public/browser/user_metrics.h" | 20 #include "content/public/browser/user_metrics.h" |
| 21 #include "grit/theme_resources.h" | 21 #include "grit/theme_resources.h" |
| 22 #include "grit/theme_resources_standard.h" | 22 #include "grit/theme_resources_standard.h" |
| 23 #include "grit/ui_resources.h" | 23 #include "grit/ui_resources.h" |
| 24 #include "ui/base/resource/resource_bundle.h" | 24 #include "ui/base/resource/resource_bundle.h" |
| 25 #include "ui/gfx/image/image_skia.h" | |
| 25 | 26 |
| 26 #if defined(OS_WIN) && !defined(USE_AURA) | 27 #if defined(OS_WIN) && !defined(USE_AURA) |
| 27 #include "ui/views/widget/native_widget_win.h" | 28 #include "ui/views/widget/native_widget_win.h" |
| 28 #endif | 29 #endif |
| 29 | 30 |
| 30 using content::BrowserThread; | 31 using content::BrowserThread; |
| 31 using content::UserMetricsAction; | 32 using content::UserMetricsAction; |
| 32 using ui::ResourceBundle; | 33 using ui::ResourceBundle; |
| 33 | 34 |
| 34 // Strings used in alignment properties. | 35 // Strings used in alignment properties. |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 237 if (theme_pack_.get()) | 238 if (theme_pack_.get()) |
| 238 image = theme_pack_->GetImageNamed(id); | 239 image = theme_pack_->GetImageNamed(id); |
| 239 | 240 |
| 240 if (!image) | 241 if (!image) |
| 241 image = &rb_.GetNativeImageNamed(id); | 242 image = &rb_.GetNativeImageNamed(id); |
| 242 | 243 |
| 243 return image; | 244 return image; |
| 244 } | 245 } |
| 245 | 246 |
| 246 SkBitmap* ThemeService::GetBitmapNamed(int id) const { | 247 SkBitmap* ThemeService::GetBitmapNamed(int id) const { |
| 247 DCHECK(CalledOnValidThread()); | 248 const gfx::Image* image = GetImageNamed(id); |
|
sky
2012/05/10 17:08:24
Add TODOs about removing casts.
| |
| 249 if (!image) | |
| 250 return NULL; | |
| 248 | 251 |
| 249 SkBitmap* bitmap = NULL; | 252 return const_cast<SkBitmap*>(image->ToSkBitmap()); |
| 253 } | |
| 250 | 254 |
| 251 if (theme_pack_.get()) | 255 gfx::ImageSkia* ThemeService::GetImageSkiaNamed(int id) const { |
| 252 bitmap = theme_pack_->GetBitmapNamed(id); | 256 const gfx::Image* image = GetImageNamed(id); |
| 253 | 257 if (!image) |
| 254 if (!bitmap) | 258 return NULL; |
| 255 bitmap = rb_.GetBitmapNamed(id); | 259 return const_cast<gfx::ImageSkia*>(image->ToImageSkia()); |
| 256 | |
| 257 return bitmap; | |
| 258 } | 260 } |
| 259 | 261 |
| 260 SkColor ThemeService::GetColor(int id) const { | 262 SkColor ThemeService::GetColor(int id) const { |
| 261 DCHECK(CalledOnValidThread()); | 263 DCHECK(CalledOnValidThread()); |
| 262 | 264 |
| 263 SkColor color; | 265 SkColor color; |
| 264 if (theme_pack_.get() && theme_pack_->GetColor(id, &color)) | 266 if (theme_pack_.get() && theme_pack_->GetColor(id, &color)) |
| 265 return color; | 267 return color; |
| 266 | 268 |
| 267 // For backward compat with older themes, some newer colors are generated from | 269 // For backward compat with older themes, some newer colors are generated from |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 676 void ThemeService::OnInfobarDisplayed() { | 678 void ThemeService::OnInfobarDisplayed() { |
| 677 number_of_infobars_++; | 679 number_of_infobars_++; |
| 678 } | 680 } |
| 679 | 681 |
| 680 void ThemeService::OnInfobarDestroyed() { | 682 void ThemeService::OnInfobarDestroyed() { |
| 681 number_of_infobars_--; | 683 number_of_infobars_--; |
| 682 | 684 |
| 683 if (number_of_infobars_ == 0) | 685 if (number_of_infobars_ == 0) |
| 684 RemoveUnusedThemes(); | 686 RemoveUnusedThemes(); |
| 685 } | 687 } |
| OLD | NEW |