| 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 <numeric> | 7 #include <numeric> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 if (!started_load_at_.is_null()) { | 413 if (!started_load_at_.is_null()) { |
| 414 const base::TimeDelta elapsed = base::Time::Now() - started_load_at_; | 414 const base::TimeDelta elapsed = base::Time::Now() - started_load_at_; |
| 415 manager->SaveLastLoadTime(elapsed); | 415 manager->SaveLastLoadTime(elapsed); |
| 416 } | 416 } |
| 417 if (manager->pending_inactive_ == this) { | 417 if (manager->pending_inactive_ == this) { |
| 418 // ProcessRequest() was never executed. | 418 // ProcessRequest() was never executed. |
| 419 manager->pending_inactive_ = NULL; | 419 manager->pending_inactive_ = NULL; |
| 420 } | 420 } |
| 421 | 421 |
| 422 // Destroy self. | 422 // Destroy self. |
| 423 DCHECK(manager->loading_.size() > 0); | 423 manager->RemovePendingWallpaperFromList(this); |
| 424 | |
| 425 for (WallpaperManager::PendingList::iterator i = manager->loading_.begin(); | |
| 426 i != manager->loading_.end(); | |
| 427 ++i) | |
| 428 if (i->get() == this) { | |
| 429 manager->loading_.erase(i); | |
| 430 break; | |
| 431 } | |
| 432 } | 424 } |
| 433 | 425 |
| 434 // WallpaperManager, public: --------------------------------------------------- | 426 // WallpaperManager, public: --------------------------------------------------- |
| 435 | 427 |
| 436 // TestApi. For testing purpose | 428 // TestApi. For testing purpose |
| 437 WallpaperManager::TestApi::TestApi(WallpaperManager* wallpaper_manager) | 429 WallpaperManager::TestApi::TestApi(WallpaperManager* wallpaper_manager) |
| 438 : wallpaper_manager_(wallpaper_manager) { | 430 : wallpaper_manager_(wallpaper_manager) { |
| 439 } | 431 } |
| 440 | 432 |
| 441 WallpaperManager::TestApi::~TestApi() { | 433 WallpaperManager::TestApi::~TestApi() { |
| (...skipping 1304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1746 if (!pending_inactive_) { | 1738 if (!pending_inactive_) { |
| 1747 loading_.push_back(new WallpaperManager::PendingWallpaper( | 1739 loading_.push_back(new WallpaperManager::PendingWallpaper( |
| 1748 (delayed ? GetWallpaperLoadDelay() | 1740 (delayed ? GetWallpaperLoadDelay() |
| 1749 : base::TimeDelta::FromMilliseconds(0)), | 1741 : base::TimeDelta::FromMilliseconds(0)), |
| 1750 user_id)); | 1742 user_id)); |
| 1751 pending_inactive_ = loading_.back(); | 1743 pending_inactive_ = loading_.back(); |
| 1752 } | 1744 } |
| 1753 return pending_inactive_; | 1745 return pending_inactive_; |
| 1754 } | 1746 } |
| 1755 | 1747 |
| 1748 void WallpaperManager::RemovePendingWallpaperFromList( |
| 1749 PendingWallpaper* pending) { |
| 1750 DCHECK(loading_.size() > 0); |
| 1751 for (WallpaperManager::PendingList::iterator i = loading_.begin(); |
| 1752 i != loading_.end(); |
| 1753 ++i) |
| 1754 if (i->get() == pending) { |
| 1755 loading_.erase(i); |
| 1756 break; |
| 1757 } |
| 1758 |
| 1759 if (loading_.size() == 0) |
| 1760 FOR_EACH_OBSERVER(Observer, observers_, OnPendingListEmptyForTesting()); |
| 1761 } |
| 1762 |
| 1756 void WallpaperManager::SetCustomizedDefaultWallpaper( | 1763 void WallpaperManager::SetCustomizedDefaultWallpaper( |
| 1757 const GURL& wallpaper_url, | 1764 const GURL& wallpaper_url, |
| 1758 const base::FilePath& downloaded_file, | 1765 const base::FilePath& downloaded_file, |
| 1759 const base::FilePath& resized_directory) { | 1766 const base::FilePath& resized_directory) { |
| 1760 // Should fail if this ever happens in tests. | 1767 // Should fail if this ever happens in tests. |
| 1761 DCHECK(wallpaper_url.is_valid()); | 1768 DCHECK(wallpaper_url.is_valid()); |
| 1762 if (!wallpaper_url.is_valid()) { | 1769 if (!wallpaper_url.is_valid()) { |
| 1763 if (!wallpaper_url.is_empty()) { | 1770 if (!wallpaper_url.is_empty()) { |
| 1764 LOG(WARNING) << "Invalid Customized Wallpaper URL '" | 1771 LOG(WARNING) << "Invalid Customized Wallpaper URL '" |
| 1765 << wallpaper_url.spec() << "'"; | 1772 << wallpaper_url.spec() << "'"; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1873 } | 1880 } |
| 1874 } | 1881 } |
| 1875 | 1882 |
| 1876 if (need_update_screen) { | 1883 if (need_update_screen) { |
| 1877 DoSetDefaultWallpaper(std::string(), | 1884 DoSetDefaultWallpaper(std::string(), |
| 1878 MovableOnDestroyCallbackHolder().Pass()); | 1885 MovableOnDestroyCallbackHolder().Pass()); |
| 1879 } | 1886 } |
| 1880 } | 1887 } |
| 1881 | 1888 |
| 1882 } // namespace chromeos | 1889 } // namespace chromeos |
| OLD | NEW |