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

Side by Side Diff: chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.cc

Issue 620663005: Lock screen for Chrome-Athena (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed crash Created 6 years, 2 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
OLDNEW
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
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
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)
Jun Mukai 2014/10/13 18:20:24 bshe is working for wallpapers IIRC. Can you conta
oshima 2014/10/13 18:52:20 crbug.com/408734
Dmitry Polukhin 2014/10/14 11:20:34 Done.
1304 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1307 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1305 user_manager::UserList users = user_manager::UserManager::Get()->GetUsers(); 1308 user_manager::UserList users = user_manager::UserManager::Get()->GetUsers();
1306 1309
1307 if (!users.empty()) { 1310 if (!users.empty()) {
1308 user_manager::UserList::const_iterator it = users.begin(); 1311 user_manager::UserList::const_iterator it = users.begin();
1309 // Skip the wallpaper of first user in the list. It should have been cached. 1312 // Skip the wallpaper of first user in the list. It should have been cached.
1310 it++; 1313 it++;
1311 for (int cached = 0; 1314 for (int cached = 0;
1312 it != users.end() && cached < kMaxWallpapersToCache; 1315 it != users.end() && cached < kMaxWallpapersToCache;
1313 ++it, ++cached) { 1316 ++it, ++cached) {
1314 std::string user_id = (*it)->email(); 1317 std::string user_id = (*it)->email();
1315 CacheUserWallpaper(user_id); 1318 CacheUserWallpaper(user_id);
1316 } 1319 }
1317 } 1320 }
1321 #endif
1318 } 1322 }
1319 1323
1320 void WallpaperManager::CacheUserWallpaper(const std::string& user_id) { 1324 void WallpaperManager::CacheUserWallpaper(const std::string& user_id) {
1321 if (wallpaper_cache_.find(user_id) != wallpaper_cache_.end()) 1325 if (wallpaper_cache_.find(user_id) != wallpaper_cache_.end())
1322 return; 1326 return;
1323 WallpaperInfo info; 1327 WallpaperInfo info;
1324 if (GetUserWallpaperInfo(user_id, &info)) { 1328 if (GetUserWallpaperInfo(user_id, &info)) {
1325 if (info.location.empty()) 1329 if (info.location.empty())
1326 return; 1330 return;
1327 1331
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
1942 void WallpaperManager::CreateSolidDefaultWallpaper() { 1946 void WallpaperManager::CreateSolidDefaultWallpaper() {
1943 loaded_wallpapers_++; 1947 loaded_wallpapers_++;
1944 SkBitmap bitmap; 1948 SkBitmap bitmap;
1945 bitmap.allocN32Pixels(1, 1); 1949 bitmap.allocN32Pixels(1, 1);
1946 bitmap.eraseColor(kDefaultWallpaperColor); 1950 bitmap.eraseColor(kDefaultWallpaperColor);
1947 const gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(bitmap); 1951 const gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(bitmap);
1948 default_wallpaper_image_.reset(new user_manager::UserImage(image)); 1952 default_wallpaper_image_.reset(new user_manager::UserImage(image));
1949 } 1953 }
1950 1954
1951 } // namespace chromeos 1955 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698