| 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 <numeric> | 7 #include <numeric> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ash/ash_constants.h" | 10 #include "ash/ash_constants.h" |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 base::FilePath wallpaper_path = GetCustomWallpaperPath( | 471 base::FilePath wallpaper_path = GetCustomWallpaperPath( |
| 472 wallpaper::kOriginalWallpaperSubDir, user_id_hash, file); | 472 wallpaper::kOriginalWallpaperSubDir, user_id_hash, file); |
| 473 | 473 |
| 474 // If decoded wallpaper is empty, we have probably failed to decode the file. | 474 // If decoded wallpaper is empty, we have probably failed to decode the file. |
| 475 // Use default wallpaper in this case. | 475 // Use default wallpaper in this case. |
| 476 if (image.isNull()) { | 476 if (image.isNull()) { |
| 477 SetDefaultWallpaperDelayed(user_id); | 477 SetDefaultWallpaperDelayed(user_id); |
| 478 return; | 478 return; |
| 479 } | 479 } |
| 480 | 480 |
| 481 const user_manager::User* user = | 481 const user_manager::User* user = user_manager::UserManager::Get()->FindUser( |
| 482 user_manager::UserManager::Get()->FindUser(user_id); | 482 AccountId::FromUserEmail(user_id)); |
| 483 CHECK(user); | 483 CHECK(user); |
| 484 bool is_persistent = | 484 const bool is_persistent = |
| 485 !user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral( | 485 !user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral( |
| 486 user_id) || | 486 AccountId::FromUserEmail(user_id)) || |
| 487 (type == user_manager::User::POLICY && | 487 (type == user_manager::User::POLICY && |
| 488 user->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT); | 488 user->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT); |
| 489 | 489 |
| 490 WallpaperInfo wallpaper_info = { | 490 WallpaperInfo wallpaper_info = { |
| 491 wallpaper_path.value(), | 491 wallpaper_path.value(), |
| 492 layout, | 492 layout, |
| 493 type, | 493 type, |
| 494 // Date field is not used. | 494 // Date field is not used. |
| 495 base::Time::Now().LocalMidnight() | 495 base::Time::Now().LocalMidnight() |
| 496 }; | 496 }; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 // in these tests anyway, avoid loading one, preventing crashes and speeding | 549 // in these tests anyway, avoid loading one, preventing crashes and speeding |
| 550 // up the tests. | 550 // up the tests. |
| 551 if (!ash::Shell::HasInstance()) | 551 if (!ash::Shell::HasInstance()) |
| 552 return; | 552 return; |
| 553 | 553 |
| 554 WallpaperResolution resolution = GetAppropriateResolution(); | 554 WallpaperResolution resolution = GetAppropriateResolution(); |
| 555 const bool use_small = (resolution == WALLPAPER_RESOLUTION_SMALL); | 555 const bool use_small = (resolution == WALLPAPER_RESOLUTION_SMALL); |
| 556 | 556 |
| 557 const base::FilePath* file = NULL; | 557 const base::FilePath* file = NULL; |
| 558 | 558 |
| 559 const user_manager::User* user = | 559 const user_manager::User* user = user_manager::UserManager::Get()->FindUser( |
| 560 user_manager::UserManager::Get()->FindUser(user_id); | 560 AccountId::FromUserEmail(user_id)); |
| 561 | 561 |
| 562 if (user_manager::UserManager::Get()->IsLoggedInAsGuest()) { | 562 if (user_manager::UserManager::Get()->IsLoggedInAsGuest()) { |
| 563 file = | 563 file = |
| 564 use_small ? &guest_small_wallpaper_file_ : &guest_large_wallpaper_file_; | 564 use_small ? &guest_small_wallpaper_file_ : &guest_large_wallpaper_file_; |
| 565 } else if (user && user->GetType() == user_manager::USER_TYPE_CHILD) { | 565 } else if (user && user->GetType() == user_manager::USER_TYPE_CHILD) { |
| 566 file = | 566 file = |
| 567 use_small ? &child_small_wallpaper_file_ : &child_large_wallpaper_file_; | 567 use_small ? &child_small_wallpaper_file_ : &child_large_wallpaper_file_; |
| 568 } else { | 568 } else { |
| 569 file = use_small ? &default_small_wallpaper_file_ | 569 file = use_small ? &default_small_wallpaper_file_ |
| 570 : &default_large_wallpaper_file_; | 570 : &default_large_wallpaper_file_; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 | 617 |
| 618 void WallpaperManager::ScheduleSetUserWallpaper(const std::string& user_id, | 618 void WallpaperManager::ScheduleSetUserWallpaper(const std::string& user_id, |
| 619 bool delayed) { | 619 bool delayed) { |
| 620 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 620 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 621 // Some unit tests come here without a UserManager or without a pref system.q | 621 // Some unit tests come here without a UserManager or without a pref system.q |
| 622 if (!user_manager::UserManager::IsInitialized() || | 622 if (!user_manager::UserManager::IsInitialized() || |
| 623 !g_browser_process->local_state()) { | 623 !g_browser_process->local_state()) { |
| 624 return; | 624 return; |
| 625 } | 625 } |
| 626 | 626 |
| 627 const AccountId account_id = AccountId::FromUserEmail(user_id); |
| 627 const user_manager::User* user = | 628 const user_manager::User* user = |
| 628 user_manager::UserManager::Get()->FindUser(user_id); | 629 user_manager::UserManager::Get()->FindUser(account_id); |
| 629 | 630 |
| 630 // User is unknown or there is no visible background in kiosk mode. | 631 // User is unknown or there is no visible background in kiosk mode. |
| 631 if (!user || user->GetType() == user_manager::USER_TYPE_KIOSK_APP) | 632 if (!user || user->GetType() == user_manager::USER_TYPE_KIOSK_APP) |
| 632 return; | 633 return; |
| 633 | 634 |
| 634 // Guest user or regular user in ephemeral mode. | 635 // Guest user or regular user in ephemeral mode. |
| 635 if ((user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral( | 636 if ((user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral( |
| 636 user_id) && | 637 account_id) && |
| 637 user->HasGaiaAccount()) || | 638 user->HasGaiaAccount()) || |
| 638 user->GetType() == user_manager::USER_TYPE_GUEST) { | 639 user->GetType() == user_manager::USER_TYPE_GUEST) { |
| 639 InitInitialUserWallpaper(user_id, false); | 640 InitInitialUserWallpaper(user_id, false); |
| 640 GetPendingWallpaper(user_id, delayed)->ResetSetDefaultWallpaper(); | 641 GetPendingWallpaper(user_id, delayed)->ResetSetDefaultWallpaper(); |
| 641 return; | 642 return; |
| 642 } | 643 } |
| 643 | 644 |
| 644 last_selected_user_ = user_id; | 645 last_selected_user_ = user_id; |
| 645 | 646 |
| 646 WallpaperInfo info; | 647 WallpaperInfo info; |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 // asynchronously once user pods are loaded. | 804 // asynchronously once user pods are loaded. |
| 804 SetUserWallpaperDelayed(users[index]->email()); | 805 SetUserWallpaperDelayed(users[index]->email()); |
| 805 } | 806 } |
| 806 } | 807 } |
| 807 | 808 |
| 808 bool WallpaperManager::GetUserWallpaperInfo(const std::string& user_id, | 809 bool WallpaperManager::GetUserWallpaperInfo(const std::string& user_id, |
| 809 WallpaperInfo* info) const { | 810 WallpaperInfo* info) const { |
| 810 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 811 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 811 | 812 |
| 812 if (user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral( | 813 if (user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral( |
| 813 user_id)) { | 814 AccountId::FromUserEmail(user_id))) { |
| 814 // Default to the values cached in memory. | 815 // Default to the values cached in memory. |
| 815 *info = current_user_wallpaper_info_; | 816 *info = current_user_wallpaper_info_; |
| 816 | 817 |
| 817 // Ephemeral users do not save anything to local state. But we have got | 818 // Ephemeral users do not save anything to local state. But we have got |
| 818 // wallpaper info from memory. Returns true. | 819 // wallpaper info from memory. Returns true. |
| 819 return true; | 820 return true; |
| 820 } | 821 } |
| 821 | 822 |
| 822 const base::DictionaryValue* info_dict; | 823 const base::DictionaryValue* info_dict; |
| 823 if (!g_browser_process->local_state() | 824 if (!g_browser_process->local_state() |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1032 } | 1033 } |
| 1033 } | 1034 } |
| 1034 | 1035 |
| 1035 if (need_update_screen) { | 1036 if (need_update_screen) { |
| 1036 DoSetDefaultWallpaper(std::string(), | 1037 DoSetDefaultWallpaper(std::string(), |
| 1037 MovableOnDestroyCallbackHolder().Pass()); | 1038 MovableOnDestroyCallbackHolder().Pass()); |
| 1038 } | 1039 } |
| 1039 } | 1040 } |
| 1040 | 1041 |
| 1041 } // namespace chromeos | 1042 } // namespace chromeos |
| OLD | NEW |