Chromium Code Reviews| 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 "ash/desktop_background/desktop_background_controller.h" | 7 #include "ash/desktop_background/desktop_background_controller.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 392 return; | 392 return; |
| 393 | 393 |
| 394 User::WallpaperType type; | 394 User::WallpaperType type; |
| 395 int index; | 395 int index; |
| 396 base::Time date; | 396 base::Time date; |
| 397 GetUserWallpaperProperties(email, &type, &index, &date); | 397 GetUserWallpaperProperties(email, &type, &index, &date); |
| 398 if (type == User::DAILY && date != base::Time::Now().LocalMidnight()) { | 398 if (type == User::DAILY && date != base::Time::Now().LocalMidnight()) { |
| 399 index = ash::GetNextWallpaperIndex(index); | 399 index = ash::GetNextWallpaperIndex(index); |
| 400 SaveUserWallpaperProperties(email, User::DAILY, index); | 400 SaveUserWallpaperProperties(email, User::DAILY, index); |
| 401 } else if (type == User::CUSTOMIZED) { | 401 } else if (type == User::CUSTOMIZED) { |
| 402 gfx::ImageSkia custom_wallpaper; | 402 if (!UserManager::Get()->IsUserLoggedIn()) { |
| 403 if (GetCustomWallpaperFromCache(email, &custom_wallpaper)) { | 403 index = ash::GetDefaultWallpaperIndex(); |
|
Ivan Korotkov
2012/08/16 15:45:01
Why is GetCustomWallpaperFromCache not needed anym
bshe
2012/08/16 22:32:49
If we cache (load from file and decode it) the cus
|
Ivan Korotkov
2012/08/16 15:45:01
Please comment on the purpose of this.
bshe
2012/08/16 22:32:49
Done
On 2012/08/16 15:45:01, Ivan Korotkov wrote:
|
| 404 // In customized mode, we use index pref to save the user selected | |
| 405 // wallpaper layout. See function SaveWallpaperToLocalState(). | |
| 406 ash::WallpaperLayout layout = static_cast<ash::WallpaperLayout>(index); | |
| 407 ash::Shell::GetInstance()->desktop_background_controller()-> | |
| 408 SetCustomWallpaper(custom_wallpaper, layout); | |
| 409 } else { | 404 } else { |
| 410 FetchCustomWallpaper(email); | 405 FetchCustomWallpaper(email); |
| 406 return; | |
| 411 } | 407 } |
| 412 return; | |
| 413 } | 408 } |
| 414 ash::Shell::GetInstance()->desktop_background_controller()-> | 409 ash::Shell::GetInstance()->desktop_background_controller()-> |
| 415 SetDefaultWallpaper(index, false); | 410 SetDefaultWallpaper(index, false); |
| 416 SetLastSelectedUser(email); | 411 SetLastSelectedUser(email); |
| 417 } | 412 } |
| 418 | 413 |
| 419 void WallpaperManager::SetWallpaperFromImageSkia( | 414 void WallpaperManager::SetWallpaperFromImageSkia( |
| 420 const gfx::ImageSkia& wallpaper, | 415 const gfx::ImageSkia& wallpaper, |
| 421 ash::WallpaperLayout layout) { | 416 ash::WallpaperLayout layout) { |
| 422 ash::Shell::GetInstance()->desktop_background_controller()-> | 417 ash::Shell::GetInstance()->desktop_background_controller()-> |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 483 } | 478 } |
| 484 } | 479 } |
| 485 } | 480 } |
| 486 | 481 |
| 487 void WallpaperManager::CacheUserWallpaper(const std::string& email) { | 482 void WallpaperManager::CacheUserWallpaper(const std::string& email) { |
| 488 User::WallpaperType type; | 483 User::WallpaperType type; |
| 489 int index; | 484 int index; |
| 490 base::Time date; | 485 base::Time date; |
| 491 GetUserWallpaperProperties(email, &type, &index, &date); | 486 GetUserWallpaperProperties(email, &type, &index, &date); |
| 492 if (type == User::CUSTOMIZED) { | 487 if (type == User::CUSTOMIZED) { |
| 493 std::string wallpaper_path = GetWallpaperPathForUser(email, false).value(); | 488 ash::Shell::GetInstance()->desktop_background_controller()-> |
| 494 | 489 CacheDefaultWallpaper(ash::GetDefaultWallpaperIndex()); |
| 495 // Uses WeakPtr here to make the request cancelable. | |
| 496 wallpaper_loader_->Start(wallpaper_path, 0, | |
| 497 base::Bind(&WallpaperManager::CacheWallpaper, | |
| 498 weak_factory_.GetWeakPtr(), email)); | |
| 499 } else { | 490 } else { |
| 500 ash::Shell::GetInstance()->desktop_background_controller()-> | 491 ash::Shell::GetInstance()->desktop_background_controller()-> |
| 501 CacheDefaultWallpaper(index); | 492 CacheDefaultWallpaper(index); |
| 502 } | 493 } |
| 503 } | 494 } |
| 504 | 495 |
| 505 void WallpaperManager::CacheWallpaper(const std::string& email, | 496 void WallpaperManager::CacheWallpaper(const std::string& email, |
| 506 const UserImage& wallpaper) { | 497 const UserImage& wallpaper) { |
| 507 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 498 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 508 DCHECK(custom_wallpaper_cache_.find(email) == custom_wallpaper_cache_.end()); | 499 DCHECK(custom_wallpaper_cache_.find(email) == custom_wallpaper_cache_.end()); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 650 | 641 |
| 651 void WallpaperManager::SystemResumed() { | 642 void WallpaperManager::SystemResumed() { |
| 652 BatchUpdateWallpaper(); | 643 BatchUpdateWallpaper(); |
| 653 } | 644 } |
| 654 | 645 |
| 655 void WallpaperManager::TimezoneChanged(const icu::TimeZone& timezone) { | 646 void WallpaperManager::TimezoneChanged(const icu::TimeZone& timezone) { |
| 656 RestartTimer(); | 647 RestartTimer(); |
| 657 } | 648 } |
| 658 | 649 |
| 659 } // chromeos | 650 } // chromeos |
| OLD | NEW |