| 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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 if (!started_load_at_.is_null()) { | 429 if (!started_load_at_.is_null()) { |
| 430 const base::TimeDelta elapsed = base::Time::Now() - started_load_at_; | 430 const base::TimeDelta elapsed = base::Time::Now() - started_load_at_; |
| 431 manager->SaveLastLoadTime(elapsed); | 431 manager->SaveLastLoadTime(elapsed); |
| 432 } | 432 } |
| 433 if (manager->pending_inactive_ == this) { | 433 if (manager->pending_inactive_ == this) { |
| 434 // ProcessRequest() was never executed. | 434 // ProcessRequest() was never executed. |
| 435 manager->pending_inactive_ = NULL; | 435 manager->pending_inactive_ = NULL; |
| 436 } | 436 } |
| 437 | 437 |
| 438 // Destroy self. | 438 // Destroy self. |
| 439 DCHECK(manager->loading_.size() > 0); | 439 manager->RemovePendingWallpaperFromList(this); |
| 440 | |
| 441 for (WallpaperManager::PendingList::iterator i = manager->loading_.begin(); | |
| 442 i != manager->loading_.end(); | |
| 443 ++i) | |
| 444 if (i->get() == this) { | |
| 445 manager->loading_.erase(i); | |
| 446 break; | |
| 447 } | |
| 448 } | 440 } |
| 449 | 441 |
| 450 // WallpaperManager, public: --------------------------------------------------- | 442 // WallpaperManager, public: --------------------------------------------------- |
| 451 | 443 |
| 452 // TestApi. For testing purpose | 444 // TestApi. For testing purpose |
| 453 WallpaperManager::TestApi::TestApi(WallpaperManager* wallpaper_manager) | 445 WallpaperManager::TestApi::TestApi(WallpaperManager* wallpaper_manager) |
| 454 : wallpaper_manager_(wallpaper_manager) { | 446 : wallpaper_manager_(wallpaper_manager) { |
| 455 } | 447 } |
| 456 | 448 |
| 457 WallpaperManager::TestApi::~TestApi() { | 449 WallpaperManager::TestApi::~TestApi() { |
| (...skipping 1326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1784 if (!pending_inactive_) { | 1776 if (!pending_inactive_) { |
| 1785 loading_.push_back(new WallpaperManager::PendingWallpaper( | 1777 loading_.push_back(new WallpaperManager::PendingWallpaper( |
| 1786 (delayed ? GetWallpaperLoadDelay() | 1778 (delayed ? GetWallpaperLoadDelay() |
| 1787 : base::TimeDelta::FromMilliseconds(0)), | 1779 : base::TimeDelta::FromMilliseconds(0)), |
| 1788 user_id)); | 1780 user_id)); |
| 1789 pending_inactive_ = loading_.back(); | 1781 pending_inactive_ = loading_.back(); |
| 1790 } | 1782 } |
| 1791 return pending_inactive_; | 1783 return pending_inactive_; |
| 1792 } | 1784 } |
| 1793 | 1785 |
| 1786 void WallpaperManager::RemovePendingWallpaperFromList( |
| 1787 PendingWallpaper* pending) { |
| 1788 DCHECK(loading_.size() > 0); |
| 1789 for (WallpaperManager::PendingList::iterator i = loading_.begin(); |
| 1790 i != loading_.end(); |
| 1791 ++i) { |
| 1792 if (i->get() == pending) { |
| 1793 loading_.erase(i); |
| 1794 break; |
| 1795 } |
| 1796 } |
| 1797 |
| 1798 if (loading_.empty()) |
| 1799 FOR_EACH_OBSERVER(Observer, observers_, OnPendingListEmptyForTesting()); |
| 1800 } |
| 1801 |
| 1794 void WallpaperManager::SetCustomizedDefaultWallpaper( | 1802 void WallpaperManager::SetCustomizedDefaultWallpaper( |
| 1795 const GURL& wallpaper_url, | 1803 const GURL& wallpaper_url, |
| 1796 const base::FilePath& downloaded_file, | 1804 const base::FilePath& downloaded_file, |
| 1797 const base::FilePath& resized_directory) { | 1805 const base::FilePath& resized_directory) { |
| 1798 // Should fail if this ever happens in tests. | 1806 // Should fail if this ever happens in tests. |
| 1799 DCHECK(wallpaper_url.is_valid()); | 1807 DCHECK(wallpaper_url.is_valid()); |
| 1800 if (!wallpaper_url.is_valid()) { | 1808 if (!wallpaper_url.is_valid()) { |
| 1801 if (!wallpaper_url.is_empty()) { | 1809 if (!wallpaper_url.is_empty()) { |
| 1802 LOG(WARNING) << "Invalid Customized Wallpaper URL '" | 1810 LOG(WARNING) << "Invalid Customized Wallpaper URL '" |
| 1803 << wallpaper_url.spec() << "'"; | 1811 << wallpaper_url.spec() << "'"; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1819 weak_factory_.GetWeakPtr(), | 1827 weak_factory_.GetWeakPtr(), |
| 1820 wallpaper_url, | 1828 wallpaper_url, |
| 1821 downloaded_file, | 1829 downloaded_file, |
| 1822 base::Passed(rescaled_files.Pass())); | 1830 base::Passed(rescaled_files.Pass())); |
| 1823 if (!BrowserThread::PostBlockingPoolTaskAndReply( | 1831 if (!BrowserThread::PostBlockingPoolTaskAndReply( |
| 1824 FROM_HERE, check_file_exists, on_checked_closure)) { | 1832 FROM_HERE, check_file_exists, on_checked_closure)) { |
| 1825 LOG(WARNING) << "Failed to start check CheckCustomizedWallpaperFilesExist."; | 1833 LOG(WARNING) << "Failed to start check CheckCustomizedWallpaperFilesExist."; |
| 1826 } | 1834 } |
| 1827 } | 1835 } |
| 1828 | 1836 |
| 1837 size_t WallpaperManager::GetPendingListSizeForTesting() const { |
| 1838 return loading_.size(); |
| 1839 } |
| 1840 |
| 1829 void WallpaperManager::SetDefaultWallpaperPathsFromCommandLine( | 1841 void WallpaperManager::SetDefaultWallpaperPathsFromCommandLine( |
| 1830 base::CommandLine* command_line) { | 1842 base::CommandLine* command_line) { |
| 1831 default_small_wallpaper_file_ = command_line->GetSwitchValuePath( | 1843 default_small_wallpaper_file_ = command_line->GetSwitchValuePath( |
| 1832 ash::switches::kAshDefaultWallpaperSmall); | 1844 ash::switches::kAshDefaultWallpaperSmall); |
| 1833 default_large_wallpaper_file_ = command_line->GetSwitchValuePath( | 1845 default_large_wallpaper_file_ = command_line->GetSwitchValuePath( |
| 1834 ash::switches::kAshDefaultWallpaperLarge); | 1846 ash::switches::kAshDefaultWallpaperLarge); |
| 1835 guest_small_wallpaper_file_ = | 1847 guest_small_wallpaper_file_ = |
| 1836 command_line->GetSwitchValuePath(ash::switches::kAshGuestWallpaperSmall); | 1848 command_line->GetSwitchValuePath(ash::switches::kAshGuestWallpaperSmall); |
| 1837 guest_large_wallpaper_file_ = | 1849 guest_large_wallpaper_file_ = |
| 1838 command_line->GetSwitchValuePath(ash::switches::kAshGuestWallpaperLarge); | 1850 command_line->GetSwitchValuePath(ash::switches::kAshGuestWallpaperLarge); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1911 } | 1923 } |
| 1912 } | 1924 } |
| 1913 | 1925 |
| 1914 if (need_update_screen) { | 1926 if (need_update_screen) { |
| 1915 DoSetDefaultWallpaper(std::string(), | 1927 DoSetDefaultWallpaper(std::string(), |
| 1916 MovableOnDestroyCallbackHolder().Pass()); | 1928 MovableOnDestroyCallbackHolder().Pass()); |
| 1917 } | 1929 } |
| 1918 } | 1930 } |
| 1919 | 1931 |
| 1920 } // namespace chromeos | 1932 } // namespace chromeos |
| OLD | NEW |