| 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(); |
| 315 if (should_cache_wallpaper_) { | 316 if (should_cache_wallpaper_) { |
| 316 BrowserThread::PostDelayedTask( | 317 BrowserThread::PostDelayedTask( |
| 317 BrowserThread::UI, FROM_HERE, | 318 BrowserThread::UI, FROM_HERE, |
| 318 base::Bind(&WallpaperManager::CacheUsersWallpapers, | 319 base::Bind(&WallpaperManager::CacheUsersWallpapers, |
| 319 weak_factory_.GetWeakPtr()), | 320 weak_factory_.GetWeakPtr()), |
| 320 base::TimeDelta::FromMilliseconds(kCacheWallpaperDelayMs)); | 321 base::TimeDelta::FromMilliseconds(kCacheWallpaperDelayMs)); |
| 321 should_cache_wallpaper_ = false; | 322 should_cache_wallpaper_ = false; |
| 322 } | 323 } |
| 323 break; | 324 break; |
| 324 } | 325 } |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 // login. If UpdateWallpaper is called at GAIA login screen, no wallpaper will | 599 // login. If UpdateWallpaper is called at GAIA login screen, no wallpaper will |
| 599 // be set. It could result a black screen on external monitors. | 600 // be set. It could result a black screen on external monitors. |
| 600 // See http://crbug.com/265689 for detail. | 601 // See http://crbug.com/265689 for detail. |
| 601 if (last_selected_user_.empty()) { | 602 if (last_selected_user_.empty()) { |
| 602 SetDefaultWallpaper(); | 603 SetDefaultWallpaper(); |
| 603 return; | 604 return; |
| 604 } | 605 } |
| 605 SetUserWallpaper(last_selected_user_); | 606 SetUserWallpaper(last_selected_user_); |
| 606 } | 607 } |
| 607 | 608 |
| 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 |
| 608 // WallpaperManager, private: -------------------------------------------------- | 622 // WallpaperManager, private: -------------------------------------------------- |
| 609 | 623 |
| 610 void WallpaperManager::CacheUsersWallpapers() { | 624 void WallpaperManager::CacheUsersWallpapers() { |
| 611 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 625 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 612 UserList users = UserManager::Get()->GetUsers(); | 626 UserList users = UserManager::Get()->GetUsers(); |
| 613 | 627 |
| 614 if (!users.empty()) { | 628 if (!users.empty()) { |
| 615 UserList::const_iterator it = users.begin(); | 629 UserList::const_iterator it = users.begin(); |
| 616 // Skip the wallpaper of first user in the list. It should have been cached. | 630 // Skip the wallpaper of first user in the list. It should have been cached. |
| 617 it++; | 631 it++; |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1052 // |sequence_token_| here. | 1066 // |sequence_token_| here. |
| 1053 wallpaper_loader_->Start(wallpaper_path.value(), 0, sequence_token_, | 1067 wallpaper_loader_->Start(wallpaper_path.value(), 0, sequence_token_, |
| 1054 base::Bind(&WallpaperManager::OnWallpaperDecoded, | 1068 base::Bind(&WallpaperManager::OnWallpaperDecoded, |
| 1055 base::Unretained(this), | 1069 base::Unretained(this), |
| 1056 email, | 1070 email, |
| 1057 info.layout, | 1071 info.layout, |
| 1058 update_wallpaper)); | 1072 update_wallpaper)); |
| 1059 } | 1073 } |
| 1060 | 1074 |
| 1061 } // namespace chromeos | 1075 } // namespace chromeos |
| OLD | NEW |