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/ash_constants.h" | 9 #include "ash/ash_constants.h" |
10 #include "ash/public/interfaces/constants.mojom.h" | 10 #include "ash/public/interfaces/constants.mojom.h" |
(...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 ? user_manager::UserManager::Get()->GetActiveUser()->GetAccountId() | 954 ? user_manager::UserManager::Get()->GetActiveUser()->GetAccountId() |
955 : user_manager::SignInAccountId()); | 955 : user_manager::SignInAccountId()); |
956 } | 956 } |
957 | 957 |
958 void WallpaperManager::OnDeviceWallpaperExists(const AccountId& account_id, | 958 void WallpaperManager::OnDeviceWallpaperExists(const AccountId& account_id, |
959 const std::string& url, | 959 const std::string& url, |
960 const std::string& hash, | 960 const std::string& hash, |
961 bool exist) { | 961 bool exist) { |
962 if (exist) { | 962 if (exist) { |
963 base::PostTaskWithTraitsAndReplyWithResult( | 963 base::PostTaskWithTraitsAndReplyWithResult( |
964 FROM_HERE, base::TaskTraits().MayBlock(), | 964 FROM_HERE, {base::MayBlock()}, |
965 base::Bind(&CheckDeviceWallpaperMatchHash, GetDeviceWallpaperFilePath(), | 965 base::Bind(&CheckDeviceWallpaperMatchHash, GetDeviceWallpaperFilePath(), |
966 hash), | 966 hash), |
967 base::Bind(&WallpaperManager::OnCheckDeviceWallpaperMatchHash, | 967 base::Bind(&WallpaperManager::OnCheckDeviceWallpaperMatchHash, |
968 weak_factory_.GetWeakPtr(), account_id, url, hash)); | 968 weak_factory_.GetWeakPtr(), account_id, url, hash)); |
969 } else { | 969 } else { |
970 GURL device_wallpaper_url(url); | 970 GURL device_wallpaper_url(url); |
971 device_wallpaper_downloader_.reset(new CustomizationWallpaperDownloader( | 971 device_wallpaper_downloader_.reset(new CustomizationWallpaperDownloader( |
972 g_browser_process->system_request_context(), device_wallpaper_url, | 972 g_browser_process->system_request_context(), device_wallpaper_url, |
973 GetDeviceWallpaperDir(), GetDeviceWallpaperFilePath(), | 973 GetDeviceWallpaperDir(), GetDeviceWallpaperFilePath(), |
974 base::Bind(&WallpaperManager::OnDeviceWallpaperDownloaded, | 974 base::Bind(&WallpaperManager::OnDeviceWallpaperDownloaded, |
975 weak_factory_.GetWeakPtr(), account_id, hash))); | 975 weak_factory_.GetWeakPtr(), account_id, hash))); |
976 device_wallpaper_downloader_->Start(); | 976 device_wallpaper_downloader_->Start(); |
977 } | 977 } |
978 } | 978 } |
979 | 979 |
980 void WallpaperManager::OnDeviceWallpaperDownloaded(const AccountId& account_id, | 980 void WallpaperManager::OnDeviceWallpaperDownloaded(const AccountId& account_id, |
981 const std::string& hash, | 981 const std::string& hash, |
982 bool success, | 982 bool success, |
983 const GURL& url) { | 983 const GURL& url) { |
984 if (!success) { | 984 if (!success) { |
985 LOG(ERROR) << "Failed to download the device wallpaper. Fallback to " | 985 LOG(ERROR) << "Failed to download the device wallpaper. Fallback to " |
986 "default wallpaper."; | 986 "default wallpaper."; |
987 SetDefaultWallpaperDelayed(account_id); | 987 SetDefaultWallpaperDelayed(account_id); |
988 return; | 988 return; |
989 } | 989 } |
990 | 990 |
991 base::PostTaskWithTraitsAndReplyWithResult( | 991 base::PostTaskWithTraitsAndReplyWithResult( |
992 FROM_HERE, base::TaskTraits().MayBlock(), | 992 FROM_HERE, {base::MayBlock()}, |
993 base::Bind(&CheckDeviceWallpaperMatchHash, GetDeviceWallpaperFilePath(), | 993 base::Bind(&CheckDeviceWallpaperMatchHash, GetDeviceWallpaperFilePath(), |
994 hash), | 994 hash), |
995 base::Bind(&WallpaperManager::OnCheckDeviceWallpaperMatchHash, | 995 base::Bind(&WallpaperManager::OnCheckDeviceWallpaperMatchHash, |
996 weak_factory_.GetWeakPtr(), account_id, url.spec(), hash)); | 996 weak_factory_.GetWeakPtr(), account_id, url.spec(), hash)); |
997 } | 997 } |
998 | 998 |
999 void WallpaperManager::OnCheckDeviceWallpaperMatchHash( | 999 void WallpaperManager::OnCheckDeviceWallpaperMatchHash( |
1000 const AccountId& account_id, | 1000 const AccountId& account_id, |
1001 const std::string& url, | 1001 const std::string& url, |
1002 const std::string& hash, | 1002 const std::string& hash, |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1278 } | 1278 } |
1279 | 1279 |
1280 bool WallpaperManager::SetDeviceWallpaperIfApplicable( | 1280 bool WallpaperManager::SetDeviceWallpaperIfApplicable( |
1281 const AccountId& account_id) { | 1281 const AccountId& account_id) { |
1282 std::string url; | 1282 std::string url; |
1283 std::string hash; | 1283 std::string hash; |
1284 if (ShouldSetDeviceWallpaper(account_id, &url, &hash)) { | 1284 if (ShouldSetDeviceWallpaper(account_id, &url, &hash)) { |
1285 // Check if the device wallpaper exists and matches the hash. If so, use it | 1285 // Check if the device wallpaper exists and matches the hash. If so, use it |
1286 // directly. Otherwise download it first. | 1286 // directly. Otherwise download it first. |
1287 base::PostTaskWithTraitsAndReplyWithResult( | 1287 base::PostTaskWithTraitsAndReplyWithResult( |
1288 FROM_HERE, base::TaskTraits().MayBlock(), | 1288 FROM_HERE, {base::MayBlock()}, |
1289 base::Bind(&base::PathExists, GetDeviceWallpaperFilePath()), | 1289 base::Bind(&base::PathExists, GetDeviceWallpaperFilePath()), |
1290 base::Bind(&WallpaperManager::OnDeviceWallpaperExists, | 1290 base::Bind(&WallpaperManager::OnDeviceWallpaperExists, |
1291 weak_factory_.GetWeakPtr(), account_id, url, hash)); | 1291 weak_factory_.GetWeakPtr(), account_id, url, hash)); |
1292 return true; | 1292 return true; |
1293 } | 1293 } |
1294 return false; | 1294 return false; |
1295 } | 1295 } |
1296 | 1296 |
1297 void WallpaperManager::UserChangedChildStatus(user_manager::User* user) { | 1297 void WallpaperManager::UserChangedChildStatus(user_manager::User* user) { |
1298 SetUserWallpaperNow(user->GetAccountId()); | 1298 SetUserWallpaperNow(user->GetAccountId()); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1386 | 1386 |
1387 UMA_HISTOGRAM_ENUMERATION( | 1387 UMA_HISTOGRAM_ENUMERATION( |
1388 "Ash.Wallpaper.Apps", | 1388 "Ash.Wallpaper.Apps", |
1389 wallpaper_manager_util::ShouldUseAndroidWallpapersApp(profile) | 1389 wallpaper_manager_util::ShouldUseAndroidWallpapersApp(profile) |
1390 ? WALLPAPERS_APP_ANDROID | 1390 ? WALLPAPERS_APP_ANDROID |
1391 : WALLPAPERS_PICKER_APP_CHROMEOS, | 1391 : WALLPAPERS_PICKER_APP_CHROMEOS, |
1392 WALLPAPERS_APPS_NUM); | 1392 WALLPAPERS_APPS_NUM); |
1393 } | 1393 } |
1394 | 1394 |
1395 } // namespace chromeos | 1395 } // namespace chromeos |
OLD | NEW |