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(Value::CreateStringValue(email)); | 177 prefs_users_update->Append(new base::StringValue(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(Value::CreateStringValue(user_email)); | 183 prefs_users_update->Append(new base::StringValue(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 base::Value::CreateStringValue(display_name)); | 372 new base::StringValue(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 base::Value::CreateStringValue(display_email)); | 400 new base::StringValue(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::Observe(int type, | 409 void UserManagerImpl::Observe(int type, |
410 const content::NotificationSource& source, | 410 const content::NotificationSource& source, |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 // Clear the prefs view of the users. | 684 // Clear the prefs view of the users. |
685 PrefService* prefs = g_browser_process->local_state(); | 685 PrefService* prefs = g_browser_process->local_state(); |
686 ListPrefUpdate prefs_users_update(prefs, kLoggedInUsers); | 686 ListPrefUpdate prefs_users_update(prefs, kLoggedInUsers); |
687 prefs_users_update->Clear(); | 687 prefs_users_update->Clear(); |
688 | 688 |
689 UserList::iterator user_to_remove = users_.end(); | 689 UserList::iterator user_to_remove = users_.end(); |
690 for (UserList::iterator it = users_.begin(); it != users_.end(); ++it) { | 690 for (UserList::iterator it = users_.begin(); it != users_.end(); ++it) { |
691 std::string user_email = (*it)->email(); | 691 std::string user_email = (*it)->email(); |
692 // Skip user that we would like to delete. | 692 // Skip user that we would like to delete. |
693 if (email != user_email) | 693 if (email != user_email) |
694 prefs_users_update->Append(Value::CreateStringValue(user_email)); | 694 prefs_users_update->Append(new base::StringValue(user_email)); |
695 else | 695 else |
696 user_to_remove = it; | 696 user_to_remove = it; |
697 } | 697 } |
698 | 698 |
699 WallpaperManager::Get()->RemoveUserWallpaperInfo(email); | 699 WallpaperManager::Get()->RemoveUserWallpaperInfo(email); |
700 | 700 |
701 DictionaryPrefUpdate prefs_oauth_update(prefs, kUserOAuthTokenStatus); | 701 DictionaryPrefUpdate prefs_oauth_update(prefs, kUserOAuthTokenStatus); |
702 int oauth_status; | 702 int oauth_status; |
703 prefs_oauth_update->GetIntegerWithoutPathExpansion(email, &oauth_status); | 703 prefs_oauth_update->GetIntegerWithoutPathExpansion(email, &oauth_status); |
704 prefs_oauth_update->RemoveWithoutPathExpansion(email, NULL); | 704 prefs_oauth_update->RemoveWithoutPathExpansion(email, NULL); |
705 | 705 |
706 DictionaryPrefUpdate prefs_display_name_update(prefs, kUserDisplayName); | 706 DictionaryPrefUpdate prefs_display_name_update(prefs, kUserDisplayName); |
707 prefs_display_name_update->RemoveWithoutPathExpansion(email, NULL); | 707 prefs_display_name_update->RemoveWithoutPathExpansion(email, NULL); |
708 | 708 |
709 DictionaryPrefUpdate prefs_display_email_update(prefs, kUserDisplayEmail); | 709 DictionaryPrefUpdate prefs_display_email_update(prefs, kUserDisplayEmail); |
710 prefs_display_email_update->RemoveWithoutPathExpansion(email, NULL); | 710 prefs_display_email_update->RemoveWithoutPathExpansion(email, NULL); |
711 | 711 |
712 if (user_to_remove != users_.end()) { | 712 if (user_to_remove != users_.end()) { |
713 delete *user_to_remove; | 713 delete *user_to_remove; |
714 users_.erase(user_to_remove); | 714 users_.erase(user_to_remove); |
715 } | 715 } |
716 } | 716 } |
717 | 717 |
718 } // namespace chromeos | 718 } // namespace chromeos |
OLD | NEW |