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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 BrowserThread::UI, FROM_HERE, | 292 BrowserThread::UI, FROM_HERE, |
293 base::Bind(&WallpaperManager::CacheUsersWallpapers, | 293 base::Bind(&WallpaperManager::CacheUsersWallpapers, |
294 weak_factory_.GetWeakPtr()), | 294 weak_factory_.GetWeakPtr()), |
295 base::TimeDelta::FromMilliseconds(kCacheWallpaperDelayMs)); | 295 base::TimeDelta::FromMilliseconds(kCacheWallpaperDelayMs)); |
296 } else { | 296 } else { |
297 should_cache_wallpaper_ = true; | 297 should_cache_wallpaper_ = true; |
298 } | 298 } |
299 break; | 299 break; |
300 } | 300 } |
301 case chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED: { | 301 case chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED: { |
| 302 NotifyAnimationFinished(); |
302 if (should_cache_wallpaper_) { | 303 if (should_cache_wallpaper_) { |
303 BrowserThread::PostDelayedTask( | 304 BrowserThread::PostDelayedTask( |
304 BrowserThread::UI, FROM_HERE, | 305 BrowserThread::UI, FROM_HERE, |
305 base::Bind(&WallpaperManager::CacheUsersWallpapers, | 306 base::Bind(&WallpaperManager::CacheUsersWallpapers, |
306 weak_factory_.GetWeakPtr()), | 307 weak_factory_.GetWeakPtr()), |
307 base::TimeDelta::FromMilliseconds(kCacheWallpaperDelayMs)); | 308 base::TimeDelta::FromMilliseconds(kCacheWallpaperDelayMs)); |
308 should_cache_wallpaper_ = false; | 309 should_cache_wallpaper_ = false; |
309 } | 310 } |
310 break; | 311 break; |
311 } | 312 } |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 // login. If UpdateWallpaper is called at GAIA login screen, no wallpaper will | 585 // login. If UpdateWallpaper is called at GAIA login screen, no wallpaper will |
585 // be set. It could result a black screen on external monitors. | 586 // be set. It could result a black screen on external monitors. |
586 // See http://crbug.com/265689 for detail. | 587 // See http://crbug.com/265689 for detail. |
587 if (last_selected_user_.empty()) { | 588 if (last_selected_user_.empty()) { |
588 SetDefaultWallpaper(); | 589 SetDefaultWallpaper(); |
589 return; | 590 return; |
590 } | 591 } |
591 SetUserWallpaper(last_selected_user_); | 592 SetUserWallpaper(last_selected_user_); |
592 } | 593 } |
593 | 594 |
| 595 void WallpaperManager::AddObserver( |
| 596 base::WeakPtr<WallpaperManager::Observer> observer) { |
| 597 ObserverList::iterator i = observers_.begin(); |
| 598 while (i != observers_.end()) { |
| 599 if (*i != NULL) { |
| 600 if (i->get() == observer.get()) |
| 601 return; |
| 602 ++i; |
| 603 continue; |
| 604 } |
| 605 observers_.erase(i++); |
| 606 } |
| 607 observers_.push_back(observer); |
| 608 } |
| 609 |
| 610 void WallpaperManager::NotifyAnimationFinished() { |
| 611 ObserverList::iterator i = observers_.begin(); |
| 612 while (i != observers_.end()) { |
| 613 if (*i != NULL) { |
| 614 (*i)->OnWallpaperAnimationFinished(last_selected_user_); |
| 615 ++i; |
| 616 continue; |
| 617 } |
| 618 observers_.erase(i++); |
| 619 } |
| 620 } |
| 621 |
594 // WallpaperManager, private: -------------------------------------------------- | 622 // WallpaperManager, private: -------------------------------------------------- |
595 | 623 |
596 void WallpaperManager::CacheUsersWallpapers() { | 624 void WallpaperManager::CacheUsersWallpapers() { |
597 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 625 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
598 UserList users = UserManager::Get()->GetUsers(); | 626 UserList users = UserManager::Get()->GetUsers(); |
599 | 627 |
600 if (!users.empty()) { | 628 if (!users.empty()) { |
601 UserList::const_iterator it = users.begin(); | 629 UserList::const_iterator it = users.begin(); |
602 // 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. |
603 it++; | 631 it++; |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 // |sequence_token_| here. | 995 // |sequence_token_| here. |
968 wallpaper_loader_->Start(wallpaper_path.value(), 0, sequence_token_, | 996 wallpaper_loader_->Start(wallpaper_path.value(), 0, sequence_token_, |
969 base::Bind(&WallpaperManager::OnWallpaperDecoded, | 997 base::Bind(&WallpaperManager::OnWallpaperDecoded, |
970 base::Unretained(this), | 998 base::Unretained(this), |
971 email, | 999 email, |
972 info.layout, | 1000 info.layout, |
973 update_wallpaper)); | 1001 update_wallpaper)); |
974 } | 1002 } |
975 | 1003 |
976 } // namespace chromeos | 1004 } // namespace chromeos |
OLD | NEW |