| 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 "components/wallpaper/wallpaper_manager_base.h" | 5 #include "components/wallpaper/wallpaper_manager_base.h" |
| 6 | 6 |
| 7 #include <numeric> | 7 #include <numeric> |
| 8 #include <vector> | 8 #include <vector> |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 void WallpaperManagerBase::SetUserWallpaperDelayed( | 623 void WallpaperManagerBase::SetUserWallpaperDelayed( |
| 624 const AccountId& account_id) { | 624 const AccountId& account_id) { |
| 625 ScheduleSetUserWallpaper(account_id, true); | 625 ScheduleSetUserWallpaper(account_id, true); |
| 626 } | 626 } |
| 627 | 627 |
| 628 void WallpaperManagerBase::SetUserWallpaperNow(const AccountId& account_id) { | 628 void WallpaperManagerBase::SetUserWallpaperNow(const AccountId& account_id) { |
| 629 ScheduleSetUserWallpaper(account_id, false); | 629 ScheduleSetUserWallpaper(account_id, false); |
| 630 } | 630 } |
| 631 | 631 |
| 632 void WallpaperManagerBase::UpdateWallpaper(bool clear_cache) { | 632 void WallpaperManagerBase::UpdateWallpaper(bool clear_cache) { |
| 633 FOR_EACH_OBSERVER(Observer, observers_, OnUpdateWallpaperForTesting()); | 633 for (auto& observer : observers_) |
| 634 observer.OnUpdateWallpaperForTesting(); |
| 634 if (clear_cache) | 635 if (clear_cache) |
| 635 wallpaper_cache_.clear(); | 636 wallpaper_cache_.clear(); |
| 636 SetUserWallpaperNow(last_selected_user_); | 637 SetUserWallpaperNow(last_selected_user_); |
| 637 } | 638 } |
| 638 | 639 |
| 639 void WallpaperManagerBase::AddObserver( | 640 void WallpaperManagerBase::AddObserver( |
| 640 WallpaperManagerBase::Observer* observer) { | 641 WallpaperManagerBase::Observer* observer) { |
| 641 observers_.AddObserver(observer); | 642 observers_.AddObserver(observer); |
| 642 } | 643 } |
| 643 | 644 |
| 644 void WallpaperManagerBase::RemoveObserver( | 645 void WallpaperManagerBase::RemoveObserver( |
| 645 WallpaperManagerBase::Observer* observer) { | 646 WallpaperManagerBase::Observer* observer) { |
| 646 observers_.RemoveObserver(observer); | 647 observers_.RemoveObserver(observer); |
| 647 } | 648 } |
| 648 | 649 |
| 649 void WallpaperManagerBase::NotifyAnimationFinished() { | 650 void WallpaperManagerBase::NotifyAnimationFinished() { |
| 650 FOR_EACH_OBSERVER(Observer, observers_, | 651 for (auto& observer : observers_) |
| 651 OnWallpaperAnimationFinished(last_selected_user_)); | 652 observer.OnWallpaperAnimationFinished(last_selected_user_); |
| 652 } | 653 } |
| 653 | 654 |
| 654 // WallpaperManager, protected: ----------------------------------------------- | 655 // WallpaperManager, protected: ----------------------------------------------- |
| 655 | 656 |
| 656 bool WallpaperManagerBase::GetWallpaperFromCache(const AccountId& account_id, | 657 bool WallpaperManagerBase::GetWallpaperFromCache(const AccountId& account_id, |
| 657 gfx::ImageSkia* image) { | 658 gfx::ImageSkia* image) { |
| 658 DCHECK(thread_checker_.CalledOnValidThread()); | 659 DCHECK(thread_checker_.CalledOnValidThread()); |
| 659 CustomWallpaperMap::const_iterator it = wallpaper_cache_.find(account_id); | 660 CustomWallpaperMap::const_iterator it = wallpaper_cache_.find(account_id); |
| 660 if (it != wallpaper_cache_.end() && !(*it).second.second.isNull()) { | 661 if (it != wallpaper_cache_.end() && !(*it).second.second.isNull()) { |
| 661 *image = (*it).second.second; | 662 *image = (*it).second.second; |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1020 void WallpaperManagerBase::CreateSolidDefaultWallpaper() { | 1021 void WallpaperManagerBase::CreateSolidDefaultWallpaper() { |
| 1021 loaded_wallpapers_for_test_++; | 1022 loaded_wallpapers_for_test_++; |
| 1022 SkBitmap bitmap; | 1023 SkBitmap bitmap; |
| 1023 bitmap.allocN32Pixels(1, 1); | 1024 bitmap.allocN32Pixels(1, 1); |
| 1024 bitmap.eraseColor(kDefaultWallpaperColor); | 1025 bitmap.eraseColor(kDefaultWallpaperColor); |
| 1025 const gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(bitmap); | 1026 const gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(bitmap); |
| 1026 default_wallpaper_image_.reset(new user_manager::UserImage(image)); | 1027 default_wallpaper_image_.reset(new user_manager::UserImage(image)); |
| 1027 } | 1028 } |
| 1028 | 1029 |
| 1029 } // namespace wallpaper | 1030 } // namespace wallpaper |
| OLD | NEW |