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 // For security reason, use default wallpaper instead of custom wallpaper |
403 if (GetCustomWallpaperFromCache(email, &custom_wallpaper)) { | 403 // at login screen. The security issue is tracked in issue 143198. Once it |
404 // In customized mode, we use index pref to save the user selected | 404 // fixed, we should then only use custom wallpaper. |
405 // wallpaper layout. See function SaveWallpaperToLocalState(). | 405 if (!UserManager::Get()->IsUserLoggedIn()) { |
406 ash::WallpaperLayout layout = static_cast<ash::WallpaperLayout>(index); | 406 index = ash::GetDefaultWallpaperIndex(); |
407 ash::Shell::GetInstance()->desktop_background_controller()-> | |
408 SetCustomWallpaper(custom_wallpaper, layout); | |
409 } else { | 407 } else { |
410 FetchCustomWallpaper(email); | 408 FetchCustomWallpaper(email); |
| 409 return; |
411 } | 410 } |
412 return; | |
413 } | 411 } |
414 ash::Shell::GetInstance()->desktop_background_controller()-> | 412 ash::Shell::GetInstance()->desktop_background_controller()-> |
415 SetDefaultWallpaper(index, false); | 413 SetDefaultWallpaper(index, false); |
416 SetLastSelectedUser(email); | 414 SetLastSelectedUser(email); |
417 } | 415 } |
418 | 416 |
419 void WallpaperManager::SetWallpaperFromImageSkia( | 417 void WallpaperManager::SetWallpaperFromImageSkia( |
420 const gfx::ImageSkia& wallpaper, | 418 const gfx::ImageSkia& wallpaper, |
421 ash::WallpaperLayout layout) { | 419 ash::WallpaperLayout layout) { |
422 ash::Shell::GetInstance()->desktop_background_controller()-> | 420 ash::Shell::GetInstance()->desktop_background_controller()-> |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 } | 481 } |
484 } | 482 } |
485 } | 483 } |
486 | 484 |
487 void WallpaperManager::CacheUserWallpaper(const std::string& email) { | 485 void WallpaperManager::CacheUserWallpaper(const std::string& email) { |
488 User::WallpaperType type; | 486 User::WallpaperType type; |
489 int index; | 487 int index; |
490 base::Time date; | 488 base::Time date; |
491 GetUserWallpaperProperties(email, &type, &index, &date); | 489 GetUserWallpaperProperties(email, &type, &index, &date); |
492 if (type == User::CUSTOMIZED) { | 490 if (type == User::CUSTOMIZED) { |
493 std::string wallpaper_path = GetWallpaperPathForUser(email, false).value(); | 491 ash::Shell::GetInstance()->desktop_background_controller()-> |
494 | 492 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 { | 493 } else { |
500 ash::Shell::GetInstance()->desktop_background_controller()-> | 494 ash::Shell::GetInstance()->desktop_background_controller()-> |
501 CacheDefaultWallpaper(index); | 495 CacheDefaultWallpaper(index); |
502 } | 496 } |
503 } | 497 } |
504 | 498 |
505 void WallpaperManager::CacheWallpaper(const std::string& email, | 499 void WallpaperManager::CacheWallpaper(const std::string& email, |
506 const UserImage& wallpaper) { | 500 const UserImage& wallpaper) { |
507 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 501 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
508 DCHECK(custom_wallpaper_cache_.find(email) == custom_wallpaper_cache_.end()); | 502 DCHECK(custom_wallpaper_cache_.find(email) == custom_wallpaper_cache_.end()); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 | 644 |
651 void WallpaperManager::SystemResumed() { | 645 void WallpaperManager::SystemResumed() { |
652 BatchUpdateWallpaper(); | 646 BatchUpdateWallpaper(); |
653 } | 647 } |
654 | 648 |
655 void WallpaperManager::TimezoneChanged(const icu::TimeZone& timezone) { | 649 void WallpaperManager::TimezoneChanged(const icu::TimeZone& timezone) { |
656 RestartTimer(); | 650 RestartTimer(); |
657 } | 651 } |
658 | 652 |
659 } // chromeos | 653 } // chromeos |
OLD | NEW |