OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/users/wallpaper/wallpaper_manager.h" | 5 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
6 | 6 |
7 #include <numeric> | 7 #include <numeric> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/ash_constants.h" | 10 #include "ash/ash_constants.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // A dictionary pref that maps usernames to wallpaper properties. | 75 // A dictionary pref that maps usernames to wallpaper properties. |
76 const char kUserWallpapersProperties[] = "UserWallpapersProperties"; | 76 const char kUserWallpapersProperties[] = "UserWallpapersProperties"; |
77 | 77 |
78 // Names of nodes with info about wallpaper in |kUserWallpapersProperties| | 78 // Names of nodes with info about wallpaper in |kUserWallpapersProperties| |
79 // dictionary. | 79 // dictionary. |
80 const char kNewWallpaperDateNodeName[] = "date"; | 80 const char kNewWallpaperDateNodeName[] = "date"; |
81 const char kNewWallpaperLayoutNodeName[] = "layout"; | 81 const char kNewWallpaperLayoutNodeName[] = "layout"; |
82 const char kNewWallpaperLocationNodeName[] = "file"; | 82 const char kNewWallpaperLocationNodeName[] = "file"; |
83 const char kNewWallpaperTypeNodeName[] = "type"; | 83 const char kNewWallpaperTypeNodeName[] = "type"; |
84 | 84 |
| 85 #if !defined(USE_ATHENA) |
85 // Maximum number of wallpapers cached by CacheUsersWallpapers(). | 86 // Maximum number of wallpapers cached by CacheUsersWallpapers(). |
86 const int kMaxWallpapersToCache = 3; | 87 const int kMaxWallpapersToCache = 3; |
| 88 #endif |
87 | 89 |
88 // Maximum number of entries in WallpaperManager::last_load_times_ . | 90 // Maximum number of entries in WallpaperManager::last_load_times_ . |
89 const size_t kLastLoadsStatsMsMaxSize = 4; | 91 const size_t kLastLoadsStatsMsMaxSize = 4; |
90 | 92 |
91 // Minimum delay between wallpaper loads, milliseconds. | 93 // Minimum delay between wallpaper loads, milliseconds. |
92 const unsigned kLoadMinDelayMs = 50; | 94 const unsigned kLoadMinDelayMs = 50; |
93 | 95 |
94 // Default wallpaper load delay, milliseconds. | 96 // Default wallpaper load delay, milliseconds. |
95 const unsigned kLoadDefaultDelayMs = 200; | 97 const unsigned kLoadDefaultDelayMs = 200; |
96 | 98 |
(...skipping 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1294 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1296 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1295 CustomWallpaperMap::const_iterator it = wallpaper_cache_.find(user_id); | 1297 CustomWallpaperMap::const_iterator it = wallpaper_cache_.find(user_id); |
1296 if (it != wallpaper_cache_.end()) { | 1298 if (it != wallpaper_cache_.end()) { |
1297 *image = (*it).second; | 1299 *image = (*it).second; |
1298 return true; | 1300 return true; |
1299 } | 1301 } |
1300 return false; | 1302 return false; |
1301 } | 1303 } |
1302 | 1304 |
1303 void WallpaperManager::CacheUsersWallpapers() { | 1305 void WallpaperManager::CacheUsersWallpapers() { |
| 1306 #if !defined(USE_ATHENA) |
| 1307 // TODO(dpolukhin): crbug.com/408734. |
1304 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1308 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1305 user_manager::UserList users = user_manager::UserManager::Get()->GetUsers(); | 1309 user_manager::UserList users = user_manager::UserManager::Get()->GetUsers(); |
1306 | 1310 |
1307 if (!users.empty()) { | 1311 if (!users.empty()) { |
1308 user_manager::UserList::const_iterator it = users.begin(); | 1312 user_manager::UserList::const_iterator it = users.begin(); |
1309 // Skip the wallpaper of first user in the list. It should have been cached. | 1313 // Skip the wallpaper of first user in the list. It should have been cached. |
1310 it++; | 1314 it++; |
1311 for (int cached = 0; | 1315 for (int cached = 0; |
1312 it != users.end() && cached < kMaxWallpapersToCache; | 1316 it != users.end() && cached < kMaxWallpapersToCache; |
1313 ++it, ++cached) { | 1317 ++it, ++cached) { |
1314 std::string user_id = (*it)->email(); | 1318 std::string user_id = (*it)->email(); |
1315 CacheUserWallpaper(user_id); | 1319 CacheUserWallpaper(user_id); |
1316 } | 1320 } |
1317 } | 1321 } |
| 1322 #endif |
1318 } | 1323 } |
1319 | 1324 |
1320 void WallpaperManager::CacheUserWallpaper(const std::string& user_id) { | 1325 void WallpaperManager::CacheUserWallpaper(const std::string& user_id) { |
1321 if (wallpaper_cache_.find(user_id) != wallpaper_cache_.end()) | 1326 if (wallpaper_cache_.find(user_id) != wallpaper_cache_.end()) |
1322 return; | 1327 return; |
1323 WallpaperInfo info; | 1328 WallpaperInfo info; |
1324 if (GetUserWallpaperInfo(user_id, &info)) { | 1329 if (GetUserWallpaperInfo(user_id, &info)) { |
1325 if (info.location.empty()) | 1330 if (info.location.empty()) |
1326 return; | 1331 return; |
1327 | 1332 |
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1949 void WallpaperManager::CreateSolidDefaultWallpaper() { | 1954 void WallpaperManager::CreateSolidDefaultWallpaper() { |
1950 loaded_wallpapers_++; | 1955 loaded_wallpapers_++; |
1951 SkBitmap bitmap; | 1956 SkBitmap bitmap; |
1952 bitmap.allocN32Pixels(1, 1); | 1957 bitmap.allocN32Pixels(1, 1); |
1953 bitmap.eraseColor(kDefaultWallpaperColor); | 1958 bitmap.eraseColor(kDefaultWallpaperColor); |
1954 const gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(bitmap); | 1959 const gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(bitmap); |
1955 default_wallpaper_image_.reset(new user_manager::UserImage(image)); | 1960 default_wallpaper_image_.reset(new user_manager::UserImage(image)); |
1956 } | 1961 } |
1957 | 1962 |
1958 } // namespace chromeos | 1963 } // namespace chromeos |
OLD | NEW |