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

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

Issue 10832019: Speed up custom wallpaper switching time and wallpaper manager code refactor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile Created 8 years, 4 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/desktop_background/desktop_background_controller.h" 9 #include "ash/desktop_background/desktop_background_controller.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/chromeos/chromeos_version.h" 12 #include "base/chromeos/chromeos_version.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/file_path.h" 15 #include "base/file_path.h"
16 #include "base/file_util.h" 16 #include "base/file_util.h"
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "base/metrics/histogram.h" 18 #include "base/metrics/histogram.h"
19 #include "base/path_service.h" 19 #include "base/path_service.h"
20 #include "base/rand_util.h" 20 #include "base/rand_util.h"
21 #include "base/stl_util.h" 21 #include "base/stl_util.h"
22 #include "base/string_number_conversions.h"
23 #include "base/string_util.h"
24 #include "base/stringprintf.h" 22 #include "base/stringprintf.h"
25 #include "base/time.h" 23 #include "base/time.h"
26 #include "base/utf_string_conversions.h" 24 #include "base/utf_string_conversions.h"
27 #include "base/values.h" 25 #include "base/values.h"
28 #include "chrome/browser/browser_process.h" 26 #include "chrome/browser/browser_process.h"
29 #include "chrome/browser/chromeos/cros/cert_library.h" 27 #include "chrome/browser/chromeos/cros/cert_library.h"
30 #include "chrome/browser/chromeos/cros/cros_library.h" 28 #include "chrome/browser/chromeos/cros/cros_library.h"
31 #include "chrome/browser/chromeos/cryptohome/async_method_caller.h" 29 #include "chrome/browser/chromeos/cryptohome/async_method_caller.h"
32 #include "chrome/browser/chromeos/input_method/input_method_manager.h" 30 #include "chrome/browser/chromeos/input_method/input_method_manager.h"
33 #include "chrome/browser/chromeos/login/default_user_images.h" 31 #include "chrome/browser/chromeos/login/default_user_images.h"
(...skipping 30 matching lines...) Expand all
64 62
65 namespace chromeos { 63 namespace chromeos {
66 64
67 namespace { 65 namespace {
68 66
69 // Names of nodes with info about user image. 67 // Names of nodes with info about user image.
70 const char kImagePathNodeName[] = "path"; 68 const char kImagePathNodeName[] = "path";
71 const char kImageIndexNodeName[] = "index"; 69 const char kImageIndexNodeName[] = "index";
72 const char kImageURLNodeName[] = "url"; 70 const char kImageURLNodeName[] = "url";
73 71
74 const char kWallpaperTypeNodeName[] = "type";
75 const char kWallpaperIndexNodeName[] = "index";
76 const char kWallpaperDateNodeName[] = "date";
77
78 // Default wallpaper index used in OOBE (first boot).
79 // Defined here because Chromium default index differs.
80 // Also see ash::WallpaperInfo kDefaultWallpapers in
81 // desktop_background_resources.cc
82 #if defined(GOOGLE_CHROME_BUILD)
83 const int kDefaultOOBEWallpaperIndex = 16; // IDR_AURA_WALLPAPERS_3_URBAN0
84 #else
85 const int kDefaultOOBEWallpaperIndex = 0; // IDR_AURA_WALLPAPERS_ROMAINGUY_0
86 #endif
87
88 const int kThumbnailWidth = 128;
89 const int kThumbnailHeight = 80;
90
91 // Delay betweeen user login and attempt to update user's profile data. 72 // Delay betweeen user login and attempt to update user's profile data.
92 const long kProfileDataDownloadDelayMs = 10000; 73 const long kProfileDataDownloadDelayMs = 10000;
93 74
94 // Delay betweeen subsequent profile refresh attempts (24 hrs). 75 // Delay betweeen subsequent profile refresh attempts (24 hrs).
95 const long kProfileRefreshIntervalMs = 24L * 3600 * 1000; 76 const long kProfileRefreshIntervalMs = 24L * 3600 * 1000;
96 77
97 // Enum for reporting histograms about profile picture download. 78 // Enum for reporting histograms about profile picture download.
98 enum ProfileDownloadResult { 79 enum ProfileDownloadResult {
99 kDownloadSuccessChanged, 80 kDownloadSuccessChanged,
100 kDownloadSuccess, 81 kDownloadSuccess,
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 186
206 } // namespace 187 } // namespace
207 188
208 UserManagerImpl::UserManagerImpl() 189 UserManagerImpl::UserManagerImpl()
209 : ALLOW_THIS_IN_INITIALIZER_LIST(image_loader_(new UserImageLoader)), 190 : ALLOW_THIS_IN_INITIALIZER_LIST(image_loader_(new UserImageLoader)),
210 logged_in_user_(NULL), 191 logged_in_user_(NULL),
211 session_started_(false), 192 session_started_(false),
212 is_current_user_owner_(false), 193 is_current_user_owner_(false),
213 is_current_user_new_(false), 194 is_current_user_new_(false),
214 is_current_user_ephemeral_(false), 195 is_current_user_ephemeral_(false),
215 current_user_wallpaper_type_(User::UNKNOWN),
216 ALLOW_THIS_IN_INITIALIZER_LIST(current_user_wallpaper_index_(
217 ash::GetInvalidWallpaperIndex())),
218 ephemeral_users_enabled_(false), 196 ephemeral_users_enabled_(false),
219 observed_sync_service_(NULL), 197 observed_sync_service_(NULL),
220 last_image_set_async_(false), 198 last_image_set_async_(false),
221 downloaded_profile_image_data_url_(chrome::kAboutBlankURL), 199 downloaded_profile_image_data_url_(chrome::kAboutBlankURL),
222 downloading_profile_image_(false) { 200 downloading_profile_image_(false) {
223 // UserManager instance should be used only on UI thread. 201 // UserManager instance should be used only on UI thread.
224 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 202 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
225 203
226 MigrateWallpaperData(); 204 MigrateWallpaperData();
227 registrar_.Add(this, chrome::NOTIFICATION_OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED, 205 registrar_.Add(this, chrome::NOTIFICATION_OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 logged_in_user_ = *logged_in_user; 269 logged_in_user_ = *logged_in_user;
292 users_.erase(logged_in_user); 270 users_.erase(logged_in_user);
293 } 271 }
294 // This user must be in the front of the user list. 272 // This user must be in the front of the user list.
295 users_.insert(users_.begin(), logged_in_user_); 273 users_.insert(users_.begin(), logged_in_user_);
296 274
297 if (is_current_user_new_) { 275 if (is_current_user_new_) {
298 SaveUserDisplayName(GetLoggedInUser().email(), 276 SaveUserDisplayName(GetLoggedInUser().email(),
299 UTF8ToUTF16(GetLoggedInUser().GetAccountName(true))); 277 UTF8ToUTF16(GetLoggedInUser().GetAccountName(true)));
300 SetInitialUserImage(email); 278 SetInitialUserImage(email);
301 SetInitialUserWallpaper(email); 279 WallpaperManager::Get()->SetInitialUserWallpaper(email);
302 } else { 280 } else {
303 int image_index = logged_in_user_->image_index(); 281 int image_index = logged_in_user_->image_index();
304 // If current user image is profile image, it needs to be refreshed. 282 // If current user image is profile image, it needs to be refreshed.
305 bool download_profile_image = image_index == User::kProfileImageIndex; 283 bool download_profile_image = image_index == User::kProfileImageIndex;
306 if (download_profile_image) 284 if (download_profile_image)
307 InitDownloadedProfileImage(); 285 InitDownloadedProfileImage();
308 286
309 // Download user's profile data (full name and optionally image) to see if 287 // Download user's profile data (full name and optionally image) to see if
310 // it has changed. 288 // it has changed.
311 BrowserThread::PostDelayedTask( 289 BrowserThread::PostDelayedTask(
(...skipping 21 matching lines...) Expand all
333 kHistogramImagesCount); 311 kHistogramImagesCount);
334 } 312 }
335 313
336 // Set up a repeating timer for refreshing the profile data. 314 // Set up a repeating timer for refreshing the profile data.
337 profile_download_timer_.Start( 315 profile_download_timer_.Start(
338 FROM_HERE, base::TimeDelta::FromMilliseconds(kProfileRefreshIntervalMs), 316 FROM_HERE, base::TimeDelta::FromMilliseconds(kProfileRefreshIntervalMs),
339 this, &UserManagerImpl::DownloadProfileDataScheduled); 317 this, &UserManagerImpl::DownloadProfileDataScheduled);
340 318
341 if (!browser_restart) { 319 if (!browser_restart) {
342 // For GAIA login flow, logged in user wallpaper may not be loaded. 320 // For GAIA login flow, logged in user wallpaper may not be loaded.
343 EnsureLoggedInUserWallpaperLoaded(); 321 WallpaperManager::Get()->EnsureLoggedInUserWallpaperLoaded();
344 } 322 }
345 323
346 NotifyOnLogin(); 324 NotifyOnLogin();
347 } 325 }
348 326
349 void UserManagerImpl::DemoUserLoggedIn() { 327 void UserManagerImpl::DemoUserLoggedIn() {
350 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 328 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
351 is_current_user_new_ = true; 329 is_current_user_new_ = true;
352 is_current_user_ephemeral_ = true; 330 is_current_user_ephemeral_ = true;
353 logged_in_user_ = CreateUser(kDemoUser, /* is_ephemeral= */ true); 331 logged_in_user_ = CreateUser(kDemoUser, /* is_ephemeral= */ true);
354 SetInitialUserImage(kDemoUser); 332 SetInitialUserImage(kDemoUser);
355 SetInitialUserWallpaper(kDemoUser); 333 WallpaperManager::Get()->SetInitialUserWallpaper(kDemoUser);
356 NotifyOnLogin(); 334 NotifyOnLogin();
357 } 335 }
358 336
359 void UserManagerImpl::GuestUserLoggedIn() { 337 void UserManagerImpl::GuestUserLoggedIn() {
360 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 338 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
361 is_current_user_ephemeral_ = true; 339 is_current_user_ephemeral_ = true;
362 SetInitialUserWallpaper(kGuestUser); 340 WallpaperManager::Get()->SetInitialUserWallpaper(kGuestUser);
363 logged_in_user_ = CreateUser(kGuestUser, /* is_ephemeral= */ true); 341 logged_in_user_ = CreateUser(kGuestUser, /* is_ephemeral= */ true);
364 NotifyOnLogin(); 342 NotifyOnLogin();
365 } 343 }
366 344
367 void UserManagerImpl::EphemeralUserLoggedIn(const std::string& email) { 345 void UserManagerImpl::EphemeralUserLoggedIn(const std::string& email) {
368 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 346 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
369 is_current_user_new_ = true; 347 is_current_user_new_ = true;
370 is_current_user_ephemeral_ = true; 348 is_current_user_ephemeral_ = true;
371 logged_in_user_ = CreateUser(email, /* is_ephemeral= */ true); 349 logged_in_user_ = CreateUser(email, /* is_ephemeral= */ true);
372 SetInitialUserImage(email); 350 SetInitialUserImage(email);
373 SetInitialUserWallpaper(email); 351 WallpaperManager::Get()->SetInitialUserWallpaper(email);
374 NotifyOnLogin(); 352 NotifyOnLogin();
375 } 353 }
376 354
377 void UserManagerImpl::InitializeWallpaper() {
378 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
379 if (!IsUserLoggedIn()) {
380 if (!CommandLine::ForCurrentProcess()->HasSwitch(
381 switches::kDisableNewOobe)) {
382 if (!WizardController::IsDeviceRegistered() &&
383 !WizardController::IsZeroDelayEnabled()) {
384 // TODO(nkostylev): Add switch to disable wallpaper transition on OOBE.
385 // Should be used on test images so that they are not slowed down.
386 ash::Shell::GetInstance()->desktop_background_controller()->
387 SetDefaultWallpaper(kDefaultOOBEWallpaperIndex);
388 } else {
389 bool show_users = true;
390 bool result = CrosSettings::Get()->GetBoolean(
391 kAccountsPrefShowUserNamesOnSignIn, &show_users);
392 DCHECK(result) << "Unable to fetch setting "
393 << kAccountsPrefShowUserNamesOnSignIn;
394 if (!show_users) {
395 ash::Shell::GetInstance()->desktop_background_controller()->
396 SetDefaultWallpaper(ash::GetSolidColorIndex());
397 }
398 }
399 }
400 return;
401 }
402 UserSelected(GetLoggedInUser().email());
403 }
404
405 void UserManagerImpl::UserSelected(const std::string& email) {
406 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
407 if (IsKnownUser(email)) {
408 User::WallpaperType type;
409 int index;
410 base::Time date;
411 GetUserWallpaperProperties(email, &type, &index, &date);
412 if (type == User::DAILY && date != base::Time::Now().LocalMidnight()) {
413 index = ash::GetNextWallpaperIndex(index);
414 SaveUserWallpaperProperties(email, User::DAILY, index);
415 } else if (type == User::CUSTOMIZED) {
416 std::string wallpaper_path =
417 GetWallpaperPathForUser(email, false).value();
418 // In customized mode, we use index pref to save the user selected
419 // wallpaper layout. See function SaveWallpaperToLocalState().
420 ash::WallpaperLayout layout = static_cast<ash::WallpaperLayout>(index);
421 // Load user image asynchronously.
422 image_loader_->Start(
423 wallpaper_path, 0,
424 base::Bind(&UserManagerImpl::OnCustomWallpaperLoaded,
425 base::Unretained(this), email, layout));
426 return;
427 }
428 ash::Shell::GetInstance()->desktop_background_controller()->
429 SetDefaultWallpaper(index);
430 WallpaperManager::Get()->SetLastSelectedUser(email);
431 }
432 }
433
434 void UserManagerImpl::SessionStarted() { 355 void UserManagerImpl::SessionStarted() {
435 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 356 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
436 session_started_ = true; 357 session_started_ = true;
437 content::NotificationService::current()->Notify( 358 content::NotificationService::current()->Notify(
438 chrome::NOTIFICATION_SESSION_STARTED, 359 chrome::NOTIFICATION_SESSION_STARTED,
439 content::NotificationService::AllSources(), 360 content::NotificationService::AllSources(),
440 content::NotificationService::NoDetails()); 361 content::NotificationService::NoDetails());
441 } 362 }
442 363
443 void UserManagerImpl::RemoveUser(const std::string& email, 364 void UserManagerImpl::RemoveUser(const std::string& email,
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 535
615 // TODO(bshe): We current disabled the customized wallpaper feature for 536 // TODO(bshe): We current disabled the customized wallpaper feature for
616 // Ephemeral user. As we dont want to keep a copy of customized wallpaper in 537 // Ephemeral user. As we dont want to keep a copy of customized wallpaper in
617 // memory. Need a smarter way to solve this. 538 // memory. Need a smarter way to solve this.
618 if (IsCurrentUserEphemeral()) 539 if (IsCurrentUserEphemeral())
619 return; 540 return;
620 const chromeos::User& user = GetLoggedInUser(); 541 const chromeos::User& user = GetLoggedInUser();
621 std::string username = user.email(); 542 std::string username = user.email();
622 DCHECK(!username.empty()); 543 DCHECK(!username.empty());
623 544
624 std::string file_path = GetWallpaperPathForUser(username, false).value(); 545 std::string file_path = WallpaperManager::Get()->
546 GetWallpaperPathForUser(username, false).value();
625 SaveWallpaperToLocalState(username, file_path, layout, User::CUSTOMIZED); 547 SaveWallpaperToLocalState(username, file_path, layout, User::CUSTOMIZED);
626 // Load wallpaper from file. 548 // Load wallpaper from file.
627 UserSelected(username); 549 WallpaperManager::Get()->OnUserSelected(username);
628 } 550 }
629 551
630 void UserManagerImpl::SaveUserImageFromFile(const std::string& username, 552 void UserManagerImpl::SaveUserImageFromFile(const std::string& username,
631 const FilePath& path) { 553 const FilePath& path) {
632 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 554 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
633 image_loader_->Start( 555 image_loader_->Start(
634 path.value(), login::kMaxUserImageSize, 556 path.value(), login::kMaxUserImageSize,
635 base::Bind(&UserManagerImpl::SaveUserImage, 557 base::Bind(&UserManagerImpl::SaveUserImage,
636 base::Unretained(this), username)); 558 base::Unretained(this), username));
637 } 559 }
638 560
639 void UserManagerImpl::SaveUserWallpaperFromFile(
640 const std::string& username,
641 const FilePath& path,
642 ash::WallpaperLayout layout,
643 base::WeakPtr<WallpaperDelegate> delegate) {
644 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
645 // For wallpapers, save the image without resizing.
646 image_loader_->Start(
647 path.value(), 0 /* Original size */,
648 base::Bind(&UserManagerImpl::SaveUserWallpaperInternal,
649 base::Unretained(this), username, layout, User::CUSTOMIZED,
650 delegate));
651 }
652
653 void UserManagerImpl::SaveUserImageFromProfileImage( 561 void UserManagerImpl::SaveUserImageFromProfileImage(
654 const std::string& username) { 562 const std::string& username) {
655 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 563 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
656 if (!downloaded_profile_image_.empty()) { 564 if (!downloaded_profile_image_.empty()) {
657 // Profile image has already been downloaded, so save it to file right now. 565 // Profile image has already been downloaded, so save it to file right now.
658 DCHECK(profile_image_url_.is_valid()); 566 DCHECK(profile_image_url_.is_valid());
659 SaveUserImageInternal( 567 SaveUserImageInternal(
660 username, 568 username,
661 User::kProfileImageIndex, profile_image_url_, 569 User::kProfileImageIndex, profile_image_url_,
662 UserImage::CreateAndEncode(downloaded_profile_image_)); 570 UserImage::CreateAndEncode(downloaded_profile_image_));
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 LocalStateChanged(this)); 698 LocalStateChanged(this));
791 } 699 }
792 700
793 FilePath UserManagerImpl::GetImagePathForUser(const std::string& username) { 701 FilePath UserManagerImpl::GetImagePathForUser(const std::string& username) {
794 std::string filename = username + ".png"; 702 std::string filename = username + ".png";
795 FilePath user_data_dir; 703 FilePath user_data_dir;
796 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); 704 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
797 return user_data_dir.AppendASCII(filename); 705 return user_data_dir.AppendASCII(filename);
798 } 706 }
799 707
800 FilePath UserManagerImpl::GetWallpaperPathForUser(const std::string& username,
801 bool is_thumbnail) {
802 std::string filename = username +
803 (is_thumbnail ? "_wallpaper_thumb.png" : "_wallpaper.png");
804 FilePath user_data_dir;
805 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
806 return user_data_dir.AppendASCII(filename);
807 }
808
809 void UserManagerImpl::EnsureUsersLoaded() { 708 void UserManagerImpl::EnsureUsersLoaded() {
810 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 709 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
811 if (!users_.empty()) 710 if (!users_.empty())
812 return; 711 return;
813 if (!g_browser_process) 712 if (!g_browser_process)
814 return; 713 return;
815 714
816 PrefService* local_state = g_browser_process->local_state(); 715 PrefService* local_state = g_browser_process->local_state();
817 const ListValue* prefs_users = 716 const ListValue* prefs_users =
818 local_state->GetList(UserManager::kLoggedInUsers); 717 local_state->GetList(UserManager::kLoggedInUsers);
819 const DictionaryValue* prefs_images = 718 const DictionaryValue* prefs_images =
820 local_state->GetDictionary(UserManager::kUserImages); 719 local_state->GetDictionary(UserManager::kUserImages);
821 const DictionaryValue* prefs_display_names = 720 const DictionaryValue* prefs_display_names =
822 local_state->GetDictionary(UserManager::kUserDisplayName); 721 local_state->GetDictionary(UserManager::kUserDisplayName);
823 const DictionaryValue* prefs_display_emails = 722 const DictionaryValue* prefs_display_emails =
824 local_state->GetDictionary(UserManager::kUserDisplayEmail); 723 local_state->GetDictionary(UserManager::kUserDisplayEmail);
825 724
826 int user_image_size = GetCurrentUserImageSize(); 725 int user_image_size = GetCurrentUserImageSize();
827 726
828 if (prefs_users) { 727 if (prefs_users) {
829 for (ListValue::const_iterator it = prefs_users->begin(); 728 for (ListValue::const_iterator it = prefs_users->begin();
830 it != prefs_users->end(); ++it) { 729 it != prefs_users->end(); ++it) {
831 std::string email; 730 std::string email;
832 if ((*it)->GetAsString(&email)) { 731 if ((*it)->GetAsString(&email)) {
833 User* user = CreateUser(email, /* is_ephemeral= */ false); 732 User* user = CreateUser(email, /* is_ephemeral= */ false);
834 users_.push_back(user); 733 users_.push_back(user);
835 734
735 WallpaperManager::Get()->CacheIfCustomWallpaper(email);
736
836 if (prefs_images) { 737 if (prefs_images) {
837 // Get account image path. 738 // Get account image path.
838 // TODO(avayvod): Reading image path as a string is here for 739 // TODO(avayvod): Reading image path as a string is here for
839 // backward compatibility. 740 // backward compatibility.
840 std::string image_path; 741 std::string image_path;
841 const base::DictionaryValue* image_properties; 742 const base::DictionaryValue* image_properties;
842 if (prefs_images->GetStringWithoutPathExpansion(email, &image_path)) { 743 if (prefs_images->GetStringWithoutPathExpansion(email, &image_path)) {
843 int image_id = User::kInvalidImageIndex; 744 int image_id = User::kInvalidImageIndex;
844 if (IsDefaultImagePath(image_path, &image_id)) { 745 if (IsDefaultImagePath(image_path, &image_id)) {
845 user->SetImage(UserImage(GetDefaultImage(image_id)), image_id); 746 user->SetImage(UserImage(GetDefaultImage(image_id)), image_id);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
902 if (prefs_display_emails && 803 if (prefs_display_emails &&
903 prefs_display_emails->GetStringWithoutPathExpansion( 804 prefs_display_emails->GetStringWithoutPathExpansion(
904 email, &display_email)) { 805 email, &display_email)) {
905 user->set_display_email(display_email); 806 user->set_display_email(display_email);
906 } 807 }
907 } 808 }
908 } 809 }
909 } 810 }
910 } 811 }
911 812
912 void UserManagerImpl::EnsureLoggedInUserWallpaperLoaded() {
913 User::WallpaperType type;
914 int index;
915 base::Time last_modification_date;
916 GetLoggedInUserWallpaperProperties(&type, &index, &last_modification_date);
917
918 if (type != current_user_wallpaper_type_ ||
919 index != current_user_wallpaper_index_)
920 UserSelected(GetLoggedInUser().email());
921 }
922
923 void UserManagerImpl::RetrieveTrustedDevicePolicies() { 813 void UserManagerImpl::RetrieveTrustedDevicePolicies() {
924 ephemeral_users_enabled_ = false; 814 ephemeral_users_enabled_ = false;
925 owner_email_ = ""; 815 owner_email_ = "";
926 816
927 CrosSettings* cros_settings = CrosSettings::Get(); 817 CrosSettings* cros_settings = CrosSettings::Get();
928 // Schedule a callback if device policy has not yet been verified. 818 // Schedule a callback if device policy has not yet been verified.
929 if (CrosSettingsProvider::TRUSTED != cros_settings->PrepareTrustedValues( 819 if (CrosSettingsProvider::TRUSTED != cros_settings->PrepareTrustedValues(
930 base::Bind(&UserManagerImpl::RetrieveTrustedDevicePolicies, 820 base::Bind(&UserManagerImpl::RetrieveTrustedDevicePolicies,
931 base::Unretained(this)))) { 821 base::Unretained(this)))) {
932 return; 822 return;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 base::Bind(&UserManagerImpl::CheckOwnership, 904 base::Bind(&UserManagerImpl::CheckOwnership,
1015 base::Unretained(this))); 905 base::Unretained(this)));
1016 } 906 }
1017 907
1018 void UserManagerImpl::SetInitialUserImage(const std::string& username) { 908 void UserManagerImpl::SetInitialUserImage(const std::string& username) {
1019 // Choose a random default image. 909 // Choose a random default image.
1020 int image_id = base::RandInt(0, kDefaultImagesCount - 1); 910 int image_id = base::RandInt(0, kDefaultImagesCount - 1);
1021 SaveUserDefaultImageIndex(username, image_id); 911 SaveUserDefaultImageIndex(username, image_id);
1022 } 912 }
1023 913
1024 void UserManagerImpl::SetInitialUserWallpaper(const std::string& username) {
1025 current_user_wallpaper_type_ = User::DEFAULT;
1026 // TODO(bshe): Ideally, wallpaper should start to load as soon as user click
1027 // "Add user".
1028 if (username == kGuestUser)
1029 current_user_wallpaper_index_ = ash::GetGuestWallpaperIndex();
1030 else
1031 current_user_wallpaper_index_ = ash::GetDefaultWallpaperIndex();
1032 SaveUserWallpaperProperties(username,
1033 current_user_wallpaper_type_,
1034 current_user_wallpaper_index_);
1035
1036 // Some browser tests do not have shell instance. And it is not necessary to
1037 // create a wallpaper for these tests. Add HasInstance check to prevent tests
1038 // crash and speed up the tests by avoid loading wallpaper.
1039 if (ash::Shell::HasInstance()) {
1040 ash::Shell::GetInstance()->desktop_background_controller()->
1041 SetDefaultWallpaper(current_user_wallpaper_index_);
1042 }
1043 }
1044
1045 void UserManagerImpl::MigrateWallpaperData() { 914 void UserManagerImpl::MigrateWallpaperData() {
1046 PrefService* local_state = g_browser_process->local_state(); 915 PrefService* local_state = g_browser_process->local_state();
1047 if (local_state) { 916 if (local_state) {
1048 const DictionaryValue* user_wallpapers = 917 const DictionaryValue* user_wallpapers =
1049 local_state->GetDictionary(kUserWallpapers); 918 local_state->GetDictionary(kUserWallpapers);
1050 int index; 919 int index;
1051 const DictionaryValue* new_user_wallpapers = 920 const DictionaryValue* new_user_wallpapers =
1052 local_state->GetDictionary(kUserWallpapersProperties); 921 local_state->GetDictionary(kUserWallpapersProperties);
1053 if (new_user_wallpapers->empty()) { 922 if (new_user_wallpapers->empty()) {
1054 const UserList& users = GetUsers(); 923 const UserList& users = GetUsers();
1055 for (UserList::const_iterator it = users.begin(); 924 for (UserList::const_iterator it = users.begin();
1056 it != users.end(); 925 it != users.end();
1057 ++it) { 926 ++it) {
1058 std::string username = (*it)->email(); 927 std::string username = (*it)->email();
1059 if (user_wallpapers->GetIntegerWithoutPathExpansion((username), 928 if (user_wallpapers->GetIntegerWithoutPathExpansion((username),
1060 &index)) { 929 &index)) {
1061 DictionaryPrefUpdate prefs_wallpapers_update(local_state, 930 DictionaryPrefUpdate prefs_wallpapers_update(local_state,
1062 kUserWallpapers); 931 kUserWallpapers);
1063 prefs_wallpapers_update->RemoveWithoutPathExpansion(username, NULL); 932 prefs_wallpapers_update->RemoveWithoutPathExpansion(username, NULL);
1064 SaveUserWallpaperProperties(username, User::DEFAULT, index); 933 WallpaperManager::Get()->SaveUserWallpaperProperties(username,
934 User::DEFAULT,
935 index);
1065 } else { 936 } else {
1066 // Before M20, wallpaper index is not saved into LocalState unless 937 // Before M20, wallpaper index is not saved into LocalState unless
1067 // user specifically sets a wallpaper. After M20, the default 938 // user specifically sets a wallpaper. After M20, the default
1068 // wallpaper index is saved to LocalState as soon as a new user login. 939 // wallpaper index is saved to LocalState as soon as a new user login.
1069 // When migrating wallpaper index from M20 to M21, we only migrate 940 // When migrating wallpaper index from M20 to M21, we only migrate
1070 // data that is in LocalState. This cause a problem when users login 941 // data that is in LocalState. This cause a problem when users login
1071 // on a M20 device and then update the device to M21. The default 942 // on a M20 device and then update the device to M21. The default
1072 // wallpaper index failed to migrate because it was not saved into 943 // wallpaper index failed to migrate because it was not saved into
1073 // LocalState. Then we assume that all users have index saved in 944 // LocalState. Then we assume that all users have index saved in
1074 // LocalState in M21. This is not true and it results an empty 945 // LocalState in M21. This is not true and it results an empty
1075 // wallpaper for those users as described in cr/130685. So here we use 946 // wallpaper for those users as described in cr/130685. So here we use
1076 // default wallpaper for users that exist in user list but does not 947 // default wallpaper for users that exist in user list but does not
1077 // have an index saved in LocalState. 948 // have an index saved in LocalState.
1078 SaveUserWallpaperProperties(username, User::DEFAULT, 949 WallpaperManager::Get()->SaveUserWallpaperProperties(username,
1079 ash::GetDefaultWallpaperIndex()); 950 User::DEFAULT, ash::GetDefaultWallpaperIndex());
1080 } 951 }
1081 } 952 }
1082 } 953 }
1083 } 954 }
1084 } 955 }
1085 956
1086 void UserManagerImpl::GetLoggedInUserWallpaperProperties(
1087 User::WallpaperType* type,
1088 int* index,
1089 base::Time* last_modification_date) {
1090 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1091 DCHECK(logged_in_user_);
1092
1093 if (IsLoggedInAsStub()) {
1094 *type = current_user_wallpaper_type_ = User::DEFAULT;
1095 *index = current_user_wallpaper_index_ = ash::GetInvalidWallpaperIndex();
1096 return;
1097 }
1098
1099 GetUserWallpaperProperties(GetLoggedInUser().email(),
1100 type,
1101 index,
1102 last_modification_date);
1103 }
1104
1105 void UserManagerImpl::SaveLoggedInUserWallpaperProperties( 957 void UserManagerImpl::SaveLoggedInUserWallpaperProperties(
1106 User::WallpaperType type, 958 User::WallpaperType type, int index) {
1107 int index) { 959 WallpaperManager::Get()->SaveUserWallpaperProperties(
1108 SaveUserWallpaperProperties(GetLoggedInUser().email(), type, index); 960 GetLoggedInUser().email(), type, index);
1109 } 961 }
1110 962
1111 void UserManagerImpl::SetUserImage(const std::string& username, 963 void UserManagerImpl::SetUserImage(const std::string& username,
1112 int image_index, 964 int image_index,
1113 const GURL& image_url, 965 const GURL& image_url,
1114 const UserImage& user_image) { 966 const UserImage& user_image) {
1115 User* user = const_cast<User*>(FindUser(username)); 967 User* user = const_cast<User*>(FindUser(username));
1116 // User may have been removed by now. 968 // User may have been removed by now.
1117 if (user) { 969 if (user) {
1118 // For existing users, a valid image index should have been set upon loading 970 // For existing users, a valid image index should have been set upon loading
(...skipping 14 matching lines...) Expand all
1133 // Unless this is first-time setting with |SetInitialUserImage|, 985 // Unless this is first-time setting with |SetInitialUserImage|,
1134 // send a notification about image change. 986 // send a notification about image change.
1135 content::NotificationService::current()->Notify( 987 content::NotificationService::current()->Notify(
1136 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, 988 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED,
1137 content::Source<UserManagerImpl>(this), 989 content::Source<UserManagerImpl>(this),
1138 content::Details<const User>(user)); 990 content::Details<const User>(user));
1139 } 991 }
1140 } 992 }
1141 } 993 }
1142 994
1143 void UserManagerImpl::GetUserWallpaperProperties(const std::string& username,
1144 User::WallpaperType* type,
1145 int* index,
1146 base::Time* last_modification_date) {
1147 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1148
1149 // Default to the values cached in memory.
1150 *type = current_user_wallpaper_type_;
1151 *index = current_user_wallpaper_index_;
1152
1153 // Override with values found in local store, if any.
1154 if (!username.empty()) {
1155 const DictionaryValue* user_wallpapers = g_browser_process->local_state()->
1156 GetDictionary(UserManager::kUserWallpapersProperties);
1157 const base::DictionaryValue* wallpaper_properties;
1158 if (user_wallpapers->GetDictionaryWithoutPathExpansion(
1159 username,
1160 &wallpaper_properties)) {
1161 *type = User::UNKNOWN;
1162 *index = ash::GetInvalidWallpaperIndex();
1163 wallpaper_properties->GetInteger(kWallpaperTypeNodeName,
1164 reinterpret_cast<int*>(type));
1165 wallpaper_properties->GetInteger(kWallpaperIndexNodeName, index);
1166 std::string date_string;
1167 int64 val;
1168 if (!(wallpaper_properties->GetString(kWallpaperDateNodeName,
1169 &date_string) &&
1170 base::StringToInt64(date_string, &val)))
1171 val = 0;
1172 *last_modification_date = base::Time::FromInternalValue(val);
1173 }
1174 }
1175 }
1176
1177 void UserManagerImpl::SaveUserWallpaperProperties(const std::string& username,
1178 User::WallpaperType type,
1179 int index) {
1180 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1181
1182 current_user_wallpaper_type_ = type;
1183 current_user_wallpaper_index_ = index;
1184 // Ephemeral users can not save data to local state. We just cache the index
1185 // in memory for them.
1186 if (IsCurrentUserEphemeral()) {
1187 return;
1188 }
1189
1190 PrefService* local_state = g_browser_process->local_state();
1191 DictionaryPrefUpdate wallpaper_update(local_state,
1192 UserManager::kUserWallpapersProperties);
1193
1194 base::DictionaryValue* wallpaper_properties = new base::DictionaryValue();
1195 wallpaper_properties->Set(kWallpaperTypeNodeName,
1196 new base::FundamentalValue(type));
1197 wallpaper_properties->Set(kWallpaperIndexNodeName,
1198 new base::FundamentalValue(index));
1199 wallpaper_properties->SetString(kWallpaperDateNodeName,
1200 base::Int64ToString(base::Time::Now().LocalMidnight().ToInternalValue()));
1201 wallpaper_update->SetWithoutPathExpansion(username, wallpaper_properties);
1202 }
1203
1204 void UserManagerImpl::SaveUserImageInternal(const std::string& username, 995 void UserManagerImpl::SaveUserImageInternal(const std::string& username,
1205 int image_index, 996 int image_index,
1206 const GURL& image_url, 997 const GURL& image_url,
1207 const UserImage& user_image) { 998 const UserImage& user_image) {
1208 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 999 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1209 1000
1210 SetUserImage(username, image_index, image_url, user_image); 1001 SetUserImage(username, image_index, image_url, user_image);
1211 1002
1212 // Ignore for ephemeral users. 1003 // Ignore for ephemeral users.
1213 if (IsEphemeralUser(username)) 1004 if (IsEphemeralUser(username))
1214 return; 1005 return;
1215 1006
1216 FilePath image_path = GetImagePathForUser(username); 1007 FilePath image_path = GetImagePathForUser(username);
1217 DVLOG(1) << "Saving user image to " << image_path.value(); 1008 DVLOG(1) << "Saving user image to " << image_path.value();
1218 1009
1219 last_image_set_async_ = true; 1010 last_image_set_async_ = true;
1220 1011
1221 BrowserThread::PostTask( 1012 BrowserThread::PostTask(
1222 BrowserThread::FILE, 1013 BrowserThread::FILE,
1223 FROM_HERE, 1014 FROM_HERE,
1224 base::Bind(&UserManagerImpl::SaveImageToFile, 1015 base::Bind(&UserManagerImpl::SaveImageToFile,
1225 base::Unretained(this), 1016 base::Unretained(this),
1226 username, user_image, image_path, image_index, image_url)); 1017 username, user_image, image_path, image_index, image_url));
1227 } 1018 }
1228 1019
1229 void UserManagerImpl::SaveUserWallpaperInternal(
1230 const std::string& username,
1231 ash::WallpaperLayout layout,
1232 User::WallpaperType type,
1233 base::WeakPtr<WallpaperDelegate> delegate,
1234 const UserImage& user_image) {
1235 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1236
1237 const SkBitmap& wallpaper = user_image.image();
1238 BrowserThread::PostTask(
1239 BrowserThread::FILE,
1240 FROM_HERE,
1241 base::Bind(&UserManagerImpl::GenerateUserWallpaperThumbnail,
1242 base::Unretained(this), username, type, delegate, wallpaper));
1243
1244 ash::Shell::GetInstance()->desktop_background_controller()->
1245 SetCustomWallpaper(wallpaper, layout);
1246
1247 // Ignore for ephemeral users.
1248 if (IsEphemeralUser(username))
1249 return;
1250
1251 FilePath wallpaper_path = GetWallpaperPathForUser(username, false);
1252 DVLOG(1) << "Saving user image to " << wallpaper_path.value();
1253
1254 last_image_set_async_ = true;
1255
1256 BrowserThread::PostTask(
1257 BrowserThread::FILE,
1258 FROM_HERE,
1259 base::Bind(&UserManagerImpl::SaveWallpaperToFile,
1260 base::Unretained(this), username, wallpaper, wallpaper_path,
1261 layout, User::CUSTOMIZED));
1262 }
1263
1264 void UserManagerImpl::OnCustomWallpaperLoaded(const std::string& email,
1265 ash::WallpaperLayout layout,
1266 const UserImage& user_image) {
1267 const SkBitmap& wallpaper = user_image.image();
1268 ash::Shell::GetInstance()->desktop_background_controller()->
1269 SetCustomWallpaper(wallpaper, layout);
1270 // Starting to load wallpaper thumbnail
1271 std::string wallpaper_thumbnail_path =
1272 GetWallpaperPathForUser(email, true).value();
1273 image_loader_->Start(
1274 wallpaper_thumbnail_path, 0,
1275 base::Bind(&UserManagerImpl::OnCustomWallpaperThumbnailLoaded,
1276 base::Unretained(this), email));
1277 }
1278
1279 void UserManagerImpl::OnCustomWallpaperThumbnailLoaded(
1280 const std::string& email,
1281 const UserImage& user_image) {
1282 const SkBitmap& wallpaper = user_image.image();
1283 User* user = const_cast<User*>(FindUser(email));
1284 // User may have been removed by now.
1285 if (user && !wallpaper.empty())
1286 user->SetWallpaperThumbnail(wallpaper);
1287 }
1288
1289 void UserManagerImpl::OnThumbnailUpdated(
1290 base::WeakPtr<WallpaperDelegate> delegate) {
1291 if (delegate)
1292 delegate->SetCustomWallpaperThumbnail();
1293 }
1294
1295 void UserManagerImpl::GenerateUserWallpaperThumbnail(
1296 const std::string& username,
1297 User::WallpaperType type,
1298 base::WeakPtr<WallpaperDelegate> delegate,
1299 const SkBitmap& wallpaper) {
1300 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
1301 SkBitmap thumbnail =
1302 skia::ImageOperations::Resize(wallpaper,
1303 skia::ImageOperations::RESIZE_LANCZOS3,
1304 kThumbnailWidth, kThumbnailHeight);
1305 logged_in_user_->SetWallpaperThumbnail(thumbnail);
1306
1307 // Notify thumbnail is ready.
1308 BrowserThread::PostTask(
1309 BrowserThread::UI,
1310 FROM_HERE,
1311 base::Bind(&UserManagerImpl::OnThumbnailUpdated,
1312 base::Unretained(this), delegate));
1313
1314 // Ignore for ephemeral users.
1315 if (IsEphemeralUser(username))
1316 return;
1317
1318 FilePath thumbnail_path = GetWallpaperPathForUser(username, true);
1319 SaveBitmapToFile(UserImage(thumbnail), thumbnail_path);
1320 }
1321
1322 void UserManagerImpl::SaveImageToFile(const std::string& username, 1020 void UserManagerImpl::SaveImageToFile(const std::string& username,
1323 const UserImage& user_image, 1021 const UserImage& user_image,
1324 const FilePath& image_path, 1022 const FilePath& image_path,
1325 int image_index, 1023 int image_index,
1326 const GURL& image_url) { 1024 const GURL& image_url) {
1327 if (!SaveBitmapToFile(user_image, image_path)) 1025 if (!SaveBitmapToFile(user_image, image_path))
1328 return; 1026 return;
1329 1027
1330 BrowserThread::PostTask( 1028 BrowserThread::PostTask(
1331 BrowserThread::UI, 1029 BrowserThread::UI,
1332 FROM_HERE, 1030 FROM_HERE,
1333 base::Bind(&UserManagerImpl::SaveImageToLocalState, 1031 base::Bind(&UserManagerImpl::SaveImageToLocalState,
1334 base::Unretained(this), 1032 base::Unretained(this),
1335 username, image_path.value(), image_index, image_url, true)); 1033 username, image_path.value(), image_index, image_url, true));
1336 } 1034 }
1337 1035
1338 void UserManagerImpl::SaveWallpaperToFile(const std::string& username,
1339 const SkBitmap& wallpaper,
1340 const FilePath& wallpaper_path,
1341 ash::WallpaperLayout layout,
1342 User::WallpaperType type) {
1343 // TODO(bshe): We should save the original file unchanged instead of
1344 // re-encoding it and saving it.
1345 if (!SaveBitmapToFile(UserImage(wallpaper), wallpaper_path))
1346 return;
1347
1348 BrowserThread::PostTask(
1349 BrowserThread::UI,
1350 FROM_HERE,
1351 base::Bind(&UserManagerImpl::SaveWallpaperToLocalState,
1352 base::Unretained(this),
1353 username, wallpaper_path.value(), layout, type));
1354 }
1355
1356 void UserManagerImpl::SaveImageToLocalState(const std::string& username, 1036 void UserManagerImpl::SaveImageToLocalState(const std::string& username,
1357 const std::string& image_path, 1037 const std::string& image_path,
1358 int image_index, 1038 int image_index,
1359 const GURL& image_url, 1039 const GURL& image_url,
1360 bool is_async) { 1040 bool is_async) {
1361 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1041 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1362 1042
1363 // Ignore for ephemeral users. 1043 // Ignore for ephemeral users.
1364 if (IsEphemeralUser(username)) 1044 if (IsEphemeralUser(username))
1365 return; 1045 return;
(...skipping 25 matching lines...) Expand all
1391 DVLOG(1) << "Saving path to user image in Local State."; 1071 DVLOG(1) << "Saving path to user image in Local State.";
1392 1072
1393 NotifyLocalStateChanged(); 1073 NotifyLocalStateChanged();
1394 } 1074 }
1395 1075
1396 void UserManagerImpl::SaveWallpaperToLocalState(const std::string& username, 1076 void UserManagerImpl::SaveWallpaperToLocalState(const std::string& username,
1397 const std::string& wallpaper_path, 1077 const std::string& wallpaper_path,
1398 ash::WallpaperLayout layout, 1078 ash::WallpaperLayout layout,
1399 User::WallpaperType type) { 1079 User::WallpaperType type) {
1400 // TODO(bshe): We probably need to save wallpaper_path instead of index. 1080 // TODO(bshe): We probably need to save wallpaper_path instead of index.
1401 SaveUserWallpaperProperties(username, type, layout); 1081 WallpaperManager::Get()->SaveUserWallpaperProperties(username, type, layout);
1402 } 1082 }
1403 1083
1404 bool UserManagerImpl::SaveBitmapToFile(const UserImage& user_image, 1084 bool UserManagerImpl::SaveBitmapToFile(const UserImage& user_image,
1405 const FilePath& image_path) { 1085 const FilePath& image_path) {
1406 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 1086 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
1407 1087
1408 const UserImage::RawImage* encoded_image = NULL; 1088 const UserImage::RawImage* encoded_image = NULL;
1409 if (user_image.has_animated_image()) { 1089 if (user_image.has_animated_image()) {
1410 encoded_image = &user_image.animated_image(); 1090 encoded_image = &user_image.animated_image();
1411 } else if (user_image.has_raw_image()) { 1091 } else if (user_image.has_raw_image()) {
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
1639 prefs_users_update->Append(Value::CreateStringValue(user_email)); 1319 prefs_users_update->Append(Value::CreateStringValue(user_email));
1640 else 1320 else
1641 user_to_remove = it; 1321 user_to_remove = it;
1642 } 1322 }
1643 1323
1644 DictionaryPrefUpdate prefs_wallpapers_update(prefs, 1324 DictionaryPrefUpdate prefs_wallpapers_update(prefs,
1645 kUserWallpapersProperties); 1325 kUserWallpapersProperties);
1646 prefs_wallpapers_update->RemoveWithoutPathExpansion(email, NULL); 1326 prefs_wallpapers_update->RemoveWithoutPathExpansion(email, NULL);
1647 1327
1648 // Remove user wallpaper thumbnail 1328 // Remove user wallpaper thumbnail
1649 FilePath wallpaper_thumb_path = GetWallpaperPathForUser(email, true); 1329 FilePath wallpaper_thumb_path = WallpaperManager::Get()->
1330 GetWallpaperPathForUser(email, true);
1650 BrowserThread::PostTask( 1331 BrowserThread::PostTask(
1651 BrowserThread::FILE, 1332 BrowserThread::FILE,
1652 FROM_HERE, 1333 FROM_HERE,
1653 base::Bind(&UserManagerImpl::DeleteUserImage, 1334 base::Bind(&UserManagerImpl::DeleteUserImage,
1654 base::Unretained(this), 1335 base::Unretained(this),
1655 wallpaper_thumb_path)); 1336 wallpaper_thumb_path));
1656 // Remove user wallpaper 1337 // Remove user wallpaper
1657 FilePath wallpaper_path = GetWallpaperPathForUser(email, false); 1338 FilePath wallpaper_path = WallpaperManager::Get()->
1339 GetWallpaperPathForUser(email, false);
1658 BrowserThread::PostTask( 1340 BrowserThread::PostTask(
1659 BrowserThread::FILE, 1341 BrowserThread::FILE,
1660 FROM_HERE, 1342 FROM_HERE,
1661 base::Bind(&UserManagerImpl::DeleteUserImage, 1343 base::Bind(&UserManagerImpl::DeleteUserImage,
1662 base::Unretained(this), 1344 base::Unretained(this),
1663 wallpaper_path)); 1345 wallpaper_path));
1664 1346
1665 DictionaryPrefUpdate prefs_images_update(prefs, kUserImages); 1347 DictionaryPrefUpdate prefs_images_update(prefs, kUserImages);
1666 std::string image_path_string; 1348 std::string image_path_string;
1667 prefs_images_update->GetStringWithoutPathExpansion(email, &image_path_string); 1349 prefs_images_update->GetStringWithoutPathExpansion(email, &image_path_string);
(...skipping 22 matching lines...) Expand all
1690 BrowserThread::PostTask( 1372 BrowserThread::PostTask(
1691 BrowserThread::FILE, 1373 BrowserThread::FILE,
1692 FROM_HERE, 1374 FROM_HERE,
1693 base::Bind(&UserManagerImpl::DeleteUserImage, 1375 base::Bind(&UserManagerImpl::DeleteUserImage,
1694 base::Unretained(this), 1376 base::Unretained(this),
1695 image_path)); 1377 image_path));
1696 } 1378 }
1697 } 1379 }
1698 1380
1699 } // namespace chromeos 1381 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/user_manager_impl.h ('k') | chrome/browser/chromeos/login/wallpaper_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698