| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/wallpaper_manager.h" | 5 #include "chrome/browser/chromeos/login/wallpaper_manager.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 BrowserThread::UI, FROM_HERE, | 305 BrowserThread::UI, FROM_HERE, |
| 306 base::Bind(&WallpaperManager::CacheUsersWallpapers, | 306 base::Bind(&WallpaperManager::CacheUsersWallpapers, |
| 307 weak_factory_.GetWeakPtr()), | 307 weak_factory_.GetWeakPtr()), |
| 308 base::TimeDelta::FromMilliseconds(kCacheWallpaperDelayMs)); | 308 base::TimeDelta::FromMilliseconds(kCacheWallpaperDelayMs)); |
| 309 } else { | 309 } else { |
| 310 should_cache_wallpaper_ = true; | 310 should_cache_wallpaper_ = true; |
| 311 } | 311 } |
| 312 break; | 312 break; |
| 313 } | 313 } |
| 314 case chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED: { | 314 case chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED: { |
| 315 NotifyAnimationFinished(); | |
| 316 if (should_cache_wallpaper_) { | 315 if (should_cache_wallpaper_) { |
| 317 BrowserThread::PostDelayedTask( | 316 BrowserThread::PostDelayedTask( |
| 318 BrowserThread::UI, FROM_HERE, | 317 BrowserThread::UI, FROM_HERE, |
| 319 base::Bind(&WallpaperManager::CacheUsersWallpapers, | 318 base::Bind(&WallpaperManager::CacheUsersWallpapers, |
| 320 weak_factory_.GetWeakPtr()), | 319 weak_factory_.GetWeakPtr()), |
| 321 base::TimeDelta::FromMilliseconds(kCacheWallpaperDelayMs)); | 320 base::TimeDelta::FromMilliseconds(kCacheWallpaperDelayMs)); |
| 322 should_cache_wallpaper_ = false; | 321 should_cache_wallpaper_ = false; |
| 323 } | 322 } |
| 324 break; | 323 break; |
| 325 } | 324 } |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 // login. If UpdateWallpaper is called at GAIA login screen, no wallpaper will | 598 // login. If UpdateWallpaper is called at GAIA login screen, no wallpaper will |
| 600 // be set. It could result a black screen on external monitors. | 599 // be set. It could result a black screen on external monitors. |
| 601 // See http://crbug.com/265689 for detail. | 600 // See http://crbug.com/265689 for detail. |
| 602 if (last_selected_user_.empty()) { | 601 if (last_selected_user_.empty()) { |
| 603 SetDefaultWallpaper(); | 602 SetDefaultWallpaper(); |
| 604 return; | 603 return; |
| 605 } | 604 } |
| 606 SetUserWallpaper(last_selected_user_); | 605 SetUserWallpaper(last_selected_user_); |
| 607 } | 606 } |
| 608 | 607 |
| 609 void WallpaperManager::AddObserver(WallpaperManager::Observer* observer) { | |
| 610 observers_.AddObserver(observer); | |
| 611 } | |
| 612 | |
| 613 void WallpaperManager::RemoveObserver(WallpaperManager::Observer* observer) { | |
| 614 observers_.RemoveObserver(observer); | |
| 615 } | |
| 616 | |
| 617 void WallpaperManager::NotifyAnimationFinished() { | |
| 618 FOR_EACH_OBSERVER( | |
| 619 Observer, observers_, OnWallpaperAnimationFinished(last_selected_user_)); | |
| 620 } | |
| 621 | |
| 622 // WallpaperManager, private: -------------------------------------------------- | 608 // WallpaperManager, private: -------------------------------------------------- |
| 623 | 609 |
| 624 void WallpaperManager::CacheUsersWallpapers() { | 610 void WallpaperManager::CacheUsersWallpapers() { |
| 625 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 611 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 626 UserList users = UserManager::Get()->GetUsers(); | 612 UserList users = UserManager::Get()->GetUsers(); |
| 627 | 613 |
| 628 if (!users.empty()) { | 614 if (!users.empty()) { |
| 629 UserList::const_iterator it = users.begin(); | 615 UserList::const_iterator it = users.begin(); |
| 630 // Skip the wallpaper of first user in the list. It should have been cached. | 616 // Skip the wallpaper of first user in the list. It should have been cached. |
| 631 it++; | 617 it++; |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1066 // |sequence_token_| here. | 1052 // |sequence_token_| here. |
| 1067 wallpaper_loader_->Start(wallpaper_path.value(), 0, sequence_token_, | 1053 wallpaper_loader_->Start(wallpaper_path.value(), 0, sequence_token_, |
| 1068 base::Bind(&WallpaperManager::OnWallpaperDecoded, | 1054 base::Bind(&WallpaperManager::OnWallpaperDecoded, |
| 1069 base::Unretained(this), | 1055 base::Unretained(this), |
| 1070 email, | 1056 email, |
| 1071 info.layout, | 1057 info.layout, |
| 1072 update_wallpaper)); | 1058 update_wallpaper)); |
| 1073 } | 1059 } |
| 1074 | 1060 |
| 1075 } // namespace chromeos | 1061 } // namespace chromeos |
| OLD | NEW |