| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/users/fake_user_manager.h" | 5 #include "chrome/browser/chromeos/login/users/fake_user_manager.h" |
| 6 | 6 |
| 7 #include "chrome/browser/chromeos/login/users/fake_supervised_user_manager.h" | 7 #include "chrome/browser/chromeos/login/users/fake_supervised_user_manager.h" |
| 8 | 8 |
| 9 namespace { | 9 namespace { |
| 10 | 10 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 71 |
| 72 void FakeUserManager::UserLoggedIn(const std::string& email, | 72 void FakeUserManager::UserLoggedIn(const std::string& email, |
| 73 const std::string& username_hash, | 73 const std::string& username_hash, |
| 74 bool browser_restart) { | 74 bool browser_restart) { |
| 75 for (UserList::const_iterator it = user_list_.begin(); | 75 for (UserList::const_iterator it = user_list_.begin(); |
| 76 it != user_list_.end(); | 76 it != user_list_.end(); |
| 77 ++it) { | 77 ++it) { |
| 78 if ((*it)->username_hash() == username_hash) { | 78 if ((*it)->username_hash() == username_hash) { |
| 79 (*it)->set_is_logged_in(true); | 79 (*it)->set_is_logged_in(true); |
| 80 logged_in_users_.push_back(*it); | 80 logged_in_users_.push_back(*it); |
| 81 (*it)->set_is_active(true); |
| 82 active_user_id_ = (*it)->email(); |
| 81 | 83 |
| 82 if (!primary_user_) | 84 if (!primary_user_) |
| 83 primary_user_ = *it; | 85 primary_user_ = *it; |
| 84 break; | 86 break; |
| 85 } | 87 } |
| 86 } | 88 } |
| 87 } | 89 } |
| 88 | 90 |
| 89 User* FakeUserManager::GetActiveUserInternal() const { | 91 User* FakeUserManager::GetActiveUserInternal() const { |
| 90 if (user_list_.size()) { | 92 if (user_list_.size()) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 103 const User* FakeUserManager::GetActiveUser() const { | 105 const User* FakeUserManager::GetActiveUser() const { |
| 104 return GetActiveUserInternal(); | 106 return GetActiveUserInternal(); |
| 105 } | 107 } |
| 106 | 108 |
| 107 User* FakeUserManager::GetActiveUser() { | 109 User* FakeUserManager::GetActiveUser() { |
| 108 return GetActiveUserInternal(); | 110 return GetActiveUserInternal(); |
| 109 } | 111 } |
| 110 | 112 |
| 111 void FakeUserManager::SwitchActiveUser(const std::string& email) { | 113 void FakeUserManager::SwitchActiveUser(const std::string& email) { |
| 112 active_user_id_ = email; | 114 active_user_id_ = email; |
| 115 if (user_list_.size() && !active_user_id_.empty()) { |
| 116 for (UserList::const_iterator it = user_list_.begin(); |
| 117 it != user_list_.end(); ++it) { |
| 118 if ((*it)->email() == active_user_id_) |
| 119 (*it)->set_is_active(true); |
| 120 } |
| 121 } |
| 113 } | 122 } |
| 114 | 123 |
| 115 void FakeUserManager::SaveUserDisplayName( | 124 void FakeUserManager::SaveUserDisplayName( |
| 116 const std::string& username, | 125 const std::string& username, |
| 117 const base::string16& display_name) { | 126 const base::string16& display_name) { |
| 118 for (UserList::iterator it = user_list_.begin(); | 127 for (UserList::iterator it = user_list_.begin(); |
| 119 it != user_list_.end(); ++it) { | 128 it != user_list_.end(); ++it) { |
| 120 if ((*it)->email() == username) { | 129 if ((*it)->email() == username) { |
| 121 (*it)->set_display_name(display_name); | 130 (*it)->set_display_name(display_name); |
| 122 return; | 131 return; |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 } | 305 } |
| 297 | 306 |
| 298 bool FakeUserManager::RespectLocalePreference( | 307 bool FakeUserManager::RespectLocalePreference( |
| 299 Profile* profile, | 308 Profile* profile, |
| 300 const User* user, | 309 const User* user, |
| 301 scoped_ptr<locale_util::SwitchLanguageCallback> callback) const { | 310 scoped_ptr<locale_util::SwitchLanguageCallback> callback) const { |
| 302 return false; | 311 return false; |
| 303 } | 312 } |
| 304 | 313 |
| 305 } // namespace chromeos | 314 } // namespace chromeos |
| OLD | NEW |