Chromium Code Reviews| 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 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 932 SetDefaultWallpaper(current_user_wallpaper_index_); | 932 SetDefaultWallpaper(current_user_wallpaper_index_); |
| 933 } | 933 } |
| 934 } | 934 } |
| 935 | 935 |
| 936 void UserManagerImpl::MigrateWallpaperData() { | 936 void UserManagerImpl::MigrateWallpaperData() { |
| 937 PrefService* local_state = g_browser_process->local_state(); | 937 PrefService* local_state = g_browser_process->local_state(); |
| 938 if (local_state) { | 938 if (local_state) { |
| 939 const DictionaryValue* user_wallpapers = | 939 const DictionaryValue* user_wallpapers = |
| 940 local_state->GetDictionary(kUserWallpapers); | 940 local_state->GetDictionary(kUserWallpapers); |
| 941 int index; | 941 int index; |
| 942 if (user_wallpapers) { | 942 const UserList& users = GetUsers(); |
| 943 const UserList& users = GetUsers(); | 943 for (UserList::const_iterator it = users.begin(); |
| 944 for (UserList::const_iterator it = users.begin(); | 944 it != users.end(); |
| 945 it != users.end(); | 945 ++it) { |
| 946 ++it) { | 946 std::string username = (*it)->email(); |
| 947 std::string username = (*it)->email(); | 947 if (user_wallpapers->GetIntegerWithoutPathExpansion((username), |
| 948 if (user_wallpapers->GetIntegerWithoutPathExpansion((username), | 948 &index)) { |
| 949 &index)) { | 949 DictionaryPrefUpdate prefs_wallpapers_update(local_state, |
| 950 DictionaryPrefUpdate prefs_wallpapers_update(local_state, | 950 kUserWallpapers); |
| 951 kUserWallpapers); | 951 prefs_wallpapers_update->RemoveWithoutPathExpansion(username, NULL); |
| 952 prefs_wallpapers_update->RemoveWithoutPathExpansion(username, NULL); | 952 SaveUserWallpaperProperties(username, User::DEFAULT, index); |
| 953 SaveUserWallpaperProperties(username, User::DEFAULT, index); | 953 } else { |
| 954 } | 954 // Before M20, wallpaper index is not saved into LocalState unless user |
| 955 // specifically sets a wallpaper. After M20, the default wallpaper index | |
| 956 // is saved to LocalState as soon as a new user login. When migrating | |
| 957 // wallpaper index from M20 to M21, we only migrate data that is in | |
| 958 // LocalState. This cause a problem when users login on a M20 device and | |
| 959 // then update the device to M21. The default wallpaper index failed to | |
| 960 // migrate because it was not saved into LocalState. Then we assume that | |
| 961 // all users have index saved in LocalState in M21. This is not true and | |
| 962 // it results an empty wallpaper for those users as described in | |
| 963 // cr/130685. So here we use default wallpaper for users that exist in | |
| 964 // user list but does not have an index saved in LocalState. | |
| 965 SaveUserWallpaperProperties(username, User::DEFAULT, | |
| 966 ash::GetDefaultWallpaperIndex()); | |
| 955 } | 967 } |
| 956 } | 968 } |
| 957 } | 969 } |
| 958 } | 970 } |
| 959 | 971 |
| 960 int UserManagerImpl::GetLoggedInUserWallpaperIndex() { | 972 int UserManagerImpl::GetLoggedInUserWallpaperIndex() { |
| 961 User::WallpaperType type; | 973 User::WallpaperType type; |
| 962 int index; | 974 int index; |
| 963 GetLoggedInUserWallpaperProperties(&type, &index); | 975 GetLoggedInUserWallpaperProperties(&type, &index); |
| 964 return index; | 976 return index; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1020 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1032 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1021 | 1033 |
| 1022 // Default to the values cached in memory. | 1034 // Default to the values cached in memory. |
| 1023 *type = current_user_wallpaper_type_; | 1035 *type = current_user_wallpaper_type_; |
| 1024 *index = current_user_wallpaper_index_; | 1036 *index = current_user_wallpaper_index_; |
| 1025 | 1037 |
| 1026 // Override with values found in local store, if any. | 1038 // Override with values found in local store, if any. |
| 1027 if (!username.empty()) { | 1039 if (!username.empty()) { |
| 1028 const DictionaryValue* user_wallpapers = g_browser_process->local_state()-> | 1040 const DictionaryValue* user_wallpapers = g_browser_process->local_state()-> |
| 1029 GetDictionary(UserManager::kUserWallpapersProperties); | 1041 GetDictionary(UserManager::kUserWallpapersProperties); |
| 1030 if (user_wallpapers) { | 1042 base::DictionaryValue* wallpaper_properties; |
|
Nikita (slow)
2012/06/05 08:07:17
Why this check is removed?
DCHECK(user_wallpapers)
bshe
2012/06/08 15:22:52
It seem this check is always true if we register t
| |
| 1031 base::DictionaryValue* wallpaper_properties; | 1043 if (user_wallpapers->GetDictionaryWithoutPathExpansion( |
| 1032 if (user_wallpapers->GetDictionaryWithoutPathExpansion( | 1044 username, |
| 1033 username, | 1045 &wallpaper_properties)) { |
| 1034 &wallpaper_properties)) { | 1046 *type = User::UNKNOWN; |
| 1035 *type = User::UNKNOWN; | 1047 *index = ash::GetDefaultWallpaperIndex(); |
| 1036 *index = ash::GetDefaultWallpaperIndex(); | 1048 wallpaper_properties->GetInteger(kWallpaperTypeNodeName, |
| 1037 wallpaper_properties->GetInteger(kWallpaperTypeNodeName, | 1049 reinterpret_cast<int*>(type)); |
| 1038 reinterpret_cast<int*>(type)); | 1050 wallpaper_properties->GetInteger(kWallpaperIndexNodeName, index); |
| 1039 wallpaper_properties->GetInteger(kWallpaperIndexNodeName, index); | |
| 1040 } | |
| 1041 } | 1051 } |
| 1042 } | 1052 } |
| 1043 } | 1053 } |
| 1044 | 1054 |
| 1045 void UserManagerImpl::SaveUserWallpaperProperties(const std::string& username, | 1055 void UserManagerImpl::SaveUserWallpaperProperties(const std::string& username, |
| 1046 User::WallpaperType type, | 1056 User::WallpaperType type, |
| 1047 int index) { | 1057 int index) { |
| 1048 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1058 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1049 | 1059 |
| 1050 current_user_wallpaper_type_ = type; | 1060 current_user_wallpaper_type_ = type; |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1461 BrowserThread::PostTask( | 1471 BrowserThread::PostTask( |
| 1462 BrowserThread::FILE, | 1472 BrowserThread::FILE, |
| 1463 FROM_HERE, | 1473 FROM_HERE, |
| 1464 base::Bind(&UserManagerImpl::DeleteUserImage, | 1474 base::Bind(&UserManagerImpl::DeleteUserImage, |
| 1465 base::Unretained(this), | 1475 base::Unretained(this), |
| 1466 image_path)); | 1476 image_path)); |
| 1467 } | 1477 } |
| 1468 } | 1478 } |
| 1469 | 1479 |
| 1470 } // namespace chromeos | 1480 } // namespace chromeos |
| OLD | NEW |