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

Unified Diff: chrome/browser/browser_theme_provider.cc

Issue 258020: GTK: Refactor some things so GTK doesn't touch the on disk image cache. (Closed)
Patch Set: Created 11 years, 3 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
« no previous file with comments | « chrome/browser/browser_theme_provider.h ('k') | chrome/browser/gtk/gtk_theme_provider.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/browser_theme_provider.cc
diff --git a/chrome/browser/browser_theme_provider.cc b/chrome/browser/browser_theme_provider.cc
index 96f1d298bb8e419a5287758415660bdbd90f0901..de0acb7cad2aa10ae19724bc8eb2a07a573c5b29 100644
--- a/chrome/browser/browser_theme_provider.cc
+++ b/chrome/browser/browser_theme_provider.cc
@@ -332,11 +332,6 @@ SkBitmap* BrowserThemeProvider::GetBitmapNamed(int id) {
// Try to load the image from the extension.
result.reset(LoadThemeBitmap(id));
- // If the extension doesn't provide the requested image, but has provided
- // a custom frame, then we may be able to generate the image required.
- if (!result.get())
- result.reset(GenerateTabBackgroundBitmap(id));
-
// If we still don't have an image, load it from resourcebundle.
if (!result.get())
result.reset(new SkBitmap(*rb_.GetBitmapNamed(id)));
@@ -1072,31 +1067,14 @@ SkBitmap* BrowserThemeProvider::GenerateTabBackgroundBitmap(int id) {
if (frame.get())
themed_image_cache_[id] = new SkBitmap(*frame.get());
} else {
- int base_id;
- std::string resource_name;
- if (id == IDR_THEME_TAB_BACKGROUND) {
- base_id = IDR_THEME_FRAME;
- resource_name = "theme_tab_background";
- } else {
- base_id = IDR_THEME_FRAME_INCOGNITO;
- resource_name = "theme_tab_background_incognito";
- }
- std::map<int, SkBitmap*>::iterator it = themed_image_cache_.find(base_id);
- if (it != themed_image_cache_.end()) {
- SkBitmap bg_tint = TintBitmap(*(it->second), TINT_BACKGROUND_TAB);
- int vertical_offset = HasCustomImage(id) ?
- kRestoredTabVerticalOffset : 0;
- SkBitmap* bg_tab = new SkBitmap(SkBitmapOperations::CreateTiledBitmap(
- bg_tint, 0, vertical_offset, bg_tint.width(), bg_tint.height()));
-
- // If they've provided a custom image, overlay it.
- if (HasCustomImage(id)) {
- SkBitmap* overlay = LoadThemeBitmap(id);
- if (overlay) {
- SkCanvas canvas(*bg_tab);
- for (int x = 0; x < bg_tab->width(); x += overlay->width())
- canvas.drawBitmap(*overlay, static_cast<SkScalar>(x), 0, NULL);
- }
+ SkBitmap* bg_tab = GenerateTabBackgroundBitmapImpl(id);
+
+ if (bg_tab) {
+ std::string resource_name;
+ if (id == IDR_THEME_TAB_BACKGROUND) {
+ resource_name = "theme_tab_background";
+ } else {
+ resource_name = "theme_tab_background_incognito";
}
themed_image_cache_[id] = bg_tab;
@@ -1108,6 +1086,37 @@ SkBitmap* BrowserThemeProvider::GenerateTabBackgroundBitmap(int id) {
return NULL;
}
+SkBitmap* BrowserThemeProvider::GenerateTabBackgroundBitmapImpl(int id) {
+ int base_id;
+ if (id == IDR_THEME_TAB_BACKGROUND) {
+ base_id = IDR_THEME_FRAME;
+ } else {
+ base_id = IDR_THEME_FRAME_INCOGNITO;
+ }
+ std::map<int, SkBitmap*>::iterator it = themed_image_cache_.find(base_id);
+ if (it != themed_image_cache_.end()) {
+ SkBitmap bg_tint = TintBitmap(*(it->second), TINT_BACKGROUND_TAB);
+ int vertical_offset = HasCustomImage(id) ?
+ kRestoredTabVerticalOffset : 0;
+ SkBitmap* bg_tab = new SkBitmap(SkBitmapOperations::CreateTiledBitmap(
+ bg_tint, 0, vertical_offset, bg_tint.width(), bg_tint.height()));
+
+ // If they've provided a custom image, overlay it.
+ if (HasCustomImage(id)) {
+ SkBitmap* overlay = LoadThemeBitmap(id);
+ if (overlay) {
+ SkCanvas canvas(*bg_tab);
+ for (int x = 0; x < bg_tab->width(); x += overlay->width())
+ canvas.drawBitmap(*overlay, static_cast<SkScalar>(x), 0, NULL);
+ }
+ }
+
+ return bg_tab;
+ }
+
+ return NULL;
+}
+
void BrowserThemeProvider::SaveCachedImageData() {
DictionaryValue* pref_images =
profile_->GetPrefs()->GetMutableDictionary(prefs::kCurrentThemeImages);
« no previous file with comments | « chrome/browser/browser_theme_provider.h ('k') | chrome/browser/gtk/gtk_theme_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698