| 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); | |
| 312 } | 310 } |
| 313 | 311 |
| 314 WallpaperManager::~WallpaperManager() { | 312 WallpaperManager::~WallpaperManager() { |
| 315 // TODO(bshe): Lifetime of WallpaperManager needs more consideration. | 313 // TODO(bshe): Lifetime of WallpaperManager needs more consideration. |
| 316 // http://crbug.com/171694 | 314 // http://crbug.com/171694 |
| 317 DCHECK(!show_user_name_on_signin_subscription_); | 315 DCHECK(!show_user_name_on_signin_subscription_); |
| 318 | 316 |
| 319 user_manager::UserManager::Get()->RemoveSessionStateObserver(this); | |
| 320 | |
| 321 ClearObsoleteWallpaperPrefs(); | 317 ClearObsoleteWallpaperPrefs(); |
| 322 weak_factory_.InvalidateWeakPtrs(); | 318 weak_factory_.InvalidateWeakPtrs(); |
| 323 } | 319 } |
| 324 | 320 |
| 325 WallpaperManager::WallpaperResolution | 321 WallpaperManager::WallpaperResolution |
| 326 WallpaperManager::GetAppropriateResolution() { | 322 WallpaperManager::GetAppropriateResolution() { |
| 327 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 323 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 328 gfx::Size size = | 324 gfx::Size size = |
| 329 ash::DesktopBackgroundController::GetMaxDisplaySizeInNative(); | 325 ash::DesktopBackgroundController::GetMaxDisplaySizeInNative(); |
| 330 return (size.width() > wallpaper::kSmallWallpaperMaxWidth || | 326 return (size.width() > wallpaper::kSmallWallpaperMaxWidth || |
| (...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 948 } | 944 } |
| 949 | 945 |
| 950 if (loading_.empty()) | 946 if (loading_.empty()) |
| 951 FOR_EACH_OBSERVER(Observer, observers_, OnPendingListEmptyForTesting()); | 947 FOR_EACH_OBSERVER(Observer, observers_, OnPendingListEmptyForTesting()); |
| 952 } | 948 } |
| 953 | 949 |
| 954 size_t WallpaperManager::GetPendingListSizeForTesting() const { | 950 size_t WallpaperManager::GetPendingListSizeForTesting() const { |
| 955 return loading_.size(); | 951 return loading_.size(); |
| 956 } | 952 } |
| 957 | 953 |
| 958 void WallpaperManager::UserChangedChildStatus(user_manager::User* user) { | |
| 959 SetUserWallpaperNow(user->email()); | |
| 960 } | |
| 961 | |
| 962 void WallpaperManager::OnDefaultWallpaperDecoded( | 954 void WallpaperManager::OnDefaultWallpaperDecoded( |
| 963 const base::FilePath& path, | 955 const base::FilePath& path, |
| 964 const wallpaper::WallpaperLayout layout, | 956 const wallpaper::WallpaperLayout layout, |
| 965 scoped_ptr<user_manager::UserImage>* result_out, | 957 scoped_ptr<user_manager::UserImage>* result_out, |
| 966 MovableOnDestroyCallbackHolder on_finish, | 958 MovableOnDestroyCallbackHolder on_finish, |
| 967 const user_manager::UserImage& user_image) { | 959 const user_manager::UserImage& user_image) { |
| 968 result_out->reset(new user_manager::UserImage(user_image)); | 960 result_out->reset(new user_manager::UserImage(user_image)); |
| 969 ash::Shell::GetInstance()->desktop_background_controller()->SetWallpaperImage( | 961 ash::Shell::GetInstance()->desktop_background_controller()->SetWallpaperImage( |
| 970 user_image.image(), layout); | 962 user_image.image(), layout); |
| 971 } | 963 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1025 } | 1017 } |
| 1026 } | 1018 } |
| 1027 | 1019 |
| 1028 if (need_update_screen) { | 1020 if (need_update_screen) { |
| 1029 DoSetDefaultWallpaper(std::string(), | 1021 DoSetDefaultWallpaper(std::string(), |
| 1030 MovableOnDestroyCallbackHolder().Pass()); | 1022 MovableOnDestroyCallbackHolder().Pass()); |
| 1031 } | 1023 } |
| 1032 } | 1024 } |
| 1033 | 1025 |
| 1034 } // namespace chromeos | 1026 } // namespace chromeos |
| OLD | NEW |