| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "ash/common/ash_constants.h" | 9 #include "ash/common/ash_constants.h" |
| 10 #include "ash/common/wallpaper/wallpaper_controller.h" | 10 #include "ash/common/wallpaper/wallpaper_controller.h" |
| (...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1034 weak_factory_.GetWeakPtr(), account_id)); | 1034 weak_factory_.GetWeakPtr(), account_id)); |
| 1035 } | 1035 } |
| 1036 | 1036 |
| 1037 void WallpaperManager::OnDeviceWallpaperDecoded( | 1037 void WallpaperManager::OnDeviceWallpaperDecoded( |
| 1038 const AccountId& account_id, | 1038 const AccountId& account_id, |
| 1039 std::unique_ptr<user_manager::UserImage> user_image) { | 1039 std::unique_ptr<user_manager::UserImage> user_image) { |
| 1040 WallpaperInfo wallpaper_info = {GetDeviceWallpaperFilePath().value(), | 1040 WallpaperInfo wallpaper_info = {GetDeviceWallpaperFilePath().value(), |
| 1041 wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED, | 1041 wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED, |
| 1042 user_manager::User::DEVICE, | 1042 user_manager::User::DEVICE, |
| 1043 base::Time::Now().LocalMidnight()}; | 1043 base::Time::Now().LocalMidnight()}; |
| 1044 if (user_manager::UserManager::Get()->IsUserLoggedIn()) { | 1044 DCHECK(!user_manager::UserManager::Get()->IsUserLoggedIn()); |
| 1045 // In a user's session treat the device wallpaper as a normal custom | 1045 // In the login screen set the device wallpaper as the wallpaper. |
| 1046 // wallpaper. It should be persistent and can be overriden by other user | 1046 GetPendingWallpaper(user_manager::SignInAccountId(), false) |
| 1047 // selected wallpapers. | 1047 ->ResetSetWallpaperImage(user_image->image(), wallpaper_info); |
| 1048 SetUserWallpaperInfo(account_id, wallpaper_info, true /* is_persistent */); | |
| 1049 GetPendingWallpaper(account_id, false) | |
| 1050 ->ResetSetWallpaperImage(user_image->image(), wallpaper_info); | |
| 1051 wallpaper_cache_[account_id] = CustomWallpaperElement( | |
| 1052 GetDeviceWallpaperFilePath(), user_image->image()); | |
| 1053 } else { | |
| 1054 // In the login screen set the device wallpaper as the wallpaper. | |
| 1055 GetPendingWallpaper(user_manager::SignInAccountId(), false) | |
| 1056 ->ResetSetWallpaperImage(user_image->image(), wallpaper_info); | |
| 1057 } | |
| 1058 } | 1048 } |
| 1059 | 1049 |
| 1060 void WallpaperManager::InitializeRegisteredDeviceWallpaper() { | 1050 void WallpaperManager::InitializeRegisteredDeviceWallpaper() { |
| 1061 if (user_manager::UserManager::Get()->IsUserLoggedIn()) | 1051 if (user_manager::UserManager::Get()->IsUserLoggedIn()) |
| 1062 return; | 1052 return; |
| 1063 | 1053 |
| 1064 bool disable_boot_animation = | 1054 bool disable_boot_animation = |
| 1065 GetCommandLine()->HasSwitch(switches::kDisableBootAnimation); | 1055 GetCommandLine()->HasSwitch(switches::kDisableBootAnimation); |
| 1066 bool show_users = true; | 1056 bool show_users = true; |
| 1067 bool result = CrosSettings::Get()->GetBoolean( | 1057 bool result = CrosSettings::Get()->GetBoolean( |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1143 return false; | 1133 return false; |
| 1144 } | 1134 } |
| 1145 | 1135 |
| 1146 const base::DictionaryValue* dict = nullptr; | 1136 const base::DictionaryValue* dict = nullptr; |
| 1147 if (!CrosSettings::Get()->GetDictionary(kDeviceWallpaperImage, &dict) || | 1137 if (!CrosSettings::Get()->GetDictionary(kDeviceWallpaperImage, &dict) || |
| 1148 !dict->GetStringWithoutPathExpansion("url", url) || | 1138 !dict->GetStringWithoutPathExpansion("url", url) || |
| 1149 !dict->GetStringWithoutPathExpansion("hash", hash)) { | 1139 !dict->GetStringWithoutPathExpansion("hash", hash)) { |
| 1150 return false; | 1140 return false; |
| 1151 } | 1141 } |
| 1152 | 1142 |
| 1153 // Only set the device wallpaper if 1) we're at the login screen or 2) there | 1143 // Only set the device wallpaper if we're at the login screen. |
| 1154 // is no user policy wallpaper in a user session and the user has the default | 1144 if (user_manager::UserManager::Get()->IsUserLoggedIn()) |
| 1155 // wallpaper or device wallpaper in a user session. Note in the latter case, | 1145 return false; |
| 1156 // the device wallpaper can be overridden by user-selected wallpapers. | |
| 1157 if (user_manager::UserManager::Get()->IsUserLoggedIn()) { | |
| 1158 WallpaperInfo info; | |
| 1159 if (GetUserWallpaperInfo(account_id, &info) && | |
| 1160 (info.type == user_manager::User::POLICY || | |
| 1161 (info.type != user_manager::User::DEFAULT && | |
| 1162 info.type != user_manager::User::DEVICE))) { | |
| 1163 return false; | |
| 1164 } | |
| 1165 } | |
| 1166 | 1146 |
| 1167 return true; | 1147 return true; |
| 1168 } | 1148 } |
| 1169 | 1149 |
| 1170 base::FilePath WallpaperManager::GetDeviceWallpaperDir() { | 1150 base::FilePath WallpaperManager::GetDeviceWallpaperDir() { |
| 1171 base::FilePath wallpaper_dir; | 1151 base::FilePath wallpaper_dir; |
| 1172 if (!PathService::Get(chrome::DIR_CHROMEOS_WALLPAPERS, &wallpaper_dir)) { | 1152 if (!PathService::Get(chrome::DIR_CHROMEOS_WALLPAPERS, &wallpaper_dir)) { |
| 1173 LOG(ERROR) << "Unable to get wallpaper dir."; | 1153 LOG(ERROR) << "Unable to get wallpaper dir."; |
| 1174 return base::FilePath(); | 1154 return base::FilePath(); |
| 1175 } | 1155 } |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1407 | 1387 |
| 1408 UMA_HISTOGRAM_ENUMERATION( | 1388 UMA_HISTOGRAM_ENUMERATION( |
| 1409 "Ash.Wallpaper.Apps", | 1389 "Ash.Wallpaper.Apps", |
| 1410 wallpaper_manager_util::ShouldUseAndroidWallpapersApp(profile) | 1390 wallpaper_manager_util::ShouldUseAndroidWallpapersApp(profile) |
| 1411 ? WALLPAPERS_APP_ANDROID | 1391 ? WALLPAPERS_APP_ANDROID |
| 1412 : WALLPAPERS_PICKER_APP_CHROMEOS, | 1392 : WALLPAPERS_PICKER_APP_CHROMEOS, |
| 1413 WALLPAPERS_APPS_NUM); | 1393 WALLPAPERS_APPS_NUM); |
| 1414 } | 1394 } |
| 1415 | 1395 |
| 1416 } // namespace chromeos | 1396 } // namespace chromeos |
| OLD | NEW |