| 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/user_manager_impl.h" | 5 #include "chrome/browser/chromeos/login/user_manager_impl.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/desktop_background/desktop_background_controller.h" | 10 #include "ash/desktop_background/desktop_background_controller.h" |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 NotifyOnLogin(); | 351 NotifyOnLogin(); |
| 352 } | 352 } |
| 353 | 353 |
| 354 void UserManagerImpl::StubUserLoggedIn() { | 354 void UserManagerImpl::StubUserLoggedIn() { |
| 355 is_current_user_ephemeral_ = true; | 355 is_current_user_ephemeral_ = true; |
| 356 logged_in_user_ = new User(kStubUser, false); | 356 logged_in_user_ = new User(kStubUser, false); |
| 357 logged_in_user_->SetImage(GetDefaultImage(kStubDefaultImageIndex), | 357 logged_in_user_->SetImage(GetDefaultImage(kStubDefaultImageIndex), |
| 358 kStubDefaultImageIndex); | 358 kStubDefaultImageIndex); |
| 359 } | 359 } |
| 360 | 360 |
| 361 void UserManagerImpl::SetLoggedInUserWallpaper() { |
| 362 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 363 |
| 364 if (!IsUserLoggedIn() || IsLoggedInAsStub()) { |
| 365 ash::Shell::GetInstance()->desktop_background_controller()-> |
| 366 SetDefaultWallpaper(ash::GetInvalidWallpaperIndex()); |
| 367 return; |
| 368 } |
| 369 UserSelected(GetLoggedInUser().email()); |
| 370 } |
| 371 |
| 361 void UserManagerImpl::UserSelected(const std::string& email) { | 372 void UserManagerImpl::UserSelected(const std::string& email) { |
| 362 if (IsKnownUser(email)) { | 373 if (IsKnownUser(email)) { |
| 363 User::WallpaperType type; | 374 User::WallpaperType type; |
| 364 int index; | 375 int index; |
| 365 GetUserWallpaperProperties(email, &type, &index); | 376 GetUserWallpaperProperties(email, &type, &index); |
| 366 if (type == User::RANDOM) { | 377 if (type == User::RANDOM) { |
| 367 // Generate a new random wallpaper index if the selected user chose | 378 // Generate a new random wallpaper index if the selected user chose |
| 368 // RANDOM wallpaper. | 379 // RANDOM wallpaper. |
| 369 index = ash::GetRandomWallpaperIndex(); | 380 index = ash::GetRandomWallpaperIndex(); |
| 370 SaveUserWallpaperProperties(email, User::RANDOM, index); | 381 SaveUserWallpaperProperties(email, User::RANDOM, index); |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 DictionaryPrefUpdate prefs_wallpapers_update(local_state, | 957 DictionaryPrefUpdate prefs_wallpapers_update(local_state, |
| 947 kUserWallpapers); | 958 kUserWallpapers); |
| 948 prefs_wallpapers_update->RemoveWithoutPathExpansion(username, NULL); | 959 prefs_wallpapers_update->RemoveWithoutPathExpansion(username, NULL); |
| 949 SaveUserWallpaperProperties(username, User::DEFAULT, index); | 960 SaveUserWallpaperProperties(username, User::DEFAULT, index); |
| 950 } | 961 } |
| 951 } | 962 } |
| 952 } | 963 } |
| 953 } | 964 } |
| 954 } | 965 } |
| 955 | 966 |
| 956 int UserManagerImpl::GetLoggedInUserWallpaperIndex() { | |
| 957 User::WallpaperType type; | |
| 958 int index; | |
| 959 GetLoggedInUserWallpaperProperties(&type, &index); | |
| 960 return index; | |
| 961 } | |
| 962 | |
| 963 void UserManagerImpl::GetLoggedInUserWallpaperProperties( | 967 void UserManagerImpl::GetLoggedInUserWallpaperProperties( |
| 964 User::WallpaperType* type, | 968 User::WallpaperType* type, |
| 965 int* index) { | 969 int* index) { |
| 966 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 970 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 967 | 971 |
| 968 if (!IsUserLoggedIn() || IsLoggedInAsStub()) { | 972 if (!IsUserLoggedIn() || IsLoggedInAsStub()) { |
| 969 *type = current_user_wallpaper_type_ = User::DEFAULT; | 973 *type = current_user_wallpaper_type_ = User::DEFAULT; |
| 970 *index = current_user_wallpaper_index_ = ash::GetInvalidWallpaperIndex(); | 974 *index = current_user_wallpaper_index_ = ash::GetInvalidWallpaperIndex(); |
| 971 return; | 975 return; |
| 972 } | 976 } |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1457 BrowserThread::PostTask( | 1461 BrowserThread::PostTask( |
| 1458 BrowserThread::FILE, | 1462 BrowserThread::FILE, |
| 1459 FROM_HERE, | 1463 FROM_HERE, |
| 1460 base::Bind(&UserManagerImpl::DeleteUserImage, | 1464 base::Bind(&UserManagerImpl::DeleteUserImage, |
| 1461 base::Unretained(this), | 1465 base::Unretained(this), |
| 1462 image_path)); | 1466 image_path)); |
| 1463 } | 1467 } |
| 1464 } | 1468 } |
| 1465 | 1469 |
| 1466 } // namespace chromeos | 1470 } // namespace chromeos |
| OLD | NEW |