Chromium Code Reviews| 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 16 matching lines...) Expand all Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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; |
| 1172 // There is no visible background in kiosk mode. | 1176 // There is no visible background in kiosk mode. |
| 1173 if (UserManager::Get()->IsLoggedInAsKioskApp()) | 1177 if (user_manager::UserManager::Get()->IsLoggedInAsKioskApp()) |
| 1174 return; | 1178 return; |
| 1175 // Guest user, regular user in ephemeral mode, or kiosk app. | 1179 // Guest user, regular user in ephemeral mode, or kiosk app. |
| 1176 const user_manager::User* user = UserManager::Get()->FindUser(user_id); | 1180 const user_manager::User* user = |
| 1177 if (UserManager::Get()->IsUserNonCryptohomeDataEphemeral(user_id) || | 1181 user_manager::UserManager::Get()->FindUser(user_id); |
| 1182 if (user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral( | |
| 1183 user_id) || | |
| 1178 (user != NULL && user->GetType() == user_manager::USER_TYPE_KIOSK_APP)) { | 1184 (user != NULL && user->GetType() == user_manager::USER_TYPE_KIOSK_APP)) { |
| 1179 InitInitialUserWallpaper(user_id, false); | 1185 InitInitialUserWallpaper(user_id, false); |
| 1180 GetPendingWallpaper(user_id, delayed)->ResetSetDefaultWallpaper(); | 1186 GetPendingWallpaper(user_id, delayed)->ResetSetDefaultWallpaper(); |
| 1181 return; | 1187 return; |
| 1182 } | 1188 } |
| 1183 | 1189 |
| 1184 if (!UserManager::Get()->IsKnownUser(user_id)) | 1190 if (!user_manager::UserManager::Get()->IsKnownUser(user_id)) |
| 1185 return; | 1191 return; |
| 1186 | 1192 |
| 1187 last_selected_user_ = user_id; | 1193 last_selected_user_ = user_id; |
| 1188 | 1194 |
| 1189 WallpaperInfo info; | 1195 WallpaperInfo info; |
| 1190 | 1196 |
| 1191 if (!GetUserWallpaperInfo(user_id, &info)) { | 1197 if (!GetUserWallpaperInfo(user_id, &info)) { |
| 1192 InitInitialUserWallpaper(user_id, true); | 1198 InitInitialUserWallpaper(user_id, true); |
| 1193 GetUserWallpaperInfo(user_id, &info); | 1199 GetUserWallpaperInfo(user_id, &info); |
| 1194 } | 1200 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1228 | 1234 |
| 1229 // Load downloaded ONLINE or converted DEFAULT wallpapers. | 1235 // Load downloaded ONLINE or converted DEFAULT wallpapers. |
| 1230 GetPendingWallpaper(user_id, delayed)->ResetLoadWallpaper(info); | 1236 GetPendingWallpaper(user_id, delayed)->ResetLoadWallpaper(info); |
| 1231 } | 1237 } |
| 1232 } | 1238 } |
| 1233 | 1239 |
| 1234 void WallpaperManager::SetWallpaperFromImageSkia(const std::string& user_id, | 1240 void WallpaperManager::SetWallpaperFromImageSkia(const std::string& user_id, |
| 1235 const gfx::ImageSkia& image, | 1241 const gfx::ImageSkia& image, |
| 1236 ash::WallpaperLayout layout, | 1242 ash::WallpaperLayout layout, |
| 1237 bool update_wallpaper) { | 1243 bool update_wallpaper) { |
| 1238 DCHECK(UserManager::Get()->IsUserLoggedIn()); | 1244 DCHECK(user_manager::UserManager::Get()->IsUserLoggedIn()); |
| 1239 | 1245 |
| 1240 // There is no visible background in kiosk mode. | 1246 // There is no visible background in kiosk mode. |
| 1241 if (UserManager::Get()->IsLoggedInAsKioskApp()) | 1247 if (user_manager::UserManager::Get()->IsLoggedInAsKioskApp()) |
| 1242 return; | 1248 return; |
| 1243 WallpaperInfo info; | 1249 WallpaperInfo info; |
| 1244 info.layout = layout; | 1250 info.layout = layout; |
| 1245 wallpaper_cache_[user_id] = image; | 1251 wallpaper_cache_[user_id] = image; |
| 1246 | 1252 |
| 1247 if (update_wallpaper) { | 1253 if (update_wallpaper) { |
| 1248 GetPendingWallpaper(last_selected_user_, false /* Not delayed */) | 1254 GetPendingWallpaper(last_selected_user_, false /* Not delayed */) |
| 1249 ->ResetSetWallpaperImage(image, info); | 1255 ->ResetSetWallpaperImage(image, info); |
| 1250 } | 1256 } |
| 1251 } | 1257 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1287 CustomWallpaperMap::const_iterator it = wallpaper_cache_.find(user_id); | 1293 CustomWallpaperMap::const_iterator it = wallpaper_cache_.find(user_id); |
| 1288 if (it != wallpaper_cache_.end()) { | 1294 if (it != wallpaper_cache_.end()) { |
| 1289 *image = (*it).second; | 1295 *image = (*it).second; |
| 1290 return true; | 1296 return true; |
| 1291 } | 1297 } |
| 1292 return false; | 1298 return false; |
| 1293 } | 1299 } |
| 1294 | 1300 |
| 1295 void WallpaperManager::CacheUsersWallpapers() { | 1301 void WallpaperManager::CacheUsersWallpapers() { |
| 1296 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1302 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1297 user_manager::UserList users = UserManager::Get()->GetUsers(); | 1303 user_manager::UserList users = user_manager::UserManager::Get()->GetUsers(); |
| 1298 | 1304 |
| 1299 if (!users.empty()) { | 1305 if (!users.empty()) { |
| 1300 user_manager::UserList::const_iterator it = users.begin(); | 1306 user_manager::UserList::const_iterator it = users.begin(); |
| 1301 // Skip the wallpaper of first user in the list. It should have been cached. | 1307 // Skip the wallpaper of first user in the list. It should have been cached. |
| 1302 it++; | 1308 it++; |
| 1303 for (int cached = 0; | 1309 for (int cached = 0; |
| 1304 it != users.end() && cached < kMaxWallpapersToCache; | 1310 it != users.end() && cached < kMaxWallpapersToCache; |
| 1305 ++it, ++cached) { | 1311 ++it, ++cached) { |
| 1306 std::string user_id = (*it)->email(); | 1312 std::string user_id = (*it)->email(); |
| 1307 CacheUserWallpaper(user_id); | 1313 CacheUserWallpaper(user_id); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1392 SetDefaultWallpaperPathsFromCommandLine(command_line); | 1398 SetDefaultWallpaperPathsFromCommandLine(command_line); |
| 1393 } | 1399 } |
| 1394 | 1400 |
| 1395 CommandLine* WallpaperManager::GetCommandLine() { | 1401 CommandLine* WallpaperManager::GetCommandLine() { |
| 1396 CommandLine* command_line = command_line_for_testing_ ? | 1402 CommandLine* command_line = command_line_for_testing_ ? |
| 1397 command_line_for_testing_ : CommandLine::ForCurrentProcess(); | 1403 command_line_for_testing_ : CommandLine::ForCurrentProcess(); |
| 1398 return command_line; | 1404 return command_line; |
| 1399 } | 1405 } |
| 1400 | 1406 |
| 1401 void WallpaperManager::InitializeRegisteredDeviceWallpaper() { | 1407 void WallpaperManager::InitializeRegisteredDeviceWallpaper() { |
| 1402 if (UserManager::Get()->IsUserLoggedIn()) | 1408 if (user_manager::UserManager::Get()->IsUserLoggedIn()) |
| 1403 return; | 1409 return; |
| 1404 | 1410 |
| 1405 bool disable_boot_animation = | 1411 bool disable_boot_animation = |
| 1406 GetCommandLine()->HasSwitch(switches::kDisableBootAnimation); | 1412 GetCommandLine()->HasSwitch(switches::kDisableBootAnimation); |
| 1407 bool show_users = true; | 1413 bool show_users = true; |
| 1408 bool result = CrosSettings::Get()->GetBoolean( | 1414 bool result = CrosSettings::Get()->GetBoolean( |
| 1409 kAccountsPrefShowUserNamesOnSignIn, &show_users); | 1415 kAccountsPrefShowUserNamesOnSignIn, &show_users); |
| 1410 DCHECK(result) << "Unable to fetch setting " | 1416 DCHECK(result) << "Unable to fetch setting " |
| 1411 << kAccountsPrefShowUserNamesOnSignIn; | 1417 << kAccountsPrefShowUserNamesOnSignIn; |
| 1412 const user_manager::UserList& users = UserManager::Get()->GetUsers(); | 1418 const user_manager::UserList& users = |
| 1419 user_manager::UserManager::Get()->GetUsers(); | |
| 1413 int public_session_user_index = FindPublicSession(users); | 1420 int public_session_user_index = FindPublicSession(users); |
| 1414 if ((!show_users && public_session_user_index == -1) || users.empty()) { | 1421 if ((!show_users && public_session_user_index == -1) || users.empty()) { |
| 1415 // Boot into sign in form, preload default wallpaper. | 1422 // Boot into sign in form, preload default wallpaper. |
| 1416 SetDefaultWallpaperDelayed(chromeos::login::kSignInUser); | 1423 SetDefaultWallpaperDelayed(chromeos::login::kSignInUser); |
| 1417 return; | 1424 return; |
| 1418 } | 1425 } |
| 1419 | 1426 |
| 1420 if (!disable_boot_animation) { | 1427 if (!disable_boot_animation) { |
| 1421 int index = public_session_user_index != -1 ? public_session_user_index : 0; | 1428 int index = public_session_user_index != -1 ? public_session_user_index : 0; |
| 1422 // Normal boot, load user wallpaper. | 1429 // Normal boot, load user wallpaper. |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1487 // crosbug.com/38429. | 1494 // crosbug.com/38429. |
| 1488 LOG(ERROR) << "Wallpaper reverts to default unexpected."; | 1495 LOG(ERROR) << "Wallpaper reverts to default unexpected."; |
| 1489 DoSetDefaultWallpaper(user_id, on_finish.Pass()); | 1496 DoSetDefaultWallpaper(user_id, on_finish.Pass()); |
| 1490 } | 1497 } |
| 1491 } | 1498 } |
| 1492 | 1499 |
| 1493 bool WallpaperManager::GetUserWallpaperInfo(const std::string& user_id, | 1500 bool WallpaperManager::GetUserWallpaperInfo(const std::string& user_id, |
| 1494 WallpaperInfo* info) const { | 1501 WallpaperInfo* info) const { |
| 1495 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1502 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1496 | 1503 |
| 1497 if (UserManager::Get()->IsUserNonCryptohomeDataEphemeral(user_id)) { | 1504 if (user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral( |
| 1505 user_id)) { | |
| 1498 // Default to the values cached in memory. | 1506 // Default to the values cached in memory. |
| 1499 *info = current_user_wallpaper_info_; | 1507 *info = current_user_wallpaper_info_; |
| 1500 | 1508 |
| 1501 // Ephemeral users do not save anything to local state. But we have got | 1509 // Ephemeral users do not save anything to local state. But we have got |
| 1502 // wallpaper info from memory. Returns true. | 1510 // wallpaper info from memory. Returns true. |
| 1503 return true; | 1511 return true; |
| 1504 } | 1512 } |
| 1505 | 1513 |
| 1506 const base::DictionaryValue* info_dict; | 1514 const base::DictionaryValue* info_dict; |
| 1507 if (!g_browser_process->local_state()-> | 1515 if (!g_browser_process->local_state()-> |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 1537 void WallpaperManager::MoveCustomWallpapersSuccess( | 1545 void WallpaperManager::MoveCustomWallpapersSuccess( |
| 1538 const std::string& user_id, | 1546 const std::string& user_id, |
| 1539 const std::string& user_id_hash) { | 1547 const std::string& user_id_hash) { |
| 1540 WallpaperInfo info; | 1548 WallpaperInfo info; |
| 1541 GetUserWallpaperInfo(user_id, &info); | 1549 GetUserWallpaperInfo(user_id, &info); |
| 1542 if (info.type == user_manager::User::CUSTOMIZED) { | 1550 if (info.type == user_manager::User::CUSTOMIZED) { |
| 1543 // New file field should include user id hash in addition to file name. | 1551 // 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. | 1552 // 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(); | 1553 info.location = base::FilePath(user_id_hash).Append(info.location).value(); |
| 1546 bool is_persistent = | 1554 bool is_persistent = |
| 1547 !UserManager::Get()->IsUserNonCryptohomeDataEphemeral(user_id); | 1555 !user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral( |
| 1556 user_id); | |
| 1548 SetUserWallpaperInfo(user_id, info, is_persistent); | 1557 SetUserWallpaperInfo(user_id, info, is_persistent); |
| 1549 } | 1558 } |
| 1550 } | 1559 } |
| 1551 | 1560 |
| 1552 void WallpaperManager::MoveLoggedInUserCustomWallpaper() { | 1561 void WallpaperManager::MoveLoggedInUserCustomWallpaper() { |
| 1553 const user_manager::User* logged_in_user = | 1562 const user_manager::User* logged_in_user = |
| 1554 UserManager::Get()->GetLoggedInUser(); | 1563 user_manager::UserManager::Get()->GetLoggedInUser(); |
| 1555 task_runner_->PostTask( | 1564 if (logged_in_user) { |
|
Dmitry Polukhin
2014/08/12 09:03:12
This check was added in this CL. Why it didn't req
Nikita (slow)
2014/08/12 09:34:42
I've only hit this check in one of my intermediate
| |
| 1556 FROM_HERE, | 1565 task_runner_->PostTask( |
| 1557 base::Bind(&WallpaperManager::MoveCustomWallpapersOnWorker, | 1566 FROM_HERE, |
| 1558 logged_in_user->email(), | 1567 base::Bind(&WallpaperManager::MoveCustomWallpapersOnWorker, |
| 1559 logged_in_user->username_hash(), | 1568 logged_in_user->email(), |
| 1560 weak_factory_.GetWeakPtr())); | 1569 logged_in_user->username_hash(), |
| 1570 weak_factory_.GetWeakPtr())); | |
| 1571 } | |
| 1561 } | 1572 } |
| 1562 | 1573 |
| 1563 void WallpaperManager::OnWallpaperDecoded( | 1574 void WallpaperManager::OnWallpaperDecoded( |
| 1564 const std::string& user_id, | 1575 const std::string& user_id, |
| 1565 ash::WallpaperLayout layout, | 1576 ash::WallpaperLayout layout, |
| 1566 bool update_wallpaper, | 1577 bool update_wallpaper, |
| 1567 MovableOnDestroyCallbackHolder on_finish, | 1578 MovableOnDestroyCallbackHolder on_finish, |
| 1568 const user_manager::UserImage& user_image) { | 1579 const user_manager::UserImage& user_image) { |
| 1569 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1580 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1570 TRACE_EVENT_ASYNC_END0("ui", "LoadAndDecodeWallpaper", this); | 1581 TRACE_EVENT_ASYNC_END0("ui", "LoadAndDecodeWallpaper", this); |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1929 void WallpaperManager::CreateSolidDefaultWallpaper() { | 1940 void WallpaperManager::CreateSolidDefaultWallpaper() { |
| 1930 loaded_wallpapers_++; | 1941 loaded_wallpapers_++; |
| 1931 SkBitmap bitmap; | 1942 SkBitmap bitmap; |
| 1932 bitmap.allocN32Pixels(1, 1); | 1943 bitmap.allocN32Pixels(1, 1); |
| 1933 bitmap.eraseColor(kDefaultWallpaperColor); | 1944 bitmap.eraseColor(kDefaultWallpaperColor); |
| 1934 const gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(bitmap); | 1945 const gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(bitmap); |
| 1935 default_wallpaper_image_.reset(new user_manager::UserImage(image)); | 1946 default_wallpaper_image_.reset(new user_manager::UserImage(image)); |
| 1936 } | 1947 } |
| 1937 | 1948 |
| 1938 } // namespace chromeos | 1949 } // namespace chromeos |
| OLD | NEW |