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