From f9bcd26a1e7bbe4d4f4bbbc72ba40e59d3be1fbb Mon Sep 17 00:00:00 2001 From: "mirandac@chromium.org" Date: Fri, 28 Aug 2009 23:07:27 +0000 Subject: If a preferences file references a theme which is from an old version, or whose images have failed to process correctly, drop back to the default theme. BUG= http://crbug.com/20263 TEST= Use a preferences file from an older version of Chrome that has a theme installed, and open Chrome. Observe that Chrome opens using the default theme. Review URL: http://codereview.chromium.org/175013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24830 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/browser_theme_provider.cc | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'chrome/browser') diff --git a/chrome/browser/browser_theme_provider.cc b/chrome/browser/browser_theme_provider.cc index ec4054b..8ff934f 100644 --- a/chrome/browser/browser_theme_provider.cc +++ b/chrome/browser/browser_theme_provider.cc @@ -1130,9 +1130,7 @@ void BrowserThemeProvider::NotifyThemeChanged() { } void BrowserThemeProvider::LoadThemePrefs() { - // Images were already processed when theme was set. process_images_ = false; - PrefService* prefs = profile_->GetPrefs(); // TODO(glen): Figure out if any custom prefs were loaded, and if so @@ -1148,9 +1146,27 @@ void BrowserThemeProvider::LoadThemePrefs() { SetTintData(prefs->GetMutableDictionary(prefs::kCurrentThemeTints)); SetDisplayPropertyData( prefs->GetMutableDictionary(prefs::kCurrentThemeDisplayProperties)); + + // If we're not loading the frame from the cached image dir, we are using + // an old preferences file, or the processed images were not saved + // correctly. Force image reprocessing and caching. + if (images_.count(IDR_THEME_FRAME) > 0) { +#if defined(OS_WIN) + FilePath cache_path = FilePath(UTF8ToWide(images_[IDR_THEME_FRAME])); +#else + FilePath cache_path = FilePath(images_[IDR_THEME_FRAME]); +#endif + process_images_ = !file_util::ContainsPath(image_dir_, cache_path); + } + GenerateFrameColors(); GenerateFrameImages(); GenerateTabImages(); + if (process_images_) { + WriteImagesToDisk(); + UserMetrics::RecordAction(L"Migrated noncached to cached theme.", + profile_); + } UserMetrics::RecordAction(L"Themes_loaded", profile_); } } -- cgit v1.1