| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 // Zero delays is also set in autotests. | 209 // Zero delays is also set in autotests. |
| 210 if (WizardController::IsZeroDelayEnabled()) { | 210 if (WizardController::IsZeroDelayEnabled()) { |
| 211 // Ensure tests have some sort of wallpaper. | 211 // Ensure tests have some sort of wallpaper. |
| 212 ash::Shell::GetInstance()->desktop_background_controller()-> | 212 ash::Shell::GetInstance()->desktop_background_controller()-> |
| 213 CreateEmptyWallpaper(); | 213 CreateEmptyWallpaper(); |
| 214 return; | 214 return; |
| 215 } | 215 } |
| 216 | 216 |
| 217 bool disable_new_oobe = CommandLine::ForCurrentProcess()-> | 217 bool disable_new_oobe = CommandLine::ForCurrentProcess()-> |
| 218 HasSwitch(switches::kDisableNewOobe); | 218 HasSwitch(switches::kDisableNewOobe); |
| 219 bool disable_boot_animation = CommandLine::ForCurrentProcess()-> | |
| 220 HasSwitch(switches::kDisableBootAnimation); | |
| 221 | 219 |
| 222 if (!user_manager->IsUserLoggedIn()) { | 220 if (!user_manager->IsUserLoggedIn()) { |
| 223 if (!disable_new_oobe) { | 221 if (!disable_new_oobe) { |
| 224 if (!WizardController::IsDeviceRegistered()) { | 222 if (!WizardController::IsDeviceRegistered()) { |
| 225 SetDefaultWallpaper(); | 223 SetDefaultWallpaper(); |
| 226 } else { | 224 } else { |
| 227 bool show_users = true; | 225 InitializeRegisteredDeviceWallpaper(); |
| 228 bool result = CrosSettings::Get()->GetBoolean( | |
| 229 kAccountsPrefShowUserNamesOnSignIn, &show_users); | |
| 230 DCHECK(result) << "Unable to fetch setting " | |
| 231 << kAccountsPrefShowUserNamesOnSignIn; | |
| 232 const chromeos::UserList& users = user_manager->GetUsers(); | |
| 233 if (!show_users || users.empty()) { | |
| 234 // Boot into sign in form, preload default wallpaper. | |
| 235 SetDefaultWallpaper(); | |
| 236 return; | |
| 237 } | |
| 238 | |
| 239 if (!disable_boot_animation) { | |
| 240 // Normal boot, load user wallpaper. | |
| 241 // If normal boot animation is disabled wallpaper would be set | |
| 242 // asynchronously once user pods are loaded. | |
| 243 SetUserWallpaper(users[0]->email()); | |
| 244 } | |
| 245 } | 226 } |
| 246 } | 227 } |
| 247 return; | 228 return; |
| 248 } | 229 } |
| 249 SetUserWallpaper(user_manager->GetLoggedInUser()->email()); | 230 SetUserWallpaper(user_manager->GetLoggedInUser()->email()); |
| 250 } | 231 } |
| 251 | 232 |
| 252 void WallpaperManager::Observe(int type, | 233 void WallpaperManager::Observe(int type, |
| 253 const content::NotificationSource& source, | 234 const content::NotificationSource& source, |
| 254 const content::NotificationDetails& details) { | 235 const content::NotificationDetails& details) { |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 file_to_remove.push_back(wallpaper_path); | 634 file_to_remove.push_back(wallpaper_path); |
| 654 | 635 |
| 655 base::WorkerPool::PostTask( | 636 base::WorkerPool::PostTask( |
| 656 FROM_HERE, | 637 FROM_HERE, |
| 657 base::Bind(&WallpaperManager::DeleteWallpaperInList, | 638 base::Bind(&WallpaperManager::DeleteWallpaperInList, |
| 658 base::Unretained(this), | 639 base::Unretained(this), |
| 659 file_to_remove), | 640 file_to_remove), |
| 660 false); | 641 false); |
| 661 } | 642 } |
| 662 | 643 |
| 644 void WallpaperManager::InitializeRegisteredDeviceWallpaper() { |
| 645 if (CrosSettingsProvider::TEMPORARILY_UNTRUSTED == |
| 646 CrosSettings::Get()->PrepareTrustedValues( |
| 647 base::Bind(&WallpaperManager::InitializeRegisteredDeviceWallpaper, |
| 648 base::Unretained(this)))) { |
| 649 return; |
| 650 } |
| 651 bool disable_boot_animation = CommandLine::ForCurrentProcess()-> |
| 652 HasSwitch(switches::kDisableBootAnimation); |
| 653 bool show_users = true; |
| 654 bool result = CrosSettings::Get()->GetBoolean( |
| 655 kAccountsPrefShowUserNamesOnSignIn, &show_users); |
| 656 DCHECK(result) << "Unable to fetch setting " |
| 657 << kAccountsPrefShowUserNamesOnSignIn; |
| 658 const chromeos::UserList& users = UserManager::Get()->GetUsers(); |
| 659 if (!show_users || users.empty()) { |
| 660 // Boot into sign in form, preload default wallpaper. |
| 661 SetDefaultWallpaper(); |
| 662 return; |
| 663 } |
| 664 |
| 665 if (!disable_boot_animation) { |
| 666 // Normal boot, load user wallpaper. |
| 667 // If normal boot animation is disabled wallpaper would be set |
| 668 // asynchronously once user pods are loaded. |
| 669 SetUserWallpaper(users[0]->email()); |
| 670 } |
| 671 } |
| 672 |
| 663 void WallpaperManager::LoadWallpaper(const std::string& email, | 673 void WallpaperManager::LoadWallpaper(const std::string& email, |
| 664 const WallpaperInfo& info, | 674 const WallpaperInfo& info, |
| 665 bool update_wallpaper) { | 675 bool update_wallpaper) { |
| 666 FilePath wallpaper_dir; | 676 FilePath wallpaper_dir; |
| 667 FilePath wallpaper_path; | 677 FilePath wallpaper_path; |
| 668 if (info.type == User::ONLINE) { | 678 if (info.type == User::ONLINE) { |
| 669 std::string file_name = GURL(info.file).ExtractFileName(); | 679 std::string file_name = GURL(info.file).ExtractFileName(); |
| 670 ash::WallpaperResolution resolution = ash::Shell::GetInstance()-> | 680 ash::WallpaperResolution resolution = ash::Shell::GetInstance()-> |
| 671 desktop_background_controller()->GetAppropriateResolution(); | 681 desktop_background_controller()->GetAppropriateResolution(); |
| 672 // Only solid color wallpapers have stretch layout and they have only one | 682 // Only solid color wallpapers have stretch layout and they have only one |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 FROM_HERE, | 915 FROM_HERE, |
| 906 base::Bind(&WallpaperManager::StartLoad, | 916 base::Bind(&WallpaperManager::StartLoad, |
| 907 base::Unretained(this), | 917 base::Unretained(this), |
| 908 email, | 918 email, |
| 909 info, | 919 info, |
| 910 update_wallpaper, | 920 update_wallpaper, |
| 911 valid_path)); | 921 valid_path)); |
| 912 } | 922 } |
| 913 | 923 |
| 914 } // chromeos | 924 } // chromeos |
| OLD | NEW |