| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/users/wallpaper/wallpaper_manager.h" | 5 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <numeric> | 8 #include <numeric> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 on_finish_.reset(); | 329 on_finish_.reset(); |
| 330 } | 330 } |
| 331 | 331 |
| 332 // This method is called by callback, when load request is finished. | 332 // This method is called by callback, when load request is finished. |
| 333 void OnWallpaperSet() { | 333 void OnWallpaperSet() { |
| 334 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 334 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 335 | 335 |
| 336 // The only known case for this check to fail is global destruction during | 336 // The only known case for this check to fail is global destruction during |
| 337 // wallpaper load. It should never happen. | 337 // wallpaper load. It should never happen. |
| 338 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) | 338 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) |
| 339 return; // We are in a process of global destruction. | 339 return; // We are in a process of global destruction. |
| 340 | 340 |
| 341 timer.Stop(); // Erase reference to self. | 341 timer.Stop(); // Erase reference to self. |
| 342 | 342 |
| 343 WallpaperManager* manager = WallpaperManager::Get(); | 343 WallpaperManager* manager = WallpaperManager::Get(); |
| 344 if (!started_load_at_.is_null()) { | 344 if (!started_load_at_.is_null()) { |
| 345 const base::TimeDelta elapsed = base::Time::Now() - started_load_at_; | 345 const base::TimeDelta elapsed = base::Time::Now() - started_load_at_; |
| 346 manager->SaveLastLoadTime(elapsed); | 346 manager->SaveLastLoadTime(elapsed); |
| 347 } | 347 } |
| 348 if (manager->pending_inactive_ == this) { | 348 if (manager->pending_inactive_ == this) { |
| 349 // ProcessRequest() was never executed. | 349 // ProcessRequest() was never executed. |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 874 DCHECK(loading_.size() > 0); | 874 DCHECK(loading_.size() > 0); |
| 875 for (WallpaperManager::PendingList::iterator i = loading_.begin(); | 875 for (WallpaperManager::PendingList::iterator i = loading_.begin(); |
| 876 i != loading_.end(); | 876 i != loading_.end(); |
| 877 ++i) { | 877 ++i) { |
| 878 if (i->get() == pending) { | 878 if (i->get() == pending) { |
| 879 loading_.erase(i); | 879 loading_.erase(i); |
| 880 break; | 880 break; |
| 881 } | 881 } |
| 882 } | 882 } |
| 883 | 883 |
| 884 if (loading_.empty()) | 884 if (loading_.empty()) { |
| 885 FOR_EACH_OBSERVER(Observer, observers_, OnPendingListEmptyForTesting()); | 885 for (auto& observer : observers_) |
| 886 observer.OnPendingListEmptyForTesting(); |
| 887 } |
| 886 } | 888 } |
| 887 | 889 |
| 888 void WallpaperManager::SetPolicyControlledWallpaper( | 890 void WallpaperManager::SetPolicyControlledWallpaper( |
| 889 const AccountId& account_id, | 891 const AccountId& account_id, |
| 890 std::unique_ptr<user_manager::UserImage> user_image) { | 892 std::unique_ptr<user_manager::UserImage> user_image) { |
| 891 if (!CanGetFilesId()) { | 893 if (!CanGetFilesId()) { |
| 892 CallWhenCanGetFilesId( | 894 CallWhenCanGetFilesId( |
| 893 base::Bind(&WallpaperManager::SetPolicyControlledWallpaper, | 895 base::Bind(&WallpaperManager::SetPolicyControlledWallpaper, |
| 894 weak_factory_.GetWeakPtr(), account_id, | 896 weak_factory_.GetWeakPtr(), account_id, |
| 895 base::Passed(std::move(user_image)))); | 897 base::Passed(std::move(user_image)))); |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1180 &stored_value)) { | 1182 &stored_value)) { |
| 1181 return wallpaper::WallpaperFilesId::FromString(stored_value); | 1183 return wallpaper::WallpaperFilesId::FromString(stored_value); |
| 1182 } | 1184 } |
| 1183 const std::string& old_id = account_id.GetUserEmail(); // Migrated | 1185 const std::string& old_id = account_id.GetUserEmail(); // Migrated |
| 1184 const wallpaper::WallpaperFilesId files_id = HashWallpaperFilesIdStr(old_id); | 1186 const wallpaper::WallpaperFilesId files_id = HashWallpaperFilesIdStr(old_id); |
| 1185 SetKnownUserWallpaperFilesId(account_id, files_id); | 1187 SetKnownUserWallpaperFilesId(account_id, files_id); |
| 1186 return files_id; | 1188 return files_id; |
| 1187 } | 1189 } |
| 1188 | 1190 |
| 1189 } // namespace chromeos | 1191 } // namespace chromeos |
| OLD | NEW |