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 = user_manager::UserManager::Get()->FindUser( | 481 const user_manager::User* user = |
482 AccountId::FromUserEmail(user_id)); | 482 user_manager::UserManager::Get()->FindUser(user_id); |
483 CHECK(user); | 483 CHECK(user); |
484 const bool is_persistent = | 484 bool is_persistent = |
485 !user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral( | 485 !user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral( |
486 AccountId::FromUserEmail(user_id)) || | 486 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 = user_manager::UserManager::Get()->FindUser( | 559 const user_manager::User* user = |
560 AccountId::FromUserEmail(user_id)); | 560 user_manager::UserManager::Get()->FindUser(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); | |
628 const user_manager::User* user = | 627 const user_manager::User* user = |
629 user_manager::UserManager::Get()->FindUser(account_id); | 628 user_manager::UserManager::Get()->FindUser(user_id); |
630 | 629 |
631 // User is unknown or there is no visible background in kiosk mode. | 630 // User is unknown or there is no visible background in kiosk mode. |
632 if (!user || user->GetType() == user_manager::USER_TYPE_KIOSK_APP) | 631 if (!user || user->GetType() == user_manager::USER_TYPE_KIOSK_APP) |
633 return; | 632 return; |
634 | 633 |
635 // Guest user or regular user in ephemeral mode. | 634 // Guest user or regular user in ephemeral mode. |
636 if ((user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral( | 635 if ((user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral( |
637 account_id) && | 636 user_id) && |
638 user->HasGaiaAccount()) || | 637 user->HasGaiaAccount()) || |
639 user->GetType() == user_manager::USER_TYPE_GUEST) { | 638 user->GetType() == user_manager::USER_TYPE_GUEST) { |
640 InitInitialUserWallpaper(user_id, false); | 639 InitInitialUserWallpaper(user_id, false); |
641 GetPendingWallpaper(user_id, delayed)->ResetSetDefaultWallpaper(); | 640 GetPendingWallpaper(user_id, delayed)->ResetSetDefaultWallpaper(); |
642 return; | 641 return; |
643 } | 642 } |
644 | 643 |
645 last_selected_user_ = user_id; | 644 last_selected_user_ = user_id; |
646 | 645 |
647 WallpaperInfo info; | 646 WallpaperInfo info; |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 // asynchronously once user pods are loaded. | 803 // asynchronously once user pods are loaded. |
805 SetUserWallpaperDelayed(users[index]->email()); | 804 SetUserWallpaperDelayed(users[index]->email()); |
806 } | 805 } |
807 } | 806 } |
808 | 807 |
809 bool WallpaperManager::GetUserWallpaperInfo(const std::string& user_id, | 808 bool WallpaperManager::GetUserWallpaperInfo(const std::string& user_id, |
810 WallpaperInfo* info) const { | 809 WallpaperInfo* info) const { |
811 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 810 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
812 | 811 |
813 if (user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral( | 812 if (user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral( |
814 AccountId::FromUserEmail(user_id))) { | 813 user_id)) { |
815 // Default to the values cached in memory. | 814 // Default to the values cached in memory. |
816 *info = current_user_wallpaper_info_; | 815 *info = current_user_wallpaper_info_; |
817 | 816 |
818 // Ephemeral users do not save anything to local state. But we have got | 817 // Ephemeral users do not save anything to local state. But we have got |
819 // wallpaper info from memory. Returns true. | 818 // wallpaper info from memory. Returns true. |
820 return true; | 819 return true; |
821 } | 820 } |
822 | 821 |
823 const base::DictionaryValue* info_dict; | 822 const base::DictionaryValue* info_dict; |
824 if (!g_browser_process->local_state() | 823 if (!g_browser_process->local_state() |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1033 } | 1032 } |
1034 } | 1033 } |
1035 | 1034 |
1036 if (need_update_screen) { | 1035 if (need_update_screen) { |
1037 DoSetDefaultWallpaper(std::string(), | 1036 DoSetDefaultWallpaper(std::string(), |
1038 MovableOnDestroyCallbackHolder().Pass()); | 1037 MovableOnDestroyCallbackHolder().Pass()); |
1039 } | 1038 } |
1040 } | 1039 } |
1041 | 1040 |
1042 } // namespace chromeos | 1041 } // namespace chromeos |
OLD | NEW |