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

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

Issue 375413002: Replace chromeos::UserManager::Get() with chromeos::GetUserManager(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test Created 6 years, 5 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
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 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 if (!ash::Shell::HasInstance()) 538 if (!ash::Shell::HasInstance())
539 return; 539 return;
540 540
541 WallpaperInfo info; 541 WallpaperInfo info;
542 if (GetLoggedInUserWallpaperInfo(&info)) { 542 if (GetLoggedInUserWallpaperInfo(&info)) {
543 // TODO(sschmitz): We need an index for default wallpapers for the new UI. 543 // TODO(sschmitz): We need an index for default wallpapers for the new UI.
544 RecordUma(info.type, -1); 544 RecordUma(info.type, -1);
545 if (info == current_user_wallpaper_info_) 545 if (info == current_user_wallpaper_info_)
546 return; 546 return;
547 } 547 }
548 SetUserWallpaperNow(UserManager::Get()->GetLoggedInUser()->email()); 548 SetUserWallpaperNow(GetUserManager()->GetLoggedInUser()->email());
549 } 549 }
550 550
551 void WallpaperManager::ClearDisposableWallpaperCache() { 551 void WallpaperManager::ClearDisposableWallpaperCache() {
552 // Cancel callback for previous cache requests. 552 // Cancel callback for previous cache requests.
553 weak_factory_.InvalidateWeakPtrs(); 553 weak_factory_.InvalidateWeakPtrs();
554 // Keep the wallpaper of logged in users in cache at multi-profile mode. 554 // Keep the wallpaper of logged in users in cache at multi-profile mode.
555 std::set<std::string> logged_in_users_names; 555 std::set<std::string> logged_in_users_names;
556 const UserList& logged_users = UserManager::Get()->GetLoggedInUsers(); 556 const UserList& logged_users = GetUserManager()->GetLoggedInUsers();
557 for (UserList::const_iterator it = logged_users.begin(); 557 for (UserList::const_iterator it = logged_users.begin();
558 it != logged_users.end(); 558 it != logged_users.end();
559 ++it) { 559 ++it) {
560 logged_in_users_names.insert((*it)->email()); 560 logged_in_users_names.insert((*it)->email());
561 } 561 }
562 562
563 CustomWallpaperMap logged_in_users_cache; 563 CustomWallpaperMap logged_in_users_cache;
564 for (CustomWallpaperMap::iterator it = wallpaper_cache_.begin(); 564 for (CustomWallpaperMap::iterator it = wallpaper_cache_.begin();
565 it != wallpaper_cache_.end(); ++it) { 565 it != wallpaper_cache_.end(); ++it) {
566 if (logged_in_users_names.find(it->first) != 566 if (logged_in_users_names.find(it->first) !=
567 logged_in_users_names.end()) { 567 logged_in_users_names.end()) {
568 logged_in_users_cache.insert(*it); 568 logged_in_users_cache.insert(*it);
569 } 569 }
570 } 570 }
571 wallpaper_cache_ = logged_in_users_cache; 571 wallpaper_cache_ = logged_in_users_cache;
572 } 572 }
573 573
574 bool WallpaperManager::GetLoggedInUserWallpaperInfo(WallpaperInfo* info) { 574 bool WallpaperManager::GetLoggedInUserWallpaperInfo(WallpaperInfo* info) {
575 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 575 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
576 576
577 if (UserManager::Get()->IsLoggedInAsStub()) { 577 if (GetUserManager()->IsLoggedInAsStub()) {
578 info->file = current_user_wallpaper_info_.file = ""; 578 info->file = current_user_wallpaper_info_.file = "";
579 info->layout = current_user_wallpaper_info_.layout = 579 info->layout = current_user_wallpaper_info_.layout =
580 ash::WALLPAPER_LAYOUT_CENTER_CROPPED; 580 ash::WALLPAPER_LAYOUT_CENTER_CROPPED;
581 info->type = current_user_wallpaper_info_.type = User::DEFAULT; 581 info->type = current_user_wallpaper_info_.type = User::DEFAULT;
582 info->date = current_user_wallpaper_info_.date = 582 info->date = current_user_wallpaper_info_.date =
583 base::Time::Now().LocalMidnight(); 583 base::Time::Now().LocalMidnight();
584 return true; 584 return true;
585 } 585 }
586 586
587 return GetUserWallpaperInfo(UserManager::Get()->GetLoggedInUser()->email(), 587 return GetUserWallpaperInfo(GetUserManager()->GetLoggedInUser()->email(),
588 info); 588 info);
589 } 589 }
590 590
591 void WallpaperManager::InitializeWallpaper() { 591 void WallpaperManager::InitializeWallpaper() {
592 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 592 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
593 UserManager* user_manager = UserManager::Get(); 593 UserManager* user_manager = GetUserManager();
594 594
595 // Apply device customization. 595 // Apply device customization.
596 if (ShouldUseCustomizedDefaultWallpaper()) { 596 if (ShouldUseCustomizedDefaultWallpaper()) {
597 SetDefaultWallpaperPath( 597 SetDefaultWallpaperPath(
598 GetCustomizedWallpaperDefaultRescaledFileName(kSmallWallpaperSuffix), 598 GetCustomizedWallpaperDefaultRescaledFileName(kSmallWallpaperSuffix),
599 scoped_ptr<gfx::ImageSkia>().Pass(), 599 scoped_ptr<gfx::ImageSkia>().Pass(),
600 GetCustomizedWallpaperDefaultRescaledFileName(kLargeWallpaperSuffix), 600 GetCustomizedWallpaperDefaultRescaledFileName(kLargeWallpaperSuffix),
601 scoped_ptr<gfx::ImageSkia>().Pass()); 601 scoped_ptr<gfx::ImageSkia>().Pass());
602 } 602 }
603 603
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 const char* sub_dir, 827 const char* sub_dir,
828 const std::string& user_id_hash, 828 const std::string& user_id_hash,
829 const std::string& file) { 829 const std::string& file) {
830 base::FilePath custom_wallpaper_path = GetCustomWallpaperDir(sub_dir); 830 base::FilePath custom_wallpaper_path = GetCustomWallpaperDir(sub_dir);
831 return custom_wallpaper_path.Append(user_id_hash).Append(file); 831 return custom_wallpaper_path.Append(user_id_hash).Append(file);
832 } 832 }
833 833
834 void WallpaperManager::SetPolicyControlledWallpaper( 834 void WallpaperManager::SetPolicyControlledWallpaper(
835 const std::string& user_id, 835 const std::string& user_id,
836 const UserImage& user_image) { 836 const UserImage& user_image) {
837 const User *user = chromeos::UserManager::Get()->FindUser(user_id); 837 const User* user = chromeos::GetUserManager()->FindUser(user_id);
838 if (!user) { 838 if (!user) {
839 NOTREACHED() << "Unknown user."; 839 NOTREACHED() << "Unknown user.";
840 return; 840 return;
841 } 841 }
842 SetCustomWallpaper(user_id, 842 SetCustomWallpaper(user_id,
843 user->username_hash(), 843 user->username_hash(),
844 "policy-controlled.jpeg", 844 "policy-controlled.jpeg",
845 ash::WALLPAPER_LAYOUT_CENTER_CROPPED, 845 ash::WALLPAPER_LAYOUT_CENTER_CROPPED,
846 User::POLICY, 846 User::POLICY,
847 user_image.image(), 847 user_image.image(),
848 true /* update wallpaper */); 848 true /* update wallpaper */);
849 } 849 }
850 850
851 void WallpaperManager::SetCustomWallpaper(const std::string& user_id, 851 void WallpaperManager::SetCustomWallpaper(const std::string& user_id,
852 const std::string& user_id_hash, 852 const std::string& user_id_hash,
853 const std::string& file, 853 const std::string& file,
854 ash::WallpaperLayout layout, 854 ash::WallpaperLayout layout,
855 User::WallpaperType type, 855 User::WallpaperType type,
856 const gfx::ImageSkia& image, 856 const gfx::ImageSkia& image,
857 bool update_wallpaper) { 857 bool update_wallpaper) {
858 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 858 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
859 DCHECK(UserManager::Get()->IsUserLoggedIn()); 859 DCHECK(GetUserManager()->IsUserLoggedIn());
860 860
861 // There is no visible background in kiosk mode. 861 // There is no visible background in kiosk mode.
862 if (UserManager::Get()->IsLoggedInAsKioskApp()) 862 if (GetUserManager()->IsLoggedInAsKioskApp())
863 return; 863 return;
864 864
865 // Don't allow custom wallpapers while policy is in effect. 865 // Don't allow custom wallpapers while policy is in effect.
866 if (type != User::POLICY && IsPolicyControlled(user_id)) 866 if (type != User::POLICY && IsPolicyControlled(user_id))
867 return; 867 return;
868 868
869 base::FilePath wallpaper_path = 869 base::FilePath wallpaper_path =
870 GetCustomWallpaperPath(kOriginalWallpaperSubDir, user_id_hash, file); 870 GetCustomWallpaperPath(kOriginalWallpaperSubDir, user_id_hash, file);
871 871
872 // If decoded wallpaper is empty, we have probably failed to decode the file. 872 // If decoded wallpaper is empty, we have probably failed to decode the file.
873 // Use default wallpaper in this case. 873 // Use default wallpaper in this case.
874 if (image.isNull()) { 874 if (image.isNull()) {
875 SetDefaultWallpaperDelayed(user_id); 875 SetDefaultWallpaperDelayed(user_id);
876 return; 876 return;
877 } 877 }
878 878
879 bool is_persistent = 879 bool is_persistent =
880 !UserManager::Get()->IsUserNonCryptohomeDataEphemeral(user_id); 880 !GetUserManager()->IsUserNonCryptohomeDataEphemeral(user_id);
881 881
882 WallpaperInfo wallpaper_info = { 882 WallpaperInfo wallpaper_info = {
883 wallpaper_path.value(), 883 wallpaper_path.value(),
884 layout, 884 layout,
885 type, 885 type,
886 // Date field is not used. 886 // Date field is not used.
887 base::Time::Now().LocalMidnight() 887 base::Time::Now().LocalMidnight()
888 }; 888 };
889 if (is_persistent) { 889 if (is_persistent) {
890 image.EnsureRepsForSupportedScales(); 890 image.EnsureRepsForSupportedScales();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 } 927 }
928 928
929 void WallpaperManager::SetDefaultWallpaperDelayed(const std::string& user_id) { 929 void WallpaperManager::SetDefaultWallpaperDelayed(const std::string& user_id) {
930 GetPendingWallpaper(user_id, true)->ResetSetDefaultWallpaper(); 930 GetPendingWallpaper(user_id, true)->ResetSetDefaultWallpaper();
931 } 931 }
932 932
933 void WallpaperManager::DoSetDefaultWallpaper( 933 void WallpaperManager::DoSetDefaultWallpaper(
934 const std::string& user_id, 934 const std::string& user_id,
935 MovableOnDestroyCallbackHolder on_finish) { 935 MovableOnDestroyCallbackHolder on_finish) {
936 // There is no visible background in kiosk mode. 936 // There is no visible background in kiosk mode.
937 if (UserManager::Get()->IsLoggedInAsKioskApp()) 937 if (GetUserManager()->IsLoggedInAsKioskApp())
938 return; 938 return;
939 current_wallpaper_path_.clear(); 939 current_wallpaper_path_.clear();
940 wallpaper_cache_.erase(user_id); 940 wallpaper_cache_.erase(user_id);
941 // Some browser tests do not have a shell instance. As no wallpaper is needed 941 // Some browser tests do not have a shell instance. As no wallpaper is needed
942 // in these tests anyway, avoid loading one, preventing crashes and speeding 942 // in these tests anyway, avoid loading one, preventing crashes and speeding
943 // up the tests. 943 // up the tests.
944 if (!ash::Shell::HasInstance()) 944 if (!ash::Shell::HasInstance())
945 return; 945 return;
946 946
947 WallpaperResolution resolution = GetAppropriateResolution(); 947 WallpaperResolution resolution = GetAppropriateResolution();
948 const bool use_small = (resolution == WALLPAPER_RESOLUTION_SMALL); 948 const bool use_small = (resolution == WALLPAPER_RESOLUTION_SMALL);
949 949
950 const base::FilePath* file = NULL; 950 const base::FilePath* file = NULL;
951 951
952 if (UserManager::Get()->IsLoggedInAsGuest()) { 952 if (GetUserManager()->IsLoggedInAsGuest()) {
953 file = 953 file =
954 use_small ? &guest_small_wallpaper_file_ : &guest_large_wallpaper_file_; 954 use_small ? &guest_small_wallpaper_file_ : &guest_large_wallpaper_file_;
955 } else { 955 } else {
956 file = use_small ? &default_small_wallpaper_file_ 956 file = use_small ? &default_small_wallpaper_file_
957 : &default_large_wallpaper_file_; 957 : &default_large_wallpaper_file_;
958 } 958 }
959 ash::WallpaperLayout layout = use_small 959 ash::WallpaperLayout layout = use_small
960 ? ash::WALLPAPER_LAYOUT_CENTER 960 ? ash::WALLPAPER_LAYOUT_CENTER
961 : ash::WALLPAPER_LAYOUT_CENTER_CROPPED; 961 : ash::WALLPAPER_LAYOUT_CENTER_CROPPED;
962 DCHECK(file); 962 DCHECK(file);
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 ScheduleSetUserWallpaper(user_id, false); 1138 ScheduleSetUserWallpaper(user_id, false);
1139 } 1139 }
1140 1140
1141 void WallpaperManager::ScheduleSetUserWallpaper(const std::string& user_id, 1141 void WallpaperManager::ScheduleSetUserWallpaper(const std::string& user_id,
1142 bool delayed) { 1142 bool delayed) {
1143 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1143 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1144 // Some unit tests come here without a UserManager or without a pref system. 1144 // Some unit tests come here without a UserManager or without a pref system.
1145 if (!UserManager::IsInitialized() || !g_browser_process->local_state()) 1145 if (!UserManager::IsInitialized() || !g_browser_process->local_state())
1146 return; 1146 return;
1147 // There is no visible background in kiosk mode. 1147 // There is no visible background in kiosk mode.
1148 if (UserManager::Get()->IsLoggedInAsKioskApp()) 1148 if (GetUserManager()->IsLoggedInAsKioskApp())
1149 return; 1149 return;
1150 // Guest user, regular user in ephemeral mode, or kiosk app. 1150 // Guest user, regular user in ephemeral mode, or kiosk app.
1151 const User* user = UserManager::Get()->FindUser(user_id); 1151 const User* user = GetUserManager()->FindUser(user_id);
1152 if (UserManager::Get()->IsUserNonCryptohomeDataEphemeral(user_id) || 1152 if (GetUserManager()->IsUserNonCryptohomeDataEphemeral(user_id) ||
1153 (user != NULL && user->GetType() == user_manager::USER_TYPE_KIOSK_APP)) { 1153 (user != NULL && user->GetType() == user_manager::USER_TYPE_KIOSK_APP)) {
1154 InitInitialUserWallpaper(user_id, false); 1154 InitInitialUserWallpaper(user_id, false);
1155 GetPendingWallpaper(user_id, delayed)->ResetSetDefaultWallpaper(); 1155 GetPendingWallpaper(user_id, delayed)->ResetSetDefaultWallpaper();
1156 return; 1156 return;
1157 } 1157 }
1158 1158
1159 if (!UserManager::Get()->IsKnownUser(user_id)) 1159 if (!GetUserManager()->IsKnownUser(user_id))
1160 return; 1160 return;
1161 1161
1162 last_selected_user_ = user_id; 1162 last_selected_user_ = user_id;
1163 1163
1164 WallpaperInfo info; 1164 WallpaperInfo info;
1165 1165
1166 if (!GetUserWallpaperInfo(user_id, &info)) { 1166 if (!GetUserWallpaperInfo(user_id, &info)) {
1167 InitInitialUserWallpaper(user_id, true); 1167 InitInitialUserWallpaper(user_id, true);
1168 GetUserWallpaperInfo(user_id, &info); 1168 GetUserWallpaperInfo(user_id, &info);
1169 } 1169 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 1202
1203 // Load downloaded ONLINE or converted DEFAULT wallpapers. 1203 // Load downloaded ONLINE or converted DEFAULT wallpapers.
1204 GetPendingWallpaper(user_id, delayed)->ResetLoadWallpaper(info); 1204 GetPendingWallpaper(user_id, delayed)->ResetLoadWallpaper(info);
1205 } 1205 }
1206 } 1206 }
1207 1207
1208 void WallpaperManager::SetWallpaperFromImageSkia(const std::string& user_id, 1208 void WallpaperManager::SetWallpaperFromImageSkia(const std::string& user_id,
1209 const gfx::ImageSkia& image, 1209 const gfx::ImageSkia& image,
1210 ash::WallpaperLayout layout, 1210 ash::WallpaperLayout layout,
1211 bool update_wallpaper) { 1211 bool update_wallpaper) {
1212 DCHECK(UserManager::Get()->IsUserLoggedIn()); 1212 DCHECK(GetUserManager()->IsUserLoggedIn());
1213 1213
1214 // There is no visible background in kiosk mode. 1214 // There is no visible background in kiosk mode.
1215 if (UserManager::Get()->IsLoggedInAsKioskApp()) 1215 if (GetUserManager()->IsLoggedInAsKioskApp())
1216 return; 1216 return;
1217 WallpaperInfo info; 1217 WallpaperInfo info;
1218 info.layout = layout; 1218 info.layout = layout;
1219 wallpaper_cache_[user_id] = image; 1219 wallpaper_cache_[user_id] = image;
1220 1220
1221 if (update_wallpaper) { 1221 if (update_wallpaper) {
1222 GetPendingWallpaper(last_selected_user_, false /* Not delayed */) 1222 GetPendingWallpaper(last_selected_user_, false /* Not delayed */)
1223 ->ResetSetWallpaperImage(image, info); 1223 ->ResetSetWallpaperImage(image, info);
1224 } 1224 }
1225 } 1225 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 CustomWallpaperMap::const_iterator it = wallpaper_cache_.find(user_id); 1261 CustomWallpaperMap::const_iterator it = wallpaper_cache_.find(user_id);
1262 if (it != wallpaper_cache_.end()) { 1262 if (it != wallpaper_cache_.end()) {
1263 *image = (*it).second; 1263 *image = (*it).second;
1264 return true; 1264 return true;
1265 } 1265 }
1266 return false; 1266 return false;
1267 } 1267 }
1268 1268
1269 void WallpaperManager::CacheUsersWallpapers() { 1269 void WallpaperManager::CacheUsersWallpapers() {
1270 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1270 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1271 UserList users = UserManager::Get()->GetUsers(); 1271 UserList users = GetUserManager()->GetUsers();
1272 1272
1273 if (!users.empty()) { 1273 if (!users.empty()) {
1274 UserList::const_iterator it = users.begin(); 1274 UserList::const_iterator it = users.begin();
1275 // Skip the wallpaper of first user in the list. It should have been cached. 1275 // Skip the wallpaper of first user in the list. It should have been cached.
1276 it++; 1276 it++;
1277 for (int cached = 0; 1277 for (int cached = 0;
1278 it != users.end() && cached < kMaxWallpapersToCache; 1278 it != users.end() && cached < kMaxWallpapersToCache;
1279 ++it, ++cached) { 1279 ++it, ++cached) {
1280 std::string user_id = (*it)->email(); 1280 std::string user_id = (*it)->email();
1281 CacheUserWallpaper(user_id); 1281 CacheUserWallpaper(user_id);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1365 SetDefaultWallpaperPathsFromCommandLine(command_line); 1365 SetDefaultWallpaperPathsFromCommandLine(command_line);
1366 } 1366 }
1367 1367
1368 CommandLine* WallpaperManager::GetCommandLine() { 1368 CommandLine* WallpaperManager::GetCommandLine() {
1369 CommandLine* command_line = command_line_for_testing_ ? 1369 CommandLine* command_line = command_line_for_testing_ ?
1370 command_line_for_testing_ : CommandLine::ForCurrentProcess(); 1370 command_line_for_testing_ : CommandLine::ForCurrentProcess();
1371 return command_line; 1371 return command_line;
1372 } 1372 }
1373 1373
1374 void WallpaperManager::InitializeRegisteredDeviceWallpaper() { 1374 void WallpaperManager::InitializeRegisteredDeviceWallpaper() {
1375 if (UserManager::Get()->IsUserLoggedIn()) 1375 if (GetUserManager()->IsUserLoggedIn())
1376 return; 1376 return;
1377 1377
1378 bool disable_boot_animation = 1378 bool disable_boot_animation =
1379 GetCommandLine()->HasSwitch(switches::kDisableBootAnimation); 1379 GetCommandLine()->HasSwitch(switches::kDisableBootAnimation);
1380 bool show_users = true; 1380 bool show_users = true;
1381 bool result = CrosSettings::Get()->GetBoolean( 1381 bool result = CrosSettings::Get()->GetBoolean(
1382 kAccountsPrefShowUserNamesOnSignIn, &show_users); 1382 kAccountsPrefShowUserNamesOnSignIn, &show_users);
1383 DCHECK(result) << "Unable to fetch setting " 1383 DCHECK(result) << "Unable to fetch setting "
1384 << kAccountsPrefShowUserNamesOnSignIn; 1384 << kAccountsPrefShowUserNamesOnSignIn;
1385 const chromeos::UserList& users = UserManager::Get()->GetUsers(); 1385 const chromeos::UserList& users = GetUserManager()->GetUsers();
1386 int public_session_user_index = FindPublicSession(users); 1386 int public_session_user_index = FindPublicSession(users);
1387 if ((!show_users && public_session_user_index == -1) || users.empty()) { 1387 if ((!show_users && public_session_user_index == -1) || users.empty()) {
1388 // Boot into sign in form, preload default wallpaper. 1388 // Boot into sign in form, preload default wallpaper.
1389 SetDefaultWallpaperDelayed(UserManager::kSignInUser); 1389 SetDefaultWallpaperDelayed(UserManager::kSignInUser);
1390 return; 1390 return;
1391 } 1391 }
1392 1392
1393 if (!disable_boot_animation) { 1393 if (!disable_boot_animation) {
1394 int index = public_session_user_index != -1 ? public_session_user_index : 0; 1394 int index = public_session_user_index != -1 ? public_session_user_index : 0;
1395 // Normal boot, load user wallpaper. 1395 // Normal boot, load user wallpaper.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1459 // crosbug.com/38429. 1459 // crosbug.com/38429.
1460 LOG(ERROR) << "Wallpaper reverts to default unexpected."; 1460 LOG(ERROR) << "Wallpaper reverts to default unexpected.";
1461 DoSetDefaultWallpaper(user_id, on_finish.Pass()); 1461 DoSetDefaultWallpaper(user_id, on_finish.Pass());
1462 } 1462 }
1463 } 1463 }
1464 1464
1465 bool WallpaperManager::GetUserWallpaperInfo(const std::string& user_id, 1465 bool WallpaperManager::GetUserWallpaperInfo(const std::string& user_id,
1466 WallpaperInfo* info) const { 1466 WallpaperInfo* info) const {
1467 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1467 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1468 1468
1469 if (UserManager::Get()->IsUserNonCryptohomeDataEphemeral(user_id)) { 1469 if (GetUserManager()->IsUserNonCryptohomeDataEphemeral(user_id)) {
1470 // Default to the values cached in memory. 1470 // Default to the values cached in memory.
1471 *info = current_user_wallpaper_info_; 1471 *info = current_user_wallpaper_info_;
1472 1472
1473 // Ephemeral users do not save anything to local state. But we have got 1473 // Ephemeral users do not save anything to local state. But we have got
1474 // wallpaper info from memory. Returns true. 1474 // wallpaper info from memory. Returns true.
1475 return true; 1475 return true;
1476 } 1476 }
1477 1477
1478 const base::DictionaryValue* info_dict; 1478 const base::DictionaryValue* info_dict;
1479 if (!g_browser_process->local_state()-> 1479 if (!g_browser_process->local_state()->
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1511 const std::string& user_id_hash) { 1511 const std::string& user_id_hash) {
1512 WallpaperInfo info; 1512 WallpaperInfo info;
1513 GetUserWallpaperInfo(user_id, &info); 1513 GetUserWallpaperInfo(user_id, &info);
1514 if (info.type == User::CUSTOMIZED) { 1514 if (info.type == User::CUSTOMIZED) {
1515 // New file field should include user id hash in addition to file name. 1515 // New file field should include user id hash in addition to file name.
1516 // This is needed because at login screen, user id hash is not available. 1516 // This is needed because at login screen, user id hash is not available.
1517 std::string relative_path = 1517 std::string relative_path =
1518 base::FilePath(user_id_hash).Append(info.file).value(); 1518 base::FilePath(user_id_hash).Append(info.file).value();
1519 info.file = relative_path; 1519 info.file = relative_path;
1520 bool is_persistent = 1520 bool is_persistent =
1521 !UserManager::Get()->IsUserNonCryptohomeDataEphemeral(user_id); 1521 !GetUserManager()->IsUserNonCryptohomeDataEphemeral(user_id);
1522 SetUserWallpaperInfo(user_id, info, is_persistent); 1522 SetUserWallpaperInfo(user_id, info, is_persistent);
1523 } 1523 }
1524 } 1524 }
1525 1525
1526 void WallpaperManager::MoveLoggedInUserCustomWallpaper() { 1526 void WallpaperManager::MoveLoggedInUserCustomWallpaper() {
1527 const User* logged_in_user = UserManager::Get()->GetLoggedInUser(); 1527 const User* logged_in_user = GetUserManager()->GetLoggedInUser();
1528 task_runner_->PostTask( 1528 task_runner_->PostTask(
1529 FROM_HERE, 1529 FROM_HERE,
1530 base::Bind(&WallpaperManager::MoveCustomWallpapersOnWorker, 1530 base::Bind(&WallpaperManager::MoveCustomWallpapersOnWorker,
1531 logged_in_user->email(), 1531 logged_in_user->email(),
1532 logged_in_user->username_hash(), 1532 logged_in_user->username_hash(),
1533 weak_factory_.GetWeakPtr())); 1533 weak_factory_.GetWeakPtr()));
1534 } 1534 }
1535 1535
1536 void WallpaperManager::OnWallpaperDecoded( 1536 void WallpaperManager::OnWallpaperDecoded(
1537 const std::string& user_id, 1537 const std::string& user_id,
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
1903 void WallpaperManager::CreateSolidDefaultWallpaper() { 1903 void WallpaperManager::CreateSolidDefaultWallpaper() {
1904 loaded_wallpapers_++; 1904 loaded_wallpapers_++;
1905 SkBitmap bitmap; 1905 SkBitmap bitmap;
1906 bitmap.allocN32Pixels(1, 1); 1906 bitmap.allocN32Pixels(1, 1);
1907 bitmap.eraseColor(kDefaultWallpaperColor); 1907 bitmap.eraseColor(kDefaultWallpaperColor);
1908 const gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(bitmap); 1908 const gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(bitmap);
1909 default_wallpaper_image_.reset(new UserImage(image)); 1909 default_wallpaper_image_.reset(new UserImage(image));
1910 } 1910 }
1911 1911
1912 } // namespace chromeos 1912 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698