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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED, | 300 chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED, |
301 content::NotificationService::AllSources()); | 301 content::NotificationService::AllSources()); |
302 sequence_token_ = BrowserThread::GetBlockingPool()->GetNamedSequenceToken( | 302 sequence_token_ = BrowserThread::GetBlockingPool()->GetNamedSequenceToken( |
303 wallpaper::kWallpaperSequenceTokenName); | 303 wallpaper::kWallpaperSequenceTokenName); |
304 task_runner_ = BrowserThread::GetBlockingPool()-> | 304 task_runner_ = BrowserThread::GetBlockingPool()-> |
305 GetSequencedTaskRunnerWithShutdownBehavior( | 305 GetSequencedTaskRunnerWithShutdownBehavior( |
306 sequence_token_, | 306 sequence_token_, |
307 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); | 307 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); |
308 wallpaper_loader_ = new UserImageLoader(ImageDecoder::ROBUST_JPEG_CODEC, | 308 wallpaper_loader_ = new UserImageLoader(ImageDecoder::ROBUST_JPEG_CODEC, |
309 task_runner_); | 309 task_runner_); |
| 310 |
| 311 user_manager::UserManager::Get()->AddSessionStateObserver(this); |
310 } | 312 } |
311 | 313 |
312 WallpaperManager::~WallpaperManager() { | 314 WallpaperManager::~WallpaperManager() { |
313 // TODO(bshe): Lifetime of WallpaperManager needs more consideration. | 315 // TODO(bshe): Lifetime of WallpaperManager needs more consideration. |
314 // http://crbug.com/171694 | 316 // http://crbug.com/171694 |
315 DCHECK(!show_user_name_on_signin_subscription_); | 317 DCHECK(!show_user_name_on_signin_subscription_); |
316 | 318 |
| 319 user_manager::UserManager::Get()->RemoveSessionStateObserver(this); |
| 320 |
317 ClearObsoleteWallpaperPrefs(); | 321 ClearObsoleteWallpaperPrefs(); |
318 weak_factory_.InvalidateWeakPtrs(); | 322 weak_factory_.InvalidateWeakPtrs(); |
319 } | 323 } |
320 | 324 |
321 WallpaperManager::WallpaperResolution | 325 WallpaperManager::WallpaperResolution |
322 WallpaperManager::GetAppropriateResolution() { | 326 WallpaperManager::GetAppropriateResolution() { |
323 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 327 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
324 gfx::Size size = | 328 gfx::Size size = |
325 ash::DesktopBackgroundController::GetMaxDisplaySizeInNative(); | 329 ash::DesktopBackgroundController::GetMaxDisplaySizeInNative(); |
326 return (size.width() > wallpaper::kSmallWallpaperMaxWidth || | 330 return (size.width() > wallpaper::kSmallWallpaperMaxWidth || |
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 small_wallpaper_image.Pass(), | 963 small_wallpaper_image.Pass(), |
960 rescaled_files->path_rescaled_large(), | 964 rescaled_files->path_rescaled_large(), |
961 large_wallpaper_image.Pass()); | 965 large_wallpaper_image.Pass()); |
962 VLOG(1) << "Customized default wallpaper applied."; | 966 VLOG(1) << "Customized default wallpaper applied."; |
963 } | 967 } |
964 | 968 |
965 size_t WallpaperManager::GetPendingListSizeForTesting() const { | 969 size_t WallpaperManager::GetPendingListSizeForTesting() const { |
966 return loading_.size(); | 970 return loading_.size(); |
967 } | 971 } |
968 | 972 |
| 973 void WallpaperManager::UserChangedChildStatus(user_manager::User* user) { |
| 974 SetUserWallpaperNow(user->email()); |
| 975 } |
| 976 |
969 void WallpaperManager::OnDefaultWallpaperDecoded( | 977 void WallpaperManager::OnDefaultWallpaperDecoded( |
970 const base::FilePath& path, | 978 const base::FilePath& path, |
971 const wallpaper::WallpaperLayout layout, | 979 const wallpaper::WallpaperLayout layout, |
972 scoped_ptr<user_manager::UserImage>* result_out, | 980 scoped_ptr<user_manager::UserImage>* result_out, |
973 MovableOnDestroyCallbackHolder on_finish, | 981 MovableOnDestroyCallbackHolder on_finish, |
974 const user_manager::UserImage& user_image) { | 982 const user_manager::UserImage& user_image) { |
975 result_out->reset(new user_manager::UserImage(user_image)); | 983 result_out->reset(new user_manager::UserImage(user_image)); |
976 ash::Shell::GetInstance()->desktop_background_controller()->SetWallpaperImage( | 984 ash::Shell::GetInstance()->desktop_background_controller()->SetWallpaperImage( |
977 user_image.image(), layout); | 985 user_image.image(), layout); |
978 } | 986 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1032 } | 1040 } |
1033 } | 1041 } |
1034 | 1042 |
1035 if (need_update_screen) { | 1043 if (need_update_screen) { |
1036 DoSetDefaultWallpaper(std::string(), | 1044 DoSetDefaultWallpaper(std::string(), |
1037 MovableOnDestroyCallbackHolder().Pass()); | 1045 MovableOnDestroyCallbackHolder().Pass()); |
1038 } | 1046 } |
1039 } | 1047 } |
1040 | 1048 |
1041 } // namespace chromeos | 1049 } // namespace chromeos |
OLD | NEW |