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 24 matching lines...) Expand all Loading... | |
35 #include "chrome/browser/chromeos/login/startup_utils.h" | 35 #include "chrome/browser/chromeos/login/startup_utils.h" |
36 #include "chrome/browser/chromeos/login/wizard_controller.h" | 36 #include "chrome/browser/chromeos/login/wizard_controller.h" |
37 #include "chrome/browser/chromeos/settings/cros_settings.h" | 37 #include "chrome/browser/chromeos/settings/cros_settings.h" |
38 #include "chrome/common/chrome_paths.h" | 38 #include "chrome/common/chrome_paths.h" |
39 #include "chrome/common/chrome_switches.h" | 39 #include "chrome/common/chrome_switches.h" |
40 #include "chrome/common/pref_names.h" | 40 #include "chrome/common/pref_names.h" |
41 #include "chromeos/chromeos_switches.h" | 41 #include "chromeos/chromeos_switches.h" |
42 #include "chromeos/cryptohome/async_method_caller.h" | 42 #include "chromeos/cryptohome/async_method_caller.h" |
43 #include "chromeos/dbus/dbus_thread_manager.h" | 43 #include "chromeos/dbus/dbus_thread_manager.h" |
44 #include "chromeos/login/user_names.h" | 44 #include "chromeos/login/user_names.h" |
45 #include "components/signin/core/account_id/account_id.h" | |
45 #include "components/user_manager/user.h" | 46 #include "components/user_manager/user.h" |
46 #include "components/user_manager/user_image/user_image.h" | 47 #include "components/user_manager/user_image/user_image.h" |
47 #include "components/user_manager/user_manager.h" | 48 #include "components/user_manager/user_manager.h" |
48 #include "components/user_manager/user_type.h" | 49 #include "components/user_manager/user_type.h" |
49 #include "components/wallpaper/wallpaper_layout.h" | 50 #include "components/wallpaper/wallpaper_layout.h" |
50 #include "content/public/browser/browser_thread.h" | 51 #include "content/public/browser/browser_thread.h" |
51 #include "content/public/browser/notification_service.h" | 52 #include "content/public/browser/notification_service.h" |
52 #include "content/public/common/content_switches.h" | 53 #include "content/public/common/content_switches.h" |
53 #include "third_party/skia/include/core/SkColor.h" | 54 #include "third_party/skia/include/core/SkColor.h" |
54 #include "ui/gfx/codec/jpeg_codec.h" | 55 #include "ui/gfx/codec/jpeg_codec.h" |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
470 base::FilePath wallpaper_path = GetCustomWallpaperPath( | 471 base::FilePath wallpaper_path = GetCustomWallpaperPath( |
471 wallpaper::kOriginalWallpaperSubDir, user_id_hash, file); | 472 wallpaper::kOriginalWallpaperSubDir, user_id_hash, file); |
472 | 473 |
473 // 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. |
474 // Use default wallpaper in this case. | 475 // Use default wallpaper in this case. |
475 if (image.isNull()) { | 476 if (image.isNull()) { |
476 SetDefaultWallpaperDelayed(user_id); | 477 SetDefaultWallpaperDelayed(user_id); |
477 return; | 478 return; |
478 } | 479 } |
479 | 480 |
480 const user_manager::User* user = | 481 const user_manager::User* user = user_manager::UserManager::Get()->FindUser( |
481 user_manager::UserManager::Get()->FindUser(user_id); | 482 AccountId::FromUserEmail(user_id)); |
482 CHECK(user); | 483 CHECK(user); |
483 bool is_persistent = | 484 bool is_persistent = |
achuithb
2015/10/28 23:11:46
const
Alexander Alekseev
2015/10/29 02:00:41
Done.
| |
484 !user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral( | 485 !user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral( |
485 user_id) || | 486 AccountId::FromUserEmail(user_id)) || |
486 (type == user_manager::User::POLICY && | 487 (type == user_manager::User::POLICY && |
487 user->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT); | 488 user->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT); |
488 | 489 |
489 WallpaperInfo wallpaper_info = { | 490 WallpaperInfo wallpaper_info = { |
490 wallpaper_path.value(), | 491 wallpaper_path.value(), |
491 layout, | 492 layout, |
492 type, | 493 type, |
493 // Date field is not used. | 494 // Date field is not used. |
494 base::Time::Now().LocalMidnight() | 495 base::Time::Now().LocalMidnight() |
495 }; | 496 }; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
548 // in these tests anyway, avoid loading one, preventing crashes and speeding | 549 // in these tests anyway, avoid loading one, preventing crashes and speeding |
549 // up the tests. | 550 // up the tests. |
550 if (!ash::Shell::HasInstance()) | 551 if (!ash::Shell::HasInstance()) |
551 return; | 552 return; |
552 | 553 |
553 WallpaperResolution resolution = GetAppropriateResolution(); | 554 WallpaperResolution resolution = GetAppropriateResolution(); |
554 const bool use_small = (resolution == WALLPAPER_RESOLUTION_SMALL); | 555 const bool use_small = (resolution == WALLPAPER_RESOLUTION_SMALL); |
555 | 556 |
556 const base::FilePath* file = NULL; | 557 const base::FilePath* file = NULL; |
557 | 558 |
558 const user_manager::User* user = | 559 const user_manager::User* user = user_manager::UserManager::Get()->FindUser( |
559 user_manager::UserManager::Get()->FindUser(user_id); | 560 AccountId::FromUserEmail(user_id)); |
560 | 561 |
561 if (user_manager::UserManager::Get()->IsLoggedInAsGuest()) { | 562 if (user_manager::UserManager::Get()->IsLoggedInAsGuest()) { |
562 file = | 563 file = |
563 use_small ? &guest_small_wallpaper_file_ : &guest_large_wallpaper_file_; | 564 use_small ? &guest_small_wallpaper_file_ : &guest_large_wallpaper_file_; |
564 } else if (user && user->GetType() == user_manager::USER_TYPE_CHILD) { | 565 } else if (user && user->GetType() == user_manager::USER_TYPE_CHILD) { |
565 file = | 566 file = |
566 use_small ? &child_small_wallpaper_file_ : &child_large_wallpaper_file_; | 567 use_small ? &child_small_wallpaper_file_ : &child_large_wallpaper_file_; |
567 } else { | 568 } else { |
568 file = use_small ? &default_small_wallpaper_file_ | 569 file = use_small ? &default_small_wallpaper_file_ |
569 : &default_large_wallpaper_file_; | 570 : &default_large_wallpaper_file_; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
616 | 617 |
617 void WallpaperManager::ScheduleSetUserWallpaper(const std::string& user_id, | 618 void WallpaperManager::ScheduleSetUserWallpaper(const std::string& user_id, |
618 bool delayed) { | 619 bool delayed) { |
619 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 620 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
620 // 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 |
621 if (!user_manager::UserManager::IsInitialized() || | 622 if (!user_manager::UserManager::IsInitialized() || |
622 !g_browser_process->local_state()) { | 623 !g_browser_process->local_state()) { |
623 return; | 624 return; |
624 } | 625 } |
625 | 626 |
627 const AccountId account_id = AccountId::FromUserEmail(user_id); | |
626 const user_manager::User* user = | 628 const user_manager::User* user = |
627 user_manager::UserManager::Get()->FindUser(user_id); | 629 user_manager::UserManager::Get()->FindUser(account_id); |
628 | 630 |
629 // 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. |
630 if (!user || user->GetType() == user_manager::USER_TYPE_KIOSK_APP) | 632 if (!user || user->GetType() == user_manager::USER_TYPE_KIOSK_APP) |
631 return; | 633 return; |
632 | 634 |
633 // Guest user or regular user in ephemeral mode. | 635 // Guest user or regular user in ephemeral mode. |
634 if ((user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral( | 636 if ((user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral( |
635 user_id) && | 637 account_id) && |
636 user->HasGaiaAccount()) || | 638 user->HasGaiaAccount()) || |
637 user->GetType() == user_manager::USER_TYPE_GUEST) { | 639 user->GetType() == user_manager::USER_TYPE_GUEST) { |
638 InitInitialUserWallpaper(user_id, false); | 640 InitInitialUserWallpaper(user_id, false); |
639 GetPendingWallpaper(user_id, delayed)->ResetSetDefaultWallpaper(); | 641 GetPendingWallpaper(user_id, delayed)->ResetSetDefaultWallpaper(); |
640 return; | 642 return; |
641 } | 643 } |
642 | 644 |
643 last_selected_user_ = user_id; | 645 last_selected_user_ = user_id; |
644 | 646 |
645 WallpaperInfo info; | 647 WallpaperInfo info; |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
802 // asynchronously once user pods are loaded. | 804 // asynchronously once user pods are loaded. |
803 SetUserWallpaperDelayed(users[index]->email()); | 805 SetUserWallpaperDelayed(users[index]->email()); |
804 } | 806 } |
805 } | 807 } |
806 | 808 |
807 bool WallpaperManager::GetUserWallpaperInfo(const std::string& user_id, | 809 bool WallpaperManager::GetUserWallpaperInfo(const std::string& user_id, |
808 WallpaperInfo* info) const { | 810 WallpaperInfo* info) const { |
809 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 811 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
810 | 812 |
811 if (user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral( | 813 if (user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral( |
812 user_id)) { | 814 AccountId::FromUserEmail(user_id))) { |
813 // Default to the values cached in memory. | 815 // Default to the values cached in memory. |
814 *info = current_user_wallpaper_info_; | 816 *info = current_user_wallpaper_info_; |
815 | 817 |
816 // 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 |
817 // wallpaper info from memory. Returns true. | 819 // wallpaper info from memory. Returns true. |
818 return true; | 820 return true; |
819 } | 821 } |
820 | 822 |
821 const base::DictionaryValue* info_dict; | 823 const base::DictionaryValue* info_dict; |
822 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... | |
1031 } | 1033 } |
1032 } | 1034 } |
1033 | 1035 |
1034 if (need_update_screen) { | 1036 if (need_update_screen) { |
1035 DoSetDefaultWallpaper(std::string(), | 1037 DoSetDefaultWallpaper(std::string(), |
1036 MovableOnDestroyCallbackHolder().Pass()); | 1038 MovableOnDestroyCallbackHolder().Pass()); |
1037 } | 1039 } |
1038 } | 1040 } |
1039 | 1041 |
1040 } // namespace chromeos | 1042 } // namespace chromeos |
OLD | NEW |