OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.h" | 5 #include "chrome/browser/chromeos/login/user_manager.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 55 |
56 base::LazyInstance<UserManager> g_user_manager(base::LINKER_INITIALIZED); | 56 base::LazyInstance<UserManager> g_user_manager(base::LINKER_INITIALIZED); |
57 | 57 |
58 // Stores path to the image in local state. Runs on UI thread. | 58 // Stores path to the image in local state. Runs on UI thread. |
59 void SaveOAuthTokenStatusToLocalState(const std::string& username, | 59 void SaveOAuthTokenStatusToLocalState(const std::string& username, |
60 UserManager::OAuthTokenStatus oauth_token_status) { | 60 UserManager::OAuthTokenStatus oauth_token_status) { |
61 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 61 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
62 PrefService* local_state = g_browser_process->local_state(); | 62 PrefService* local_state = g_browser_process->local_state(); |
63 DictionaryPrefUpdate oauth_status_update(local_state, kUserOAuthTokenStatus); | 63 DictionaryPrefUpdate oauth_status_update(local_state, kUserOAuthTokenStatus); |
64 oauth_status_update->SetWithoutPathExpansion(username, | 64 oauth_status_update->SetWithoutPathExpansion(username, |
65 new base::FundamentalValue(static_cast<int>(oauth_token_status))); | 65 base::NumberValue::New(static_cast<int>(oauth_token_status))); |
66 DVLOG(1) << "Saving user OAuth token status in Local State."; | 66 DVLOG(1) << "Saving user OAuth token status in Local State."; |
67 local_state->SavePersistentPrefs(); | 67 local_state->SavePersistentPrefs(); |
68 } | 68 } |
69 | 69 |
70 // Stores path to the image in local state. Runs on UI thread. | 70 // Stores path to the image in local state. Runs on UI thread. |
71 void SavePathToLocalState(const std::string& username, | 71 void SavePathToLocalState(const std::string& username, |
72 const std::string& image_path) { | 72 const std::string& image_path) { |
73 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 73 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
74 PrefService* local_state = g_browser_process->local_state(); | 74 PrefService* local_state = g_browser_process->local_state(); |
75 DictionaryPrefUpdate images_update(local_state, kUserImages); | 75 DictionaryPrefUpdate images_update(local_state, kUserImages); |
76 images_update->SetWithoutPathExpansion(username, new StringValue(image_path)); | 76 images_update->SetWithoutPathExpansion(username, |
| 77 base::StringValue::New(image_path)); |
77 DVLOG(1) << "Saving path to user image in Local State."; | 78 DVLOG(1) << "Saving path to user image in Local State."; |
78 local_state->SavePersistentPrefs(); | 79 local_state->SavePersistentPrefs(); |
79 UserManager::Get()->NotifyLocalStateChanged(); | 80 UserManager::Get()->NotifyLocalStateChanged(); |
80 } | 81 } |
81 | 82 |
82 // Saves image to file with specified path. Runs on FILE thread. | 83 // Saves image to file with specified path. Runs on FILE thread. |
83 // Posts task for saving image path to local state on UI thread. | 84 // Posts task for saving image path to local state on UI thread. |
84 void SaveImageToFile(const SkBitmap& image, | 85 void SaveImageToFile(const SkBitmap& image, |
85 const FilePath& image_path, | 86 const FilePath& image_path, |
86 const std::string& username) { | 87 const std::string& username) { |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 // Clear the prefs view of the users. | 377 // Clear the prefs view of the users. |
377 PrefService* prefs = g_browser_process->local_state(); | 378 PrefService* prefs = g_browser_process->local_state(); |
378 ListPrefUpdate prefs_users_update(prefs, kLoggedInUsers); | 379 ListPrefUpdate prefs_users_update(prefs, kLoggedInUsers); |
379 prefs_users_update->Clear(); | 380 prefs_users_update->Clear(); |
380 | 381 |
381 user_is_logged_in_ = true; | 382 user_is_logged_in_ = true; |
382 logged_in_user_ = User(); | 383 logged_in_user_ = User(); |
383 logged_in_user_.set_email(email); | 384 logged_in_user_.set_email(email); |
384 | 385 |
385 // Make sure this user is first. | 386 // Make sure this user is first. |
386 prefs_users_update->Append(Value::CreateStringValue(email)); | 387 prefs_users_update->Append(base::StringValue::New(email)); |
387 for (std::vector<User>::iterator it = users.begin(); | 388 for (std::vector<User>::iterator it = users.begin(); |
388 it != users.end(); | 389 it != users.end(); |
389 ++it) { | 390 ++it) { |
390 std::string user_email = it->email(); | 391 std::string user_email = it->email(); |
391 // Skip the most recent user. | 392 // Skip the most recent user. |
392 if (email != user_email) { | 393 if (email != user_email) { |
393 prefs_users_update->Append(Value::CreateStringValue(user_email)); | 394 prefs_users_update->Append(base::StringValue::New(user_email)); |
394 } else { | 395 } else { |
395 logged_in_user_ = *it; | 396 logged_in_user_ = *it; |
396 } | 397 } |
397 } | 398 } |
398 prefs->SavePersistentPrefs(); | 399 prefs->SavePersistentPrefs(); |
399 NotifyOnLogin(); | 400 NotifyOnLogin(); |
400 if (current_user_is_new_) { | 401 if (current_user_is_new_) { |
401 SetDefaultUserImage(email); | 402 SetDefaultUserImage(email); |
402 } else { | 403 } else { |
403 int metric = kDefaultImagesCount; | 404 int metric = kDefaultImagesCount; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 PrefService* prefs = g_browser_process->local_state(); | 441 PrefService* prefs = g_browser_process->local_state(); |
441 ListPrefUpdate prefs_users_update(prefs, kLoggedInUsers); | 442 ListPrefUpdate prefs_users_update(prefs, kLoggedInUsers); |
442 prefs_users_update->Clear(); | 443 prefs_users_update->Clear(); |
443 | 444 |
444 for (std::vector<User>::iterator it = users.begin(); | 445 for (std::vector<User>::iterator it = users.begin(); |
445 it != users.end(); | 446 it != users.end(); |
446 ++it) { | 447 ++it) { |
447 std::string user_email = it->email(); | 448 std::string user_email = it->email(); |
448 // Skip user that we would like to delete. | 449 // Skip user that we would like to delete. |
449 if (email != user_email) | 450 if (email != user_email) |
450 prefs_users_update->Append(Value::CreateStringValue(user_email)); | 451 prefs_users_update->Append(base::StringValue::New(user_email)); |
451 } | 452 } |
452 | 453 |
453 DictionaryPrefUpdate prefs_images_update(prefs, kUserImages); | 454 DictionaryPrefUpdate prefs_images_update(prefs, kUserImages); |
454 std::string image_path_string; | 455 std::string image_path_string; |
455 prefs_images_update->GetStringWithoutPathExpansion(email, &image_path_string); | 456 prefs_images_update->GetStringWithoutPathExpansion(email, &image_path_string); |
456 prefs_images_update->RemoveWithoutPathExpansion(email, NULL); | 457 prefs_images_update->RemoveWithoutPathExpansion(email, NULL); |
457 | 458 |
458 DictionaryPrefUpdate prefs_oauth_update(prefs, kUserOAuthTokenStatus); | 459 DictionaryPrefUpdate prefs_oauth_update(prefs, kUserOAuthTokenStatus); |
459 int oauth_status; | 460 int oauth_status; |
460 prefs_oauth_update->GetIntegerWithoutPathExpansion(email, &oauth_status); | 461 prefs_oauth_update->GetIntegerWithoutPathExpansion(email, &oauth_status); |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 } | 723 } |
723 | 724 |
724 void UserManager::NotifyLocalStateChanged() { | 725 void UserManager::NotifyLocalStateChanged() { |
725 FOR_EACH_OBSERVER( | 726 FOR_EACH_OBSERVER( |
726 Observer, | 727 Observer, |
727 observer_list_, | 728 observer_list_, |
728 LocalStateChanged(this)); | 729 LocalStateChanged(this)); |
729 } | 730 } |
730 | 731 |
731 } // namespace chromeos | 732 } // namespace chromeos |
OLD | NEW |