OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 } | 123 } |
124 | 124 |
125 // static | 125 // static |
126 void WallpaperManager::RegisterPrefs(PrefServiceSimple* local_state) { | 126 void WallpaperManager::RegisterPrefs(PrefServiceSimple* local_state) { |
127 local_state->RegisterDictionaryPref(prefs::kUsersWallpaperInfo); | 127 local_state->RegisterDictionaryPref(prefs::kUsersWallpaperInfo); |
128 local_state->RegisterDictionaryPref(kUserWallpapers); | 128 local_state->RegisterDictionaryPref(kUserWallpapers); |
129 local_state->RegisterDictionaryPref(kUserWallpapersProperties); | 129 local_state->RegisterDictionaryPref(kUserWallpapersProperties); |
130 } | 130 } |
131 | 131 |
132 void WallpaperManager::AddObservers() { | 132 void WallpaperManager::AddObservers() { |
| 133 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); |
133 if (!DBusThreadManager::Get()->GetRootPowerManagerClient()->HasObserver(this)) | 134 if (!DBusThreadManager::Get()->GetRootPowerManagerClient()->HasObserver(this)) |
134 DBusThreadManager::Get()->GetRootPowerManagerClient()->AddObserver(this); | 135 DBusThreadManager::Get()->GetRootPowerManagerClient()->AddObserver(this); |
135 system::TimezoneSettings::GetInstance()->AddObserver(this); | 136 system::TimezoneSettings::GetInstance()->AddObserver(this); |
136 } | 137 } |
137 | 138 |
138 void WallpaperManager::EnsureLoggedInUserWallpaperLoaded() { | 139 void WallpaperManager::EnsureLoggedInUserWallpaperLoaded() { |
139 // Some browser tests do not have a shell instance. As no wallpaper is needed | 140 // Some browser tests do not have a shell instance. As no wallpaper is needed |
140 // in these tests anyway, avoid loading one, preventing crashes and speeding | 141 // in these tests anyway, avoid loading one, preventing crashes and speeding |
141 // up the tests. | 142 // up the tests. |
142 if (!ash::Shell::HasInstance()) | 143 if (!ash::Shell::HasInstance()) |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 ClearWallpaperCache(); | 552 ClearWallpaperCache(); |
552 current_wallpaper_path_.clear(); | 553 current_wallpaper_path_.clear(); |
553 SetUserWallpaper(last_selected_user_); | 554 SetUserWallpaper(last_selected_user_); |
554 } | 555 } |
555 | 556 |
556 // WallpaperManager, private: -------------------------------------------------- | 557 // WallpaperManager, private: -------------------------------------------------- |
557 | 558 |
558 WallpaperManager::~WallpaperManager() { | 559 WallpaperManager::~WallpaperManager() { |
559 ClearObsoleteWallpaperPrefs(); | 560 ClearObsoleteWallpaperPrefs(); |
560 DBusThreadManager::Get()->GetRootPowerManagerClient()->RemoveObserver(this); | 561 DBusThreadManager::Get()->GetRootPowerManagerClient()->RemoveObserver(this); |
| 562 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); |
561 system::TimezoneSettings::GetInstance()->RemoveObserver(this); | 563 system::TimezoneSettings::GetInstance()->RemoveObserver(this); |
562 weak_factory_.InvalidateWeakPtrs(); | 564 weak_factory_.InvalidateWeakPtrs(); |
563 } | 565 } |
564 | 566 |
565 void WallpaperManager::BatchUpdateWallpaper() { | 567 void WallpaperManager::BatchUpdateWallpaper() { |
566 NOTIMPLEMENTED(); | 568 NOTIMPLEMENTED(); |
567 } | 569 } |
568 | 570 |
569 void WallpaperManager::CacheUsersWallpapers() { | 571 void WallpaperManager::CacheUsersWallpapers() { |
570 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 572 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
888 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 890 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
889 | 891 |
890 wallpaper_loader_->Start(wallpaper_path.value(), 0, | 892 wallpaper_loader_->Start(wallpaper_path.value(), 0, |
891 base::Bind(&WallpaperManager::OnWallpaperDecoded, | 893 base::Bind(&WallpaperManager::OnWallpaperDecoded, |
892 base::Unretained(this), | 894 base::Unretained(this), |
893 email, | 895 email, |
894 info.layout, | 896 info.layout, |
895 update_wallpaper)); | 897 update_wallpaper)); |
896 } | 898 } |
897 | 899 |
| 900 void WallpaperManager::SystemResumed(const base::TimeDelta& sleep_duration) { |
| 901 BatchUpdateWallpaper(); |
| 902 } |
| 903 |
898 void WallpaperManager::OnResume(const base::TimeDelta& sleep_duration) { | 904 void WallpaperManager::OnResume(const base::TimeDelta& sleep_duration) { |
899 BatchUpdateWallpaper(); | 905 SystemResumed(sleep_duration); |
900 } | 906 } |
901 | 907 |
902 void WallpaperManager::TimezoneChanged(const icu::TimeZone& timezone) { | 908 void WallpaperManager::TimezoneChanged(const icu::TimeZone& timezone) { |
903 RestartTimer(); | 909 RestartTimer(); |
904 } | 910 } |
905 | 911 |
906 void WallpaperManager::ValidateAndLoadWallpaper( | 912 void WallpaperManager::ValidateAndLoadWallpaper( |
907 const std::string& email, | 913 const std::string& email, |
908 const WallpaperInfo& info, | 914 const WallpaperInfo& info, |
909 bool update_wallpaper, | 915 bool update_wallpaper, |
910 const FilePath& wallpaper_path) { | 916 const FilePath& wallpaper_path) { |
911 FilePath valid_path(wallpaper_path); | 917 FilePath valid_path(wallpaper_path); |
912 if (!file_util::PathExists(wallpaper_path)) | 918 if (!file_util::PathExists(wallpaper_path)) |
913 valid_path = wallpaper_path.AddExtension(".png"); | 919 valid_path = wallpaper_path.AddExtension(".png"); |
914 BrowserThread::PostTask(BrowserThread::UI, | 920 BrowserThread::PostTask(BrowserThread::UI, |
915 FROM_HERE, | 921 FROM_HERE, |
916 base::Bind(&WallpaperManager::StartLoad, | 922 base::Bind(&WallpaperManager::StartLoad, |
917 base::Unretained(this), | 923 base::Unretained(this), |
918 email, | 924 email, |
919 info, | 925 info, |
920 update_wallpaper, | 926 update_wallpaper, |
921 valid_path)); | 927 valid_path)); |
922 } | 928 } |
923 | 929 |
924 } // chromeos | 930 } // chromeos |
OLD | NEW |