Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(670)

Side by Side Diff: chrome/browser/chromeos/login/user_manager_impl.cc

Issue 9856016: Using random wallpaper until user select one (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 } 406 }
407 UMA_HISTOGRAM_ENUMERATION("UserImage.LoggedIn", 407 UMA_HISTOGRAM_ENUMERATION("UserImage.LoggedIn",
408 histogram_index, 408 histogram_index,
409 kHistogramImagesCount); 409 kHistogramImagesCount);
410 } 410 }
411 } 411 }
412 412
413 void UserManagerImpl::DemoUserLoggedIn() { 413 void UserManagerImpl::DemoUserLoggedIn() {
414 is_current_user_new_ = true; 414 is_current_user_new_ = true;
415 is_current_user_ephemeral_ = true; 415 is_current_user_ephemeral_ = true;
416 ephemeral_user_wallpaper_index_ = ash::GetDefaultWallpaperIndex();
416 logged_in_user_ = new User(kDemoUser, false); 417 logged_in_user_ = new User(kDemoUser, false);
417 SetInitialUserImage(kDemoUser); 418 SetInitialUserImage(kDemoUser);
418 NotifyOnLogin(); 419 NotifyOnLogin();
419 } 420 }
420 421
421 void UserManagerImpl::GuestUserLoggedIn() { 422 void UserManagerImpl::GuestUserLoggedIn() {
422 is_current_user_ephemeral_ = true; 423 is_current_user_ephemeral_ = true;
424 ephemeral_user_wallpaper_index_ = ash::GetGuestWallpaperIndex();
423 logged_in_user_ = new User(kGuestUser, true); 425 logged_in_user_ = new User(kGuestUser, true);
424 NotifyOnLogin(); 426 NotifyOnLogin();
425 } 427 }
426 428
427 void UserManagerImpl::EphemeralUserLoggedIn(const std::string& email) { 429 void UserManagerImpl::EphemeralUserLoggedIn(const std::string& email) {
428 is_current_user_new_ = true; 430 is_current_user_new_ = true;
429 is_current_user_ephemeral_ = true; 431 is_current_user_ephemeral_ = true;
432 ephemeral_user_wallpaper_index_ = ash::GetDefaultWallpaperIndex();
430 logged_in_user_ = CreateUser(email); 433 logged_in_user_ = CreateUser(email);
431 SetInitialUserImage(email); 434 SetInitialUserImage(email);
432 NotifyOnLogin(); 435 NotifyOnLogin();
433 } 436 }
434 437
435 void UserManagerImpl::StubUserLoggedIn() { 438 void UserManagerImpl::StubUserLoggedIn() {
436 is_current_user_ephemeral_ = true; 439 is_current_user_ephemeral_ = true;
437 logged_in_user_ = new User(kStubUser, false); 440 logged_in_user_ = new User(kStubUser, false);
438 logged_in_user_->SetImage(GetDefaultImage(kStubDefaultImageIndex), 441 logged_in_user_->SetImage(GetDefaultImage(kStubDefaultImageIndex),
439 kStubDefaultImageIndex); 442 kStubDefaultImageIndex);
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 906
904 void UserManagerImpl::SetInitialUserImage(const std::string& username) { 907 void UserManagerImpl::SetInitialUserImage(const std::string& username) {
905 // Choose a random default image. 908 // Choose a random default image.
906 int image_id = base::RandInt(0, kDefaultImagesCount - 1); 909 int image_id = base::RandInt(0, kDefaultImagesCount - 1);
907 SaveUserDefaultImageIndex(username, image_id); 910 SaveUserDefaultImageIndex(username, image_id);
908 } 911 }
909 912
910 int UserManagerImpl::GetUserWallpaperIndex() { 913 int UserManagerImpl::GetUserWallpaperIndex() {
911 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 914 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
912 915
913 // If at login screen or logged in as a guest/incognito user, then use the 916 // If at login screen or logged in as a guest user, use the default guest
914 // randomly generated wallpaper. 917 // wallpaper. If logged in as other ephemeral uses (Demo/Stub/Normal user
918 // with ephemeral policy enabled), use the index in memory.
915 if (IsLoggedInAsGuest() || !IsUserLoggedIn()) 919 if (IsLoggedInAsGuest() || !IsUserLoggedIn())
Nikita (slow) 2012/03/26 15:31:58 if (!IsUserLoggedIn()) guest is handled below.
bshe 2012/03/26 16:12:10 It seems we want to always return the same index f
Nikita (slow) 2012/03/26 16:50:07 Ok, now I've checked that kGuestWallpaperIndex is
916 return ash::GetGuestWallpaperIndex(); 920 return ash::GetGuestWallpaperIndex();
921 if (IsCurrentUserEphemeral())
922 return ephemeral_user_wallpaper_index_;
917 923
918 const chromeos::User& user = GetLoggedInUser(); 924 const chromeos::User& user = GetLoggedInUser();
919 std::string username = user.email(); 925 std::string username = user.email();
920 DCHECK(!username.empty()); 926 DCHECK(!username.empty());
921 927
922 PrefService* local_state = g_browser_process->local_state(); 928 PrefService* local_state = g_browser_process->local_state();
923 const DictionaryValue* user_wallpapers = 929 const DictionaryValue* user_wallpapers =
924 local_state->GetDictionary(UserManager::kUserWallpapers); 930 local_state->GetDictionary(UserManager::kUserWallpapers);
925 int index = ash::GetDefaultWallpaperIndex(); 931 int index = ash::GetDefaultWallpaperIndex();
926 if (!user_wallpapers->GetIntegerWithoutPathExpansion(username, &index)) 932 if (!user_wallpapers->GetIntegerWithoutPathExpansion(username, &index))
927 SaveUserWallpaperIndex(index); 933 SaveUserWallpaperIndex(index);
928 934
929 DCHECK(index >=0 && index < ash::GetWallpaperCount()); 935 DCHECK(index >=0 && index < ash::GetWallpaperCount());
930 return index; 936 return index;
931 } 937 }
932 938
933 void UserManagerImpl::SaveUserWallpaperIndex(int wallpaper_index) { 939 void UserManagerImpl::SaveUserWallpaperIndex(int wallpaper_index) {
934 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 940 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
935 // If at login screen or logged in as a guest/incognito user, then return. 941 // Ephemeral users can not save data to local state. We cache the index in
936 // Guest/incognito user can not change wallpaper according to chromium-os 942 // memory for them.
937 // issue 26900. 943 if (IsCurrentUserEphemeral() || !IsUserLoggedIn()) {
938 if (IsLoggedInAsGuest() || !IsUserLoggedIn()) 944 ephemeral_user_wallpaper_index_ = wallpaper_index;
939 return; 945 return;
946 }
940 947
941 const chromeos::User& user = GetLoggedInUser(); 948 const chromeos::User& user = GetLoggedInUser();
942 std::string username = user.email(); 949 std::string username = user.email();
943 DCHECK(!username.empty()); 950 DCHECK(!username.empty());
944 951
945 PrefService* local_state = g_browser_process->local_state(); 952 PrefService* local_state = g_browser_process->local_state();
946 DictionaryPrefUpdate wallpapers_update(local_state, 953 DictionaryPrefUpdate wallpapers_update(local_state,
947 UserManager::kUserWallpapers); 954 UserManager::kUserWallpapers);
948 wallpapers_update->SetWithoutPathExpansion(username, 955 wallpapers_update->SetWithoutPathExpansion(username,
949 new base::FundamentalValue(wallpaper_index)); 956 new base::FundamentalValue(wallpaper_index));
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
1235 BrowserThread::PostTask( 1242 BrowserThread::PostTask(
1236 BrowserThread::FILE, 1243 BrowserThread::FILE,
1237 FROM_HERE, 1244 FROM_HERE,
1238 base::Bind(&UserManagerImpl::DeleteUserImage, 1245 base::Bind(&UserManagerImpl::DeleteUserImage,
1239 base::Unretained(this), 1246 base::Unretained(this),
1240 image_path)); 1247 image_path));
1241 } 1248 }
1242 } 1249 }
1243 1250
1244 } // namespace chromeos 1251 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698