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 "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/chromeos/chromeos_version.h" | 9 #include "base/chromeos/chromeos_version.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 } | 167 } |
168 | 168 |
169 EnsureUsersLoaded(); | 169 EnsureUsersLoaded(); |
170 | 170 |
171 // Clear the prefs view of the users. | 171 // Clear the prefs view of the users. |
172 PrefService* prefs = g_browser_process->local_state(); | 172 PrefService* prefs = g_browser_process->local_state(); |
173 ListPrefUpdate prefs_users_update(prefs, kLoggedInUsers); | 173 ListPrefUpdate prefs_users_update(prefs, kLoggedInUsers); |
174 prefs_users_update->Clear(); | 174 prefs_users_update->Clear(); |
175 | 175 |
176 // Make sure this user is first. | 176 // Make sure this user is first. |
177 prefs_users_update->Append(new base::StringValue(email)); | 177 prefs_users_update->Append(Value::CreateStringValue(email)); |
178 UserList::iterator logged_in_user = users_.end(); | 178 UserList::iterator logged_in_user = users_.end(); |
179 for (UserList::iterator it = users_.begin(); it != users_.end(); ++it) { | 179 for (UserList::iterator it = users_.begin(); it != users_.end(); ++it) { |
180 std::string user_email = (*it)->email(); | 180 std::string user_email = (*it)->email(); |
181 // Skip the most recent user. | 181 // Skip the most recent user. |
182 if (email != user_email) | 182 if (email != user_email) |
183 prefs_users_update->Append(new base::StringValue(user_email)); | 183 prefs_users_update->Append(Value::CreateStringValue(user_email)); |
184 else | 184 else |
185 logged_in_user = it; | 185 logged_in_user = it; |
186 } | 186 } |
187 | 187 |
188 if (logged_in_user == users_.end()) { | 188 if (logged_in_user == users_.end()) { |
189 is_current_user_new_ = true; | 189 is_current_user_new_ = true; |
190 logged_in_user_ = CreateUser(email, /* is_ephemeral= */ false); | 190 logged_in_user_ = CreateUser(email, /* is_ephemeral= */ false); |
191 } else { | 191 } else { |
192 logged_in_user_ = *logged_in_user; | 192 logged_in_user_ = *logged_in_user; |
193 users_.erase(logged_in_user); | 193 users_.erase(logged_in_user); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 | 362 |
363 // Do not update local store if the user is ephemeral. | 363 // Do not update local store if the user is ephemeral. |
364 if (IsEphemeralUser(username)) | 364 if (IsEphemeralUser(username)) |
365 return; | 365 return; |
366 | 366 |
367 PrefService* local_state = g_browser_process->local_state(); | 367 PrefService* local_state = g_browser_process->local_state(); |
368 | 368 |
369 DictionaryPrefUpdate display_name_update(local_state, kUserDisplayName); | 369 DictionaryPrefUpdate display_name_update(local_state, kUserDisplayName); |
370 display_name_update->SetWithoutPathExpansion( | 370 display_name_update->SetWithoutPathExpansion( |
371 username, | 371 username, |
372 new base::StringValue(display_name)); | 372 base::Value::CreateStringValue(display_name)); |
373 } | 373 } |
374 | 374 |
375 string16 UserManagerImpl::GetUserDisplayName( | 375 string16 UserManagerImpl::GetUserDisplayName( |
376 const std::string& username) const { | 376 const std::string& username) const { |
377 const User* user = FindUser(username); | 377 const User* user = FindUser(username); |
378 return user ? user->display_name() : string16(); | 378 return user ? user->display_name() : string16(); |
379 } | 379 } |
380 | 380 |
381 void UserManagerImpl::SaveUserDisplayEmail(const std::string& username, | 381 void UserManagerImpl::SaveUserDisplayEmail(const std::string& username, |
382 const std::string& display_email) { | 382 const std::string& display_email) { |
383 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 383 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
384 | 384 |
385 User* user = const_cast<User*>(FindUser(username)); | 385 User* user = const_cast<User*>(FindUser(username)); |
386 if (!user) | 386 if (!user) |
387 return; // Ignore if there is no such user. | 387 return; // Ignore if there is no such user. |
388 | 388 |
389 user->set_display_email(display_email); | 389 user->set_display_email(display_email); |
390 | 390 |
391 // Do not update local store if the user is ephemeral. | 391 // Do not update local store if the user is ephemeral. |
392 if (IsEphemeralUser(username)) | 392 if (IsEphemeralUser(username)) |
393 return; | 393 return; |
394 | 394 |
395 PrefService* local_state = g_browser_process->local_state(); | 395 PrefService* local_state = g_browser_process->local_state(); |
396 | 396 |
397 DictionaryPrefUpdate display_email_update(local_state, kUserDisplayEmail); | 397 DictionaryPrefUpdate display_email_update(local_state, kUserDisplayEmail); |
398 display_email_update->SetWithoutPathExpansion( | 398 display_email_update->SetWithoutPathExpansion( |
399 username, | 399 username, |
400 new base::StringValue(display_email)); | 400 base::Value::CreateStringValue(display_email)); |
401 } | 401 } |
402 | 402 |
403 std::string UserManagerImpl::GetUserDisplayEmail( | 403 std::string UserManagerImpl::GetUserDisplayEmail( |
404 const std::string& username) const { | 404 const std::string& username) const { |
405 const User* user = FindUser(username); | 405 const User* user = FindUser(username); |
406 return user ? user->display_email() : username; | 406 return user ? user->display_email() : username; |
407 } | 407 } |
408 | 408 |
409 void UserManagerImpl::SetLoggedInUserCustomWallpaperLayout( | 409 void UserManagerImpl::SetLoggedInUserCustomWallpaperLayout( |
410 ash::WallpaperLayout layout) { | 410 ash::WallpaperLayout layout) { |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 // Clear the prefs view of the users. | 722 // Clear the prefs view of the users. |
723 PrefService* prefs = g_browser_process->local_state(); | 723 PrefService* prefs = g_browser_process->local_state(); |
724 ListPrefUpdate prefs_users_update(prefs, kLoggedInUsers); | 724 ListPrefUpdate prefs_users_update(prefs, kLoggedInUsers); |
725 prefs_users_update->Clear(); | 725 prefs_users_update->Clear(); |
726 | 726 |
727 UserList::iterator user_to_remove = users_.end(); | 727 UserList::iterator user_to_remove = users_.end(); |
728 for (UserList::iterator it = users_.begin(); it != users_.end(); ++it) { | 728 for (UserList::iterator it = users_.begin(); it != users_.end(); ++it) { |
729 std::string user_email = (*it)->email(); | 729 std::string user_email = (*it)->email(); |
730 // Skip user that we would like to delete. | 730 // Skip user that we would like to delete. |
731 if (email != user_email) | 731 if (email != user_email) |
732 prefs_users_update->Append(new base::StringValue(user_email)); | 732 prefs_users_update->Append(Value::CreateStringValue(user_email)); |
733 else | 733 else |
734 user_to_remove = it; | 734 user_to_remove = it; |
735 } | 735 } |
736 | 736 |
737 WallpaperManager::Get()->RemoveUserWallpaperInfo(email); | 737 WallpaperManager::Get()->RemoveUserWallpaperInfo(email); |
738 | 738 |
739 DictionaryPrefUpdate prefs_oauth_update(prefs, kUserOAuthTokenStatus); | 739 DictionaryPrefUpdate prefs_oauth_update(prefs, kUserOAuthTokenStatus); |
740 int oauth_status; | 740 int oauth_status; |
741 prefs_oauth_update->GetIntegerWithoutPathExpansion(email, &oauth_status); | 741 prefs_oauth_update->GetIntegerWithoutPathExpansion(email, &oauth_status); |
742 prefs_oauth_update->RemoveWithoutPathExpansion(email, NULL); | 742 prefs_oauth_update->RemoveWithoutPathExpansion(email, NULL); |
743 | 743 |
744 DictionaryPrefUpdate prefs_display_name_update(prefs, kUserDisplayName); | 744 DictionaryPrefUpdate prefs_display_name_update(prefs, kUserDisplayName); |
745 prefs_display_name_update->RemoveWithoutPathExpansion(email, NULL); | 745 prefs_display_name_update->RemoveWithoutPathExpansion(email, NULL); |
746 | 746 |
747 DictionaryPrefUpdate prefs_display_email_update(prefs, kUserDisplayEmail); | 747 DictionaryPrefUpdate prefs_display_email_update(prefs, kUserDisplayEmail); |
748 prefs_display_email_update->RemoveWithoutPathExpansion(email, NULL); | 748 prefs_display_email_update->RemoveWithoutPathExpansion(email, NULL); |
749 | 749 |
750 if (user_to_remove != users_.end()) { | 750 if (user_to_remove != users_.end()) { |
751 delete *user_to_remove; | 751 delete *user_to_remove; |
752 users_.erase(user_to_remove); | 752 users_.erase(user_to_remove); |
753 } | 753 } |
754 } | 754 } |
755 | 755 |
756 } // namespace chromeos | 756 } // namespace chromeos |
OLD | NEW |