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

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

Issue 444903002: [cros] user_manager component - move UserManagerBase and UserManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 4 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 16 matching lines...) Expand all
27 #include "base/strings/string_util.h" 27 #include "base/strings/string_util.h"
28 #include "base/strings/stringprintf.h" 28 #include "base/strings/stringprintf.h"
29 #include "base/sys_info.h" 29 #include "base/sys_info.h"
30 #include "base/threading/worker_pool.h" 30 #include "base/threading/worker_pool.h"
31 #include "base/time/time.h" 31 #include "base/time/time.h"
32 #include "base/values.h" 32 #include "base/values.h"
33 #include "chrome/browser/browser_process.h" 33 #include "chrome/browser/browser_process.h"
34 #include "chrome/browser/chrome_notification_types.h" 34 #include "chrome/browser/chrome_notification_types.h"
35 #include "chrome/browser/chromeos/customization_document.h" 35 #include "chrome/browser/chromeos/customization_document.h"
36 #include "chrome/browser/chromeos/login/startup_utils.h" 36 #include "chrome/browser/chromeos/login/startup_utils.h"
37 #include "chrome/browser/chromeos/login/users/user_manager.h"
38 #include "chrome/browser/chromeos/login/wizard_controller.h" 37 #include "chrome/browser/chromeos/login/wizard_controller.h"
39 #include "chrome/browser/chromeos/settings/cros_settings.h" 38 #include "chrome/browser/chromeos/settings/cros_settings.h"
40 #include "chrome/common/chrome_paths.h" 39 #include "chrome/common/chrome_paths.h"
41 #include "chrome/common/chrome_switches.h" 40 #include "chrome/common/chrome_switches.h"
42 #include "chrome/common/pref_names.h" 41 #include "chrome/common/pref_names.h"
43 #include "chromeos/chromeos_switches.h" 42 #include "chromeos/chromeos_switches.h"
44 #include "chromeos/cryptohome/async_method_caller.h" 43 #include "chromeos/cryptohome/async_method_caller.h"
45 #include "chromeos/dbus/dbus_thread_manager.h" 44 #include "chromeos/dbus/dbus_thread_manager.h"
46 #include "chromeos/login/user_names.h" 45 #include "chromeos/login/user_names.h"
47 #include "components/user_manager/user.h" 46 #include "components/user_manager/user.h"
48 #include "components/user_manager/user_image/user_image.h" 47 #include "components/user_manager/user_image/user_image.h"
48 #include "components/user_manager/user_manager.h"
49 #include "components/user_manager/user_type.h" 49 #include "components/user_manager/user_type.h"
50 #include "content/public/browser/browser_thread.h" 50 #include "content/public/browser/browser_thread.h"
51 #include "content/public/browser/notification_service.h" 51 #include "content/public/browser/notification_service.h"
52 #include "third_party/skia/include/core/SkColor.h" 52 #include "third_party/skia/include/core/SkColor.h"
53 #include "ui/gfx/codec/jpeg_codec.h" 53 #include "ui/gfx/codec/jpeg_codec.h"
54 #include "ui/gfx/image/image_skia_operations.h" 54 #include "ui/gfx/image/image_skia_operations.h"
55 #include "ui/gfx/skia_util.h" 55 #include "ui/gfx/skia_util.h"
56 56
57 using content::BrowserThread; 57 using content::BrowserThread;
58 58
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 if (!ash::Shell::HasInstance()) 529 if (!ash::Shell::HasInstance())
530 return; 530 return;
531 531
532 WallpaperInfo info; 532 WallpaperInfo info;
533 if (GetLoggedInUserWallpaperInfo(&info)) { 533 if (GetLoggedInUserWallpaperInfo(&info)) {
534 UMA_HISTOGRAM_ENUMERATION("Ash.Wallpaper.Type", info.type, 534 UMA_HISTOGRAM_ENUMERATION("Ash.Wallpaper.Type", info.type,
535 user_manager::User::WALLPAPER_TYPE_COUNT); 535 user_manager::User::WALLPAPER_TYPE_COUNT);
536 if (info == current_user_wallpaper_info_) 536 if (info == current_user_wallpaper_info_)
537 return; 537 return;
538 } 538 }
539 SetUserWallpaperNow(UserManager::Get()->GetLoggedInUser()->email()); 539 SetUserWallpaperNow(
540 user_manager::UserManager::Get()->GetLoggedInUser()->email());
540 } 541 }
541 542
542 void WallpaperManager::ClearDisposableWallpaperCache() { 543 void WallpaperManager::ClearDisposableWallpaperCache() {
543 // Cancel callback for previous cache requests. 544 // Cancel callback for previous cache requests.
544 weak_factory_.InvalidateWeakPtrs(); 545 weak_factory_.InvalidateWeakPtrs();
545 // Keep the wallpaper of logged in users in cache at multi-profile mode. 546 // Keep the wallpaper of logged in users in cache at multi-profile mode.
546 std::set<std::string> logged_in_users_names; 547 std::set<std::string> logged_in_users_names;
547 const user_manager::UserList& logged_users = 548 const user_manager::UserList& logged_users =
548 UserManager::Get()->GetLoggedInUsers(); 549 user_manager::UserManager::Get()->GetLoggedInUsers();
549 for (user_manager::UserList::const_iterator it = logged_users.begin(); 550 for (user_manager::UserList::const_iterator it = logged_users.begin();
550 it != logged_users.end(); 551 it != logged_users.end();
551 ++it) { 552 ++it) {
552 logged_in_users_names.insert((*it)->email()); 553 logged_in_users_names.insert((*it)->email());
553 } 554 }
554 555
555 CustomWallpaperMap logged_in_users_cache; 556 CustomWallpaperMap logged_in_users_cache;
556 for (CustomWallpaperMap::iterator it = wallpaper_cache_.begin(); 557 for (CustomWallpaperMap::iterator it = wallpaper_cache_.begin();
557 it != wallpaper_cache_.end(); ++it) { 558 it != wallpaper_cache_.end(); ++it) {
558 if (logged_in_users_names.find(it->first) != 559 if (logged_in_users_names.find(it->first) !=
559 logged_in_users_names.end()) { 560 logged_in_users_names.end()) {
560 logged_in_users_cache.insert(*it); 561 logged_in_users_cache.insert(*it);
561 } 562 }
562 } 563 }
563 wallpaper_cache_ = logged_in_users_cache; 564 wallpaper_cache_ = logged_in_users_cache;
564 } 565 }
565 566
566 bool WallpaperManager::GetLoggedInUserWallpaperInfo(WallpaperInfo* info) { 567 bool WallpaperManager::GetLoggedInUserWallpaperInfo(WallpaperInfo* info) {
567 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 568 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
568 569
569 if (UserManager::Get()->IsLoggedInAsStub()) { 570 if (user_manager::UserManager::Get()->IsLoggedInAsStub()) {
570 info->location = current_user_wallpaper_info_.location = ""; 571 info->location = current_user_wallpaper_info_.location = "";
571 info->layout = current_user_wallpaper_info_.layout = 572 info->layout = current_user_wallpaper_info_.layout =
572 ash::WALLPAPER_LAYOUT_CENTER_CROPPED; 573 ash::WALLPAPER_LAYOUT_CENTER_CROPPED;
573 info->type = current_user_wallpaper_info_.type = 574 info->type = current_user_wallpaper_info_.type =
574 user_manager::User::DEFAULT; 575 user_manager::User::DEFAULT;
575 info->date = current_user_wallpaper_info_.date = 576 info->date = current_user_wallpaper_info_.date =
576 base::Time::Now().LocalMidnight(); 577 base::Time::Now().LocalMidnight();
577 return true; 578 return true;
578 } 579 }
579 580
580 return GetUserWallpaperInfo(UserManager::Get()->GetLoggedInUser()->email(), 581 return GetUserWallpaperInfo(
581 info); 582 user_manager::UserManager::Get()->GetLoggedInUser()->email(), info);
582 } 583 }
583 584
584 void WallpaperManager::InitializeWallpaper() { 585 void WallpaperManager::InitializeWallpaper() {
585 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 586 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
586 UserManager* user_manager = UserManager::Get(); 587 user_manager::UserManager* user_manager = user_manager::UserManager::Get();
587 588
588 // Apply device customization. 589 // Apply device customization.
589 if (ShouldUseCustomizedDefaultWallpaper()) { 590 if (ShouldUseCustomizedDefaultWallpaper()) {
590 SetDefaultWallpaperPath( 591 SetDefaultWallpaperPath(
591 GetCustomizedWallpaperDefaultRescaledFileName(kSmallWallpaperSuffix), 592 GetCustomizedWallpaperDefaultRescaledFileName(kSmallWallpaperSuffix),
592 scoped_ptr<gfx::ImageSkia>().Pass(), 593 scoped_ptr<gfx::ImageSkia>().Pass(),
593 GetCustomizedWallpaperDefaultRescaledFileName(kLargeWallpaperSuffix), 594 GetCustomizedWallpaperDefaultRescaledFileName(kLargeWallpaperSuffix),
594 scoped_ptr<gfx::ImageSkia>().Pass()); 595 scoped_ptr<gfx::ImageSkia>().Pass());
595 } 596 }
596 597
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 const std::string& user_id_hash, 822 const std::string& user_id_hash,
822 const std::string& file) { 823 const std::string& file) {
823 base::FilePath custom_wallpaper_path = GetCustomWallpaperDir(sub_dir); 824 base::FilePath custom_wallpaper_path = GetCustomWallpaperDir(sub_dir);
824 return custom_wallpaper_path.Append(user_id_hash).Append(file); 825 return custom_wallpaper_path.Append(user_id_hash).Append(file);
825 } 826 }
826 827
827 void WallpaperManager::SetPolicyControlledWallpaper( 828 void WallpaperManager::SetPolicyControlledWallpaper(
828 const std::string& user_id, 829 const std::string& user_id,
829 const user_manager::UserImage& user_image) { 830 const user_manager::UserImage& user_image) {
830 const user_manager::User* user = 831 const user_manager::User* user =
831 chromeos::UserManager::Get()->FindUser(user_id); 832 user_manager::UserManager::Get()->FindUser(user_id);
832 if (!user) { 833 if (!user) {
833 NOTREACHED() << "Unknown user."; 834 NOTREACHED() << "Unknown user.";
834 return; 835 return;
835 } 836 }
836 837
837 if (user->username_hash().empty()) { 838 if (user->username_hash().empty()) {
838 cryptohome::AsyncMethodCaller::GetInstance()->AsyncGetSanitizedUsername( 839 cryptohome::AsyncMethodCaller::GetInstance()->AsyncGetSanitizedUsername(
839 user_id, 840 user_id,
840 base::Bind(&WallpaperManager::SetCustomWallpaperOnSanitizedUsername, 841 base::Bind(&WallpaperManager::SetCustomWallpaperOnSanitizedUsername,
841 weak_factory_.GetWeakPtr(), 842 weak_factory_.GetWeakPtr(),
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 const std::string& user_id, 875 const std::string& user_id,
875 const std::string& user_id_hash, 876 const std::string& user_id_hash,
876 const std::string& file, 877 const std::string& file,
877 ash::WallpaperLayout layout, 878 ash::WallpaperLayout layout,
878 user_manager::User::WallpaperType type, 879 user_manager::User::WallpaperType type,
879 const gfx::ImageSkia& image, 880 const gfx::ImageSkia& image,
880 bool update_wallpaper) { 881 bool update_wallpaper) {
881 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 882 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
882 883
883 // There is no visible background in kiosk mode. 884 // There is no visible background in kiosk mode.
884 if (UserManager::Get()->IsLoggedInAsKioskApp()) 885 if (user_manager::UserManager::Get()->IsLoggedInAsKioskApp())
885 return; 886 return;
886 887
887 // Don't allow custom wallpapers while policy is in effect. 888 // Don't allow custom wallpapers while policy is in effect.
888 if (type != user_manager::User::POLICY && IsPolicyControlled(user_id)) 889 if (type != user_manager::User::POLICY && IsPolicyControlled(user_id))
889 return; 890 return;
890 891
891 base::FilePath wallpaper_path = 892 base::FilePath wallpaper_path =
892 GetCustomWallpaperPath(kOriginalWallpaperSubDir, user_id_hash, file); 893 GetCustomWallpaperPath(kOriginalWallpaperSubDir, user_id_hash, file);
893 894
894 // If decoded wallpaper is empty, we have probably failed to decode the file. 895 // If decoded wallpaper is empty, we have probably failed to decode the file.
895 // Use default wallpaper in this case. 896 // Use default wallpaper in this case.
896 if (image.isNull()) { 897 if (image.isNull()) {
897 SetDefaultWallpaperDelayed(user_id); 898 SetDefaultWallpaperDelayed(user_id);
898 return; 899 return;
899 } 900 }
900 901
901 const user_manager::User *user = UserManager::Get()->FindUser(user_id); 902 const user_manager::User* user =
903 user_manager::UserManager::Get()->FindUser(user_id);
902 CHECK(user); 904 CHECK(user);
903 bool is_persistent = 905 bool is_persistent =
904 !UserManager::Get()->IsUserNonCryptohomeDataEphemeral(user_id) || 906 !user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral(
907 user_id) ||
905 (type == user_manager::User::POLICY && 908 (type == user_manager::User::POLICY &&
906 user->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT); 909 user->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT);
907 910
908 WallpaperInfo wallpaper_info = { 911 WallpaperInfo wallpaper_info = {
909 wallpaper_path.value(), 912 wallpaper_path.value(),
910 layout, 913 layout,
911 type, 914 type,
912 // Date field is not used. 915 // Date field is not used.
913 base::Time::Now().LocalMidnight() 916 base::Time::Now().LocalMidnight()
914 }; 917 };
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 } 956 }
954 957
955 void WallpaperManager::SetDefaultWallpaperDelayed(const std::string& user_id) { 958 void WallpaperManager::SetDefaultWallpaperDelayed(const std::string& user_id) {
956 GetPendingWallpaper(user_id, true)->ResetSetDefaultWallpaper(); 959 GetPendingWallpaper(user_id, true)->ResetSetDefaultWallpaper();
957 } 960 }
958 961
959 void WallpaperManager::DoSetDefaultWallpaper( 962 void WallpaperManager::DoSetDefaultWallpaper(
960 const std::string& user_id, 963 const std::string& user_id,
961 MovableOnDestroyCallbackHolder on_finish) { 964 MovableOnDestroyCallbackHolder on_finish) {
962 // There is no visible background in kiosk mode. 965 // There is no visible background in kiosk mode.
963 if (UserManager::Get()->IsLoggedInAsKioskApp()) 966 if (user_manager::UserManager::Get()->IsLoggedInAsKioskApp())
964 return; 967 return;
965 current_wallpaper_path_.clear(); 968 current_wallpaper_path_.clear();
966 wallpaper_cache_.erase(user_id); 969 wallpaper_cache_.erase(user_id);
967 // Some browser tests do not have a shell instance. As no wallpaper is needed 970 // Some browser tests do not have a shell instance. As no wallpaper is needed
968 // in these tests anyway, avoid loading one, preventing crashes and speeding 971 // in these tests anyway, avoid loading one, preventing crashes and speeding
969 // up the tests. 972 // up the tests.
970 if (!ash::Shell::HasInstance()) 973 if (!ash::Shell::HasInstance())
971 return; 974 return;
972 975
973 WallpaperResolution resolution = GetAppropriateResolution(); 976 WallpaperResolution resolution = GetAppropriateResolution();
974 const bool use_small = (resolution == WALLPAPER_RESOLUTION_SMALL); 977 const bool use_small = (resolution == WALLPAPER_RESOLUTION_SMALL);
975 978
976 const base::FilePath* file = NULL; 979 const base::FilePath* file = NULL;
977 980
978 if (UserManager::Get()->IsLoggedInAsGuest()) { 981 if (user_manager::UserManager::Get()->IsLoggedInAsGuest()) {
979 file = 982 file =
980 use_small ? &guest_small_wallpaper_file_ : &guest_large_wallpaper_file_; 983 use_small ? &guest_small_wallpaper_file_ : &guest_large_wallpaper_file_;
981 } else { 984 } else {
982 file = use_small ? &default_small_wallpaper_file_ 985 file = use_small ? &default_small_wallpaper_file_
983 : &default_large_wallpaper_file_; 986 : &default_large_wallpaper_file_;
984 } 987 }
985 ash::WallpaperLayout layout = use_small 988 ash::WallpaperLayout layout = use_small
986 ? ash::WALLPAPER_LAYOUT_CENTER 989 ? ash::WALLPAPER_LAYOUT_CENTER
987 : ash::WALLPAPER_LAYOUT_CENTER_CROPPED; 990 : ash::WALLPAPER_LAYOUT_CENTER_CROPPED;
988 DCHECK(file); 991 DCHECK(file);
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 } 1163 }
1161 1164
1162 void WallpaperManager::SetUserWallpaperNow(const std::string& user_id) { 1165 void WallpaperManager::SetUserWallpaperNow(const std::string& user_id) {
1163 ScheduleSetUserWallpaper(user_id, false); 1166 ScheduleSetUserWallpaper(user_id, false);
1164 } 1167 }
1165 1168
1166 void WallpaperManager::ScheduleSetUserWallpaper(const std::string& user_id, 1169 void WallpaperManager::ScheduleSetUserWallpaper(const std::string& user_id,
1167 bool delayed) { 1170 bool delayed) {
1168 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1171 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1169 // Some unit tests come here without a UserManager or without a pref system. 1172 // Some unit tests come here without a UserManager or without a pref system.
1170 if (!UserManager::IsInitialized() || !g_browser_process->local_state()) 1173 if (!user_manager::UserManager::IsInitialized() ||
1174 !g_browser_process->local_state()) {
1171 return; 1175 return;
1176 }
1177
1172 // There is no visible background in kiosk mode. 1178 // There is no visible background in kiosk mode.
1173 if (UserManager::Get()->IsLoggedInAsKioskApp()) 1179 if (user_manager::UserManager::Get()->IsLoggedInAsKioskApp())
1174 return; 1180 return;
1175 // Guest user, regular user in ephemeral mode, or kiosk app. 1181 // Guest user, regular user in ephemeral mode, or kiosk app.
1176 const user_manager::User* user = UserManager::Get()->FindUser(user_id); 1182 const user_manager::User* user =
1177 if (UserManager::Get()->IsUserNonCryptohomeDataEphemeral(user_id) || 1183 user_manager::UserManager::Get()->FindUser(user_id);
1184 if (user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral(
1185 user_id) ||
1178 (user != NULL && user->GetType() == user_manager::USER_TYPE_KIOSK_APP)) { 1186 (user != NULL && user->GetType() == user_manager::USER_TYPE_KIOSK_APP)) {
1179 InitInitialUserWallpaper(user_id, false); 1187 InitInitialUserWallpaper(user_id, false);
1180 GetPendingWallpaper(user_id, delayed)->ResetSetDefaultWallpaper(); 1188 GetPendingWallpaper(user_id, delayed)->ResetSetDefaultWallpaper();
1181 return; 1189 return;
1182 } 1190 }
1183 1191
1184 if (!UserManager::Get()->IsKnownUser(user_id)) 1192 if (!user_manager::UserManager::Get()->IsKnownUser(user_id))
1185 return; 1193 return;
1186 1194
1187 last_selected_user_ = user_id; 1195 last_selected_user_ = user_id;
1188 1196
1189 WallpaperInfo info; 1197 WallpaperInfo info;
1190 1198
1191 if (!GetUserWallpaperInfo(user_id, &info)) { 1199 if (!GetUserWallpaperInfo(user_id, &info)) {
1192 InitInitialUserWallpaper(user_id, true); 1200 InitInitialUserWallpaper(user_id, true);
1193 GetUserWallpaperInfo(user_id, &info); 1201 GetUserWallpaperInfo(user_id, &info);
1194 } 1202 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1228 1236
1229 // Load downloaded ONLINE or converted DEFAULT wallpapers. 1237 // Load downloaded ONLINE or converted DEFAULT wallpapers.
1230 GetPendingWallpaper(user_id, delayed)->ResetLoadWallpaper(info); 1238 GetPendingWallpaper(user_id, delayed)->ResetLoadWallpaper(info);
1231 } 1239 }
1232 } 1240 }
1233 1241
1234 void WallpaperManager::SetWallpaperFromImageSkia(const std::string& user_id, 1242 void WallpaperManager::SetWallpaperFromImageSkia(const std::string& user_id,
1235 const gfx::ImageSkia& image, 1243 const gfx::ImageSkia& image,
1236 ash::WallpaperLayout layout, 1244 ash::WallpaperLayout layout,
1237 bool update_wallpaper) { 1245 bool update_wallpaper) {
1238 DCHECK(UserManager::Get()->IsUserLoggedIn()); 1246 DCHECK(user_manager::UserManager::Get()->IsUserLoggedIn());
1239 1247
1240 // There is no visible background in kiosk mode. 1248 // There is no visible background in kiosk mode.
1241 if (UserManager::Get()->IsLoggedInAsKioskApp()) 1249 if (user_manager::UserManager::Get()->IsLoggedInAsKioskApp())
1242 return; 1250 return;
1243 WallpaperInfo info; 1251 WallpaperInfo info;
1244 info.layout = layout; 1252 info.layout = layout;
1245 wallpaper_cache_[user_id] = image; 1253 wallpaper_cache_[user_id] = image;
1246 1254
1247 if (update_wallpaper) { 1255 if (update_wallpaper) {
1248 GetPendingWallpaper(last_selected_user_, false /* Not delayed */) 1256 GetPendingWallpaper(last_selected_user_, false /* Not delayed */)
1249 ->ResetSetWallpaperImage(image, info); 1257 ->ResetSetWallpaperImage(image, info);
1250 } 1258 }
1251 } 1259 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1287 CustomWallpaperMap::const_iterator it = wallpaper_cache_.find(user_id); 1295 CustomWallpaperMap::const_iterator it = wallpaper_cache_.find(user_id);
1288 if (it != wallpaper_cache_.end()) { 1296 if (it != wallpaper_cache_.end()) {
1289 *image = (*it).second; 1297 *image = (*it).second;
1290 return true; 1298 return true;
1291 } 1299 }
1292 return false; 1300 return false;
1293 } 1301 }
1294 1302
1295 void WallpaperManager::CacheUsersWallpapers() { 1303 void WallpaperManager::CacheUsersWallpapers() {
1296 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1304 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1297 user_manager::UserList users = UserManager::Get()->GetUsers(); 1305 user_manager::UserList users = user_manager::UserManager::Get()->GetUsers();
1298 1306
1299 if (!users.empty()) { 1307 if (!users.empty()) {
1300 user_manager::UserList::const_iterator it = users.begin(); 1308 user_manager::UserList::const_iterator it = users.begin();
1301 // Skip the wallpaper of first user in the list. It should have been cached. 1309 // Skip the wallpaper of first user in the list. It should have been cached.
1302 it++; 1310 it++;
1303 for (int cached = 0; 1311 for (int cached = 0;
1304 it != users.end() && cached < kMaxWallpapersToCache; 1312 it != users.end() && cached < kMaxWallpapersToCache;
1305 ++it, ++cached) { 1313 ++it, ++cached) {
1306 std::string user_id = (*it)->email(); 1314 std::string user_id = (*it)->email();
1307 CacheUserWallpaper(user_id); 1315 CacheUserWallpaper(user_id);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1392 SetDefaultWallpaperPathsFromCommandLine(command_line); 1400 SetDefaultWallpaperPathsFromCommandLine(command_line);
1393 } 1401 }
1394 1402
1395 CommandLine* WallpaperManager::GetCommandLine() { 1403 CommandLine* WallpaperManager::GetCommandLine() {
1396 CommandLine* command_line = command_line_for_testing_ ? 1404 CommandLine* command_line = command_line_for_testing_ ?
1397 command_line_for_testing_ : CommandLine::ForCurrentProcess(); 1405 command_line_for_testing_ : CommandLine::ForCurrentProcess();
1398 return command_line; 1406 return command_line;
1399 } 1407 }
1400 1408
1401 void WallpaperManager::InitializeRegisteredDeviceWallpaper() { 1409 void WallpaperManager::InitializeRegisteredDeviceWallpaper() {
1402 if (UserManager::Get()->IsUserLoggedIn()) 1410 if (user_manager::UserManager::Get()->IsUserLoggedIn())
1403 return; 1411 return;
1404 1412
1405 bool disable_boot_animation = 1413 bool disable_boot_animation =
1406 GetCommandLine()->HasSwitch(switches::kDisableBootAnimation); 1414 GetCommandLine()->HasSwitch(switches::kDisableBootAnimation);
1407 bool show_users = true; 1415 bool show_users = true;
1408 bool result = CrosSettings::Get()->GetBoolean( 1416 bool result = CrosSettings::Get()->GetBoolean(
1409 kAccountsPrefShowUserNamesOnSignIn, &show_users); 1417 kAccountsPrefShowUserNamesOnSignIn, &show_users);
1410 DCHECK(result) << "Unable to fetch setting " 1418 DCHECK(result) << "Unable to fetch setting "
1411 << kAccountsPrefShowUserNamesOnSignIn; 1419 << kAccountsPrefShowUserNamesOnSignIn;
1412 const user_manager::UserList& users = UserManager::Get()->GetUsers(); 1420 const user_manager::UserList& users =
1421 user_manager::UserManager::Get()->GetUsers();
1413 int public_session_user_index = FindPublicSession(users); 1422 int public_session_user_index = FindPublicSession(users);
1414 if ((!show_users && public_session_user_index == -1) || users.empty()) { 1423 if ((!show_users && public_session_user_index == -1) || users.empty()) {
1415 // Boot into sign in form, preload default wallpaper. 1424 // Boot into sign in form, preload default wallpaper.
1416 SetDefaultWallpaperDelayed(chromeos::login::kSignInUser); 1425 SetDefaultWallpaperDelayed(chromeos::login::kSignInUser);
1417 return; 1426 return;
1418 } 1427 }
1419 1428
1420 if (!disable_boot_animation) { 1429 if (!disable_boot_animation) {
1421 int index = public_session_user_index != -1 ? public_session_user_index : 0; 1430 int index = public_session_user_index != -1 ? public_session_user_index : 0;
1422 // Normal boot, load user wallpaper. 1431 // Normal boot, load user wallpaper.
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1487 // crosbug.com/38429. 1496 // crosbug.com/38429.
1488 LOG(ERROR) << "Wallpaper reverts to default unexpected."; 1497 LOG(ERROR) << "Wallpaper reverts to default unexpected.";
1489 DoSetDefaultWallpaper(user_id, on_finish.Pass()); 1498 DoSetDefaultWallpaper(user_id, on_finish.Pass());
1490 } 1499 }
1491 } 1500 }
1492 1501
1493 bool WallpaperManager::GetUserWallpaperInfo(const std::string& user_id, 1502 bool WallpaperManager::GetUserWallpaperInfo(const std::string& user_id,
1494 WallpaperInfo* info) const { 1503 WallpaperInfo* info) const {
1495 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1504 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1496 1505
1497 if (UserManager::Get()->IsUserNonCryptohomeDataEphemeral(user_id)) { 1506 if (user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral(
1507 user_id)) {
1498 // Default to the values cached in memory. 1508 // Default to the values cached in memory.
1499 *info = current_user_wallpaper_info_; 1509 *info = current_user_wallpaper_info_;
1500 1510
1501 // Ephemeral users do not save anything to local state. But we have got 1511 // Ephemeral users do not save anything to local state. But we have got
1502 // wallpaper info from memory. Returns true. 1512 // wallpaper info from memory. Returns true.
1503 return true; 1513 return true;
1504 } 1514 }
1505 1515
1506 const base::DictionaryValue* info_dict; 1516 const base::DictionaryValue* info_dict;
1507 if (!g_browser_process->local_state()-> 1517 if (!g_browser_process->local_state()->
(...skipping 29 matching lines...) Expand all
1537 void WallpaperManager::MoveCustomWallpapersSuccess( 1547 void WallpaperManager::MoveCustomWallpapersSuccess(
1538 const std::string& user_id, 1548 const std::string& user_id,
1539 const std::string& user_id_hash) { 1549 const std::string& user_id_hash) {
1540 WallpaperInfo info; 1550 WallpaperInfo info;
1541 GetUserWallpaperInfo(user_id, &info); 1551 GetUserWallpaperInfo(user_id, &info);
1542 if (info.type == user_manager::User::CUSTOMIZED) { 1552 if (info.type == user_manager::User::CUSTOMIZED) {
1543 // New file field should include user id hash in addition to file name. 1553 // New file field should include user id hash in addition to file name.
1544 // This is needed because at login screen, user id hash is not available. 1554 // This is needed because at login screen, user id hash is not available.
1545 info.location = base::FilePath(user_id_hash).Append(info.location).value(); 1555 info.location = base::FilePath(user_id_hash).Append(info.location).value();
1546 bool is_persistent = 1556 bool is_persistent =
1547 !UserManager::Get()->IsUserNonCryptohomeDataEphemeral(user_id); 1557 !user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral(
1558 user_id);
1548 SetUserWallpaperInfo(user_id, info, is_persistent); 1559 SetUserWallpaperInfo(user_id, info, is_persistent);
1549 } 1560 }
1550 } 1561 }
1551 1562
1552 void WallpaperManager::MoveLoggedInUserCustomWallpaper() { 1563 void WallpaperManager::MoveLoggedInUserCustomWallpaper() {
1553 const user_manager::User* logged_in_user = 1564 const user_manager::User* logged_in_user =
1554 UserManager::Get()->GetLoggedInUser(); 1565 user_manager::UserManager::Get()->GetLoggedInUser();
1555 task_runner_->PostTask( 1566 if (logged_in_user) {
1556 FROM_HERE, 1567 task_runner_->PostTask(
1557 base::Bind(&WallpaperManager::MoveCustomWallpapersOnWorker, 1568 FROM_HERE,
1558 logged_in_user->email(), 1569 base::Bind(&WallpaperManager::MoveCustomWallpapersOnWorker,
1559 logged_in_user->username_hash(), 1570 logged_in_user->email(),
1560 weak_factory_.GetWeakPtr())); 1571 logged_in_user->username_hash(),
1572 weak_factory_.GetWeakPtr()));
1573 }
1561 } 1574 }
1562 1575
1563 void WallpaperManager::OnWallpaperDecoded( 1576 void WallpaperManager::OnWallpaperDecoded(
1564 const std::string& user_id, 1577 const std::string& user_id,
1565 ash::WallpaperLayout layout, 1578 ash::WallpaperLayout layout,
1566 bool update_wallpaper, 1579 bool update_wallpaper,
1567 MovableOnDestroyCallbackHolder on_finish, 1580 MovableOnDestroyCallbackHolder on_finish,
1568 const user_manager::UserImage& user_image) { 1581 const user_manager::UserImage& user_image) {
1569 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1582 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1570 TRACE_EVENT_ASYNC_END0("ui", "LoadAndDecodeWallpaper", this); 1583 TRACE_EVENT_ASYNC_END0("ui", "LoadAndDecodeWallpaper", this);
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
1929 void WallpaperManager::CreateSolidDefaultWallpaper() { 1942 void WallpaperManager::CreateSolidDefaultWallpaper() {
1930 loaded_wallpapers_++; 1943 loaded_wallpapers_++;
1931 SkBitmap bitmap; 1944 SkBitmap bitmap;
1932 bitmap.allocN32Pixels(1, 1); 1945 bitmap.allocN32Pixels(1, 1);
1933 bitmap.eraseColor(kDefaultWallpaperColor); 1946 bitmap.eraseColor(kDefaultWallpaperColor);
1934 const gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(bitmap); 1947 const gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(bitmap);
1935 default_wallpaper_image_.reset(new user_manager::UserImage(image)); 1948 default_wallpaper_image_.reset(new user_manager::UserImage(image));
1936 } 1949 }
1937 1950
1938 } // namespace chromeos 1951 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698