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/chromeos/login/wallpaper_manager.h" | 5 #include "chrome/browser/chromeos/login/wallpaper_manager.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ash/desktop_background/desktop_background_controller.h" | 9 #include "ash/desktop_background/desktop_background_controller.h" |
10 #include "ash/desktop_background/desktop_background_resources.h" | 10 #include "ash/desktop_background/desktop_background_resources.h" |
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 base::Bind(&WallpaperManager::GetCustomWallpaperInternal, | 730 base::Bind(&WallpaperManager::GetCustomWallpaperInternal, |
731 base::Unretained(this), email, info, resolution, | 731 base::Unretained(this), email, info, resolution, |
732 false /* do not update wallpaper */)); | 732 false /* do not update wallpaper */)); |
733 return; | 733 return; |
734 } | 734 } |
735 LoadWallpaper(email, info, false /* do not update wallpaper */); | 735 LoadWallpaper(email, info, false /* do not update wallpaper */); |
736 } | 736 } |
737 } | 737 } |
738 | 738 |
739 void WallpaperManager::CacheThumbnail(const std::string& email, | 739 void WallpaperManager::CacheThumbnail(const std::string& email, |
740 const gfx::ImageSkia& wallpaper) { | 740 scoped_ptr<gfx::ImageSkia> wallpaper) { |
741 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 741 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
742 custom_wallpaper_thumbnail_cache_[email] = GetWallpaperThumbnail(wallpaper); | 742 custom_wallpaper_thumbnail_cache_[email] = |
| 743 GetWallpaperThumbnail(*wallpaper.get()); |
743 } | 744 } |
744 | 745 |
745 void WallpaperManager::DeleteWallpaperInList( | 746 void WallpaperManager::DeleteWallpaperInList( |
746 const std::vector<FilePath>& file_list) { | 747 const std::vector<FilePath>& file_list) { |
747 for (std::vector<FilePath>::const_iterator it = file_list.begin(); | 748 for (std::vector<FilePath>::const_iterator it = file_list.begin(); |
748 it != file_list.end(); ++it) { | 749 it != file_list.end(); ++it) { |
749 FilePath path = *it; | 750 FilePath path = *it; |
750 if (!file_util::Delete(path, false)) { | 751 if (!file_util::Delete(path, false)) { |
751 LOG(ERROR) << "Failed to remove user wallpaper."; | 752 LOG(ERROR) << "Failed to remove user wallpaper."; |
752 } | 753 } |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1076 | 1077 |
1077 if (update_wallpaper) { | 1078 if (update_wallpaper) { |
1078 ash::Shell::GetInstance()->desktop_background_controller()-> | 1079 ash::Shell::GetInstance()->desktop_background_controller()-> |
1079 SetDefaultWallpaper(ash::GetDefaultWallpaperIndex()); | 1080 SetDefaultWallpaper(ash::GetDefaultWallpaperIndex()); |
1080 } else { | 1081 } else { |
1081 ash::Shell::GetInstance()->desktop_background_controller()-> | 1082 ash::Shell::GetInstance()->desktop_background_controller()-> |
1082 CacheDefaultWallpaper(ash::GetDefaultWallpaperIndex()); | 1083 CacheDefaultWallpaper(ash::GetDefaultWallpaperIndex()); |
1083 } | 1084 } |
1084 return; | 1085 return; |
1085 } | 1086 } |
| 1087 // Generate all reps before passing to another thread. |
| 1088 wallpaper.image().EnsureRepsForSupportedScaleFactors(); |
| 1089 scoped_ptr<gfx::ImageSkia> deep_copy(wallpaper.image().DeepCopy()); |
1086 | 1090 |
1087 BrowserThread::PostTask( | 1091 BrowserThread::PostTask( |
1088 BrowserThread::FILE, | 1092 BrowserThread::FILE, |
1089 FROM_HERE, | 1093 FROM_HERE, |
1090 base::Bind(&WallpaperManager::CacheThumbnail, | 1094 base::Bind(&WallpaperManager::CacheThumbnail, |
1091 base::Unretained(this), email, | 1095 base::Unretained(this), email, |
1092 wallpaper.image().DeepCopy())); | 1096 base::Passed(&deep_copy))); |
1093 // Only cache user wallpaper at login screen. | 1097 // Only cache user wallpaper at login screen. |
1094 if (!UserManager::Get()->IsUserLoggedIn()) { | 1098 if (!UserManager::Get()->IsUserLoggedIn()) { |
1095 wallpaper_cache_.insert(std::make_pair(email, wallpaper.image())); | 1099 wallpaper_cache_.insert(std::make_pair(email, wallpaper.image())); |
1096 } | 1100 } |
1097 if (update_wallpaper) { | 1101 if (update_wallpaper) { |
1098 ash::Shell::GetInstance()->desktop_background_controller()-> | 1102 ash::Shell::GetInstance()->desktop_background_controller()-> |
1099 SetCustomWallpaper(wallpaper.image(), layout); | 1103 SetCustomWallpaper(wallpaper.image(), layout); |
1100 } | 1104 } |
1101 } | 1105 } |
1102 | 1106 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1196 FROM_HERE, | 1200 FROM_HERE, |
1197 base::Bind(&WallpaperManager::StartLoad, | 1201 base::Bind(&WallpaperManager::StartLoad, |
1198 base::Unretained(this), | 1202 base::Unretained(this), |
1199 email, | 1203 email, |
1200 info, | 1204 info, |
1201 update_wallpaper, | 1205 update_wallpaper, |
1202 valid_path)); | 1206 valid_path)); |
1203 } | 1207 } |
1204 | 1208 |
1205 } // chromeos | 1209 } // chromeos |
OLD | NEW |