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

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

Issue 271533004: Turning on MultiProfile by default for ChromeOS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 <numeric> 7 #include <numeric>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/ash_switches.h" 10 #include "ash/ash_switches.h"
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 RecordUma(info.type, -1); 537 RecordUma(info.type, -1);
538 if (info == current_user_wallpaper_info_) 538 if (info == current_user_wallpaper_info_)
539 return; 539 return;
540 } 540 }
541 SetUserWallpaperNow(UserManager::Get()->GetLoggedInUser()->email()); 541 SetUserWallpaperNow(UserManager::Get()->GetLoggedInUser()->email());
542 } 542 }
543 543
544 void WallpaperManager::ClearDisposableWallpaperCache() { 544 void WallpaperManager::ClearDisposableWallpaperCache() {
545 // Cancel callback for previous cache requests. 545 // Cancel callback for previous cache requests.
546 weak_factory_.InvalidateWeakPtrs(); 546 weak_factory_.InvalidateWeakPtrs();
547 if (!UserManager::IsMultipleProfilesAllowed()) { 547 // Keep the wallpaper of logged in users in cache at multi-profile mode.
548 wallpaper_cache_.clear(); 548 std::set<std::string> logged_in_users_names;
549 } else { 549 const UserList& logged_users = UserManager::Get()->GetLoggedInUsers();
550 // Keep the wallpaper of logged in users in cache at multi-profile mode. 550 for (UserList::const_iterator it = logged_users.begin();
551 std::set<std::string> logged_in_users_names; 551 it != logged_users.end();
552 const UserList& logged_users = UserManager::Get()->GetLoggedInUsers(); 552 ++it) {
553 for (UserList::const_iterator it = logged_users.begin(); 553 logged_in_users_names.insert((*it)->email());
554 it != logged_users.end(); 554 }
555 ++it) { 555
556 logged_in_users_names.insert((*it)->email()); 556 CustomWallpaperMap logged_in_users_cache;
557 for (CustomWallpaperMap::iterator it = wallpaper_cache_.begin();
558 it != wallpaper_cache_.end(); ++it) {
559 if (logged_in_users_names.find(it->first) !=
560 logged_in_users_names.end()) {
561 logged_in_users_cache.insert(*it);
557 } 562 }
558
559 CustomWallpaperMap logged_in_users_cache;
560 for (CustomWallpaperMap::iterator it = wallpaper_cache_.begin();
561 it != wallpaper_cache_.end(); ++it) {
562 if (logged_in_users_names.find(it->first) !=
563 logged_in_users_names.end()) {
564 logged_in_users_cache.insert(*it);
565 }
566 }
567 wallpaper_cache_ = logged_in_users_cache;
568 } 563 }
564 wallpaper_cache_ = logged_in_users_cache;
569 } 565 }
570 566
571 base::FilePath WallpaperManager::GetCustomWallpaperPath( 567 base::FilePath WallpaperManager::GetCustomWallpaperPath(
572 const char* sub_dir, 568 const char* sub_dir,
573 const std::string& user_id_hash, 569 const std::string& user_id_hash,
574 const std::string& file) const { 570 const std::string& file) const {
575 base::FilePath custom_wallpaper_path = GetCustomWallpaperDir(sub_dir); 571 base::FilePath custom_wallpaper_path = GetCustomWallpaperDir(sub_dir);
576 return custom_wallpaper_path.Append(user_id_hash).Append(file); 572 return custom_wallpaper_path.Append(user_id_hash).Append(file);
577 } 573 }
578 574
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 relative_path, 905 relative_path,
910 layout, 906 layout,
911 type, 907 type,
912 base::Time::Now().LocalMidnight() 908 base::Time::Now().LocalMidnight()
913 }; 909 };
914 SetUserWallpaperInfo(user_id, info, is_persistent); 910 SetUserWallpaperInfo(user_id, info, is_persistent);
915 if (update_wallpaper) { 911 if (update_wallpaper) {
916 GetPendingWallpaper(user_id, false)->ResetSetWallpaperImage(image, info); 912 GetPendingWallpaper(user_id, false)->ResetSetWallpaperImage(image, info);
917 } 913 }
918 914
919 if (UserManager::IsMultipleProfilesAllowed()) 915 wallpaper_cache_[user_id] = image;
920 wallpaper_cache_[user_id] = image;
921 } 916 }
922 917
923 void WallpaperManager::SetDefaultWallpaperNow(const std::string& user_id) { 918 void WallpaperManager::SetDefaultWallpaperNow(const std::string& user_id) {
924 GetPendingWallpaper(user_id, false)->ResetSetDefaultWallpaper(); 919 GetPendingWallpaper(user_id, false)->ResetSetDefaultWallpaper();
925 } 920 }
926 921
927 void WallpaperManager::SetDefaultWallpaperDelayed(const std::string& user_id) { 922 void WallpaperManager::SetDefaultWallpaperDelayed(const std::string& user_id) {
928 GetPendingWallpaper(user_id, true)->ResetSetDefaultWallpaper(); 923 GetPendingWallpaper(user_id, true)->ResetSetDefaultWallpaper();
929 } 924 }
930 925
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 const gfx::ImageSkia& image, 1086 const gfx::ImageSkia& image,
1092 ash::WallpaperLayout layout, 1087 ash::WallpaperLayout layout,
1093 bool update_wallpaper) { 1088 bool update_wallpaper) {
1094 DCHECK(UserManager::Get()->IsUserLoggedIn()); 1089 DCHECK(UserManager::Get()->IsUserLoggedIn());
1095 1090
1096 // There is no visible background in kiosk mode. 1091 // There is no visible background in kiosk mode.
1097 if (UserManager::Get()->IsLoggedInAsKioskApp()) 1092 if (UserManager::Get()->IsLoggedInAsKioskApp())
1098 return; 1093 return;
1099 WallpaperInfo info; 1094 WallpaperInfo info;
1100 info.layout = layout; 1095 info.layout = layout;
1101 if (UserManager::IsMultipleProfilesAllowed()) 1096 wallpaper_cache_[user_id] = image;
1102 wallpaper_cache_[user_id] = image;
1103 1097
1104 if (update_wallpaper) { 1098 if (update_wallpaper) {
1105 GetPendingWallpaper(last_selected_user_, false /* Not delayed */) 1099 GetPendingWallpaper(last_selected_user_, false /* Not delayed */)
1106 ->ResetSetWallpaperImage(image, info); 1100 ->ResetSetWallpaperImage(image, info);
1107 } 1101 }
1108 } 1102 }
1109 1103
1110 void WallpaperManager::UpdateWallpaper(bool clear_cache) { 1104 void WallpaperManager::UpdateWallpaper(bool clear_cache) {
1111 FOR_EACH_OBSERVER(Observer, observers_, OnUpdateWallpaperForTesting()); 1105 FOR_EACH_OBSERVER(Observer, observers_, OnUpdateWallpaperForTesting());
1112 if (clear_cache) 1106 if (clear_cache)
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
1485 User::DEFAULT, 1479 User::DEFAULT,
1486 base::Time::Now().LocalMidnight() 1480 base::Time::Now().LocalMidnight()
1487 }; 1481 };
1488 SetUserWallpaperInfo(user_id, info, true); 1482 SetUserWallpaperInfo(user_id, info, true);
1489 1483
1490 if (update_wallpaper) 1484 if (update_wallpaper)
1491 DoSetDefaultWallpaper(user_id, on_finish.Pass()); 1485 DoSetDefaultWallpaper(user_id, on_finish.Pass());
1492 return; 1486 return;
1493 } 1487 }
1494 1488
1495 // Only cache the user wallpaper at login screen and for multi profile users. 1489 wallpaper_cache_[user_id] = user_image.image();
1496 if (!UserManager::Get()->IsUserLoggedIn() ||
1497 UserManager::IsMultipleProfilesAllowed()) {
1498 wallpaper_cache_[user_id] = user_image.image();
1499 }
1500 1490
1501 if (update_wallpaper) { 1491 if (update_wallpaper) {
1502 ash::Shell::GetInstance() 1492 ash::Shell::GetInstance()
1503 ->desktop_background_controller() 1493 ->desktop_background_controller()
1504 ->SetWallpaperImage(user_image.image(), layout); 1494 ->SetWallpaperImage(user_image.image(), layout);
1505 } 1495 }
1506 } 1496 }
1507 1497
1508 void WallpaperManager::SaveCustomWallpaper( 1498 void WallpaperManager::SaveCustomWallpaper(
1509 const std::string& user_id_hash, 1499 const std::string& user_id_hash,
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
1883 } 1873 }
1884 } 1874 }
1885 1875
1886 if (need_update_screen) { 1876 if (need_update_screen) {
1887 DoSetDefaultWallpaper(std::string(), 1877 DoSetDefaultWallpaper(std::string(),
1888 MovableOnDestroyCallbackHolder().Pass()); 1878 MovableOnDestroyCallbackHolder().Pass());
1889 } 1879 }
1890 } 1880 }
1891 1881
1892 } // namespace chromeos 1882 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/user_manager_unittest.cc ('k') | chrome/browser/chromeos/profiles/profile_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698