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

Side by Side Diff: chrome/browser/browser_theme_provider.cc

Issue 173638: Merge 24830 - If a preferences file references a theme which is from an old v... (Closed) Base URL: svn://chrome-svn/chrome/branches/195/src/
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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Modified: svn:mergeinfo
Merged /trunk/src/chrome/browser/browser_theme_provider.cc:r24830
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/browser_theme_provider.h" 5 #include "chrome/browser/browser_theme_provider.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/gfx/png_decoder.h" 8 #include "base/gfx/png_decoder.h"
9 #include "base/gfx/png_encoder.h" 9 #include "base/gfx/png_encoder.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1118 1118
1119 void BrowserThemeProvider::NotifyThemeChanged() { 1119 void BrowserThemeProvider::NotifyThemeChanged() {
1120 // Redraw! 1120 // Redraw!
1121 NotificationService* service = NotificationService::current(); 1121 NotificationService* service = NotificationService::current();
1122 service->Notify(NotificationType::BROWSER_THEME_CHANGED, 1122 service->Notify(NotificationType::BROWSER_THEME_CHANGED,
1123 Source<BrowserThemeProvider>(this), 1123 Source<BrowserThemeProvider>(this),
1124 NotificationService::NoDetails()); 1124 NotificationService::NoDetails());
1125 } 1125 }
1126 1126
1127 void BrowserThemeProvider::LoadThemePrefs() { 1127 void BrowserThemeProvider::LoadThemePrefs() {
1128 // Images were already processed when theme was set.
1129 process_images_ = false; 1128 process_images_ = false;
1130
1131 PrefService* prefs = profile_->GetPrefs(); 1129 PrefService* prefs = profile_->GetPrefs();
1132 1130
1133 // TODO(glen): Figure out if any custom prefs were loaded, and if so 1131 // TODO(glen): Figure out if any custom prefs were loaded, and if so
1134 // UMA-log the fact that a theme was loaded. 1132 // UMA-log the fact that a theme was loaded.
1135 if (prefs->HasPrefPath(prefs::kCurrentThemeImages) || 1133 if (prefs->HasPrefPath(prefs::kCurrentThemeImages) ||
1136 prefs->HasPrefPath(prefs::kCurrentThemeColors) || 1134 prefs->HasPrefPath(prefs::kCurrentThemeColors) ||
1137 prefs->HasPrefPath(prefs::kCurrentThemeTints)) { 1135 prefs->HasPrefPath(prefs::kCurrentThemeTints)) {
1138 // Our prefs already have the extension path baked in, so we don't need 1136 // Our prefs already have the extension path baked in, so we don't need
1139 // to provide it. 1137 // to provide it.
1140 SetImageData(prefs->GetMutableDictionary(prefs::kCurrentThemeImages), 1138 SetImageData(prefs->GetMutableDictionary(prefs::kCurrentThemeImages),
1141 FilePath()); 1139 FilePath());
1142 SetColorData(prefs->GetMutableDictionary(prefs::kCurrentThemeColors)); 1140 SetColorData(prefs->GetMutableDictionary(prefs::kCurrentThemeColors));
1143 SetTintData(prefs->GetMutableDictionary(prefs::kCurrentThemeTints)); 1141 SetTintData(prefs->GetMutableDictionary(prefs::kCurrentThemeTints));
1144 SetDisplayPropertyData( 1142 SetDisplayPropertyData(
1145 prefs->GetMutableDictionary(prefs::kCurrentThemeDisplayProperties)); 1143 prefs->GetMutableDictionary(prefs::kCurrentThemeDisplayProperties));
1144
1145 // If we're not loading the frame from the cached image dir, we are using
1146 // an old preferences file, or the processed images were not saved
1147 // correctly. Force image reprocessing and caching.
1148 if (images_.count(IDR_THEME_FRAME) > 0) {
1149 #if defined(OS_WIN)
1150 FilePath cache_path = FilePath(UTF8ToWide(images_[IDR_THEME_FRAME]));
1151 #else
1152 FilePath cache_path = FilePath(images_[IDR_THEME_FRAME]);
1153 #endif
1154 process_images_ = !file_util::ContainsPath(image_dir_, cache_path);
1155 }
1156
1146 GenerateFrameColors(); 1157 GenerateFrameColors();
1147 GenerateFrameImages(); 1158 GenerateFrameImages();
1148 GenerateTabImages(); 1159 GenerateTabImages();
1160 if (process_images_) {
1161 WriteImagesToDisk();
1162 UserMetrics::RecordAction(L"Migrated noncached to cached theme.",
1163 profile_);
1164 }
1149 UserMetrics::RecordAction(L"Themes_loaded", profile_); 1165 UserMetrics::RecordAction(L"Themes_loaded", profile_);
1150 } 1166 }
1151 } 1167 }
1152 1168
1153 void BrowserThemeProvider::ClearCaches() { 1169 void BrowserThemeProvider::ClearCaches() {
1154 FreePlatformCaches(); 1170 FreePlatformCaches();
1155 for (ImageCache::iterator i = image_cache_.begin(); 1171 for (ImageCache::iterator i = image_cache_.begin();
1156 i != image_cache_.end(); i++) { 1172 i != image_cache_.end(); i++) {
1157 delete i->second; 1173 delete i->second;
1158 } 1174 }
1159 image_cache_.clear(); 1175 image_cache_.clear();
1160 1176
1161 // The SkBitmaps in the image_save_cache_ are a subset of those stored in 1177 // The SkBitmaps in the image_save_cache_ are a subset of those stored in
1162 // the image_cache_, and have therefore all been deleted in the lines above. 1178 // the image_cache_, and have therefore all been deleted in the lines above.
1163 // TODO(mirandac): make memory management clearer here. 1179 // TODO(mirandac): make memory management clearer here.
1164 image_save_cache_.clear(); 1180 image_save_cache_.clear();
1165 } 1181 }
1166 1182
1167 #if defined(TOOLKIT_VIEWS) 1183 #if defined(TOOLKIT_VIEWS)
1168 void BrowserThemeProvider::FreePlatformCaches() { 1184 void BrowserThemeProvider::FreePlatformCaches() {
1169 // Views (Skia) has no platform image cache to clear. 1185 // Views (Skia) has no platform image cache to clear.
1170 } 1186 }
1171 #endif 1187 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698