| 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 "base/task_runner.h" | 7 #include "base/task_runner.h" |
| 8 #include "chrome/browser/chromeos/login/users/fake_supervised_user_manager.h" | 8 #include "chrome/browser/chromeos/login/users/fake_supervised_user_manager.h" |
| 9 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 9 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 10 #include "chrome/grit/theme_resources.h" | 10 #include "chrome/grit/theme_resources.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 void FakeUserManager::UserLoggedIn(const std::string& email, | 120 void FakeUserManager::UserLoggedIn(const std::string& email, |
| 121 const std::string& username_hash, | 121 const std::string& username_hash, |
| 122 bool browser_restart) { | 122 bool browser_restart) { |
| 123 for (user_manager::UserList::const_iterator it = user_list_.begin(); | 123 for (user_manager::UserList::const_iterator it = user_list_.begin(); |
| 124 it != user_list_.end(); | 124 it != user_list_.end(); |
| 125 ++it) { | 125 ++it) { |
| 126 if ((*it)->username_hash() == username_hash) { | 126 if ((*it)->username_hash() == username_hash) { |
| 127 (*it)->set_is_logged_in(true); | 127 (*it)->set_is_logged_in(true); |
| 128 (*it)->set_profile_is_created(); | 128 (*it)->set_profile_is_created(); |
| 129 logged_in_users_.push_back(*it); | 129 logged_in_users_.push_back(*it); |
| 130 SwitchActiveUser((*it)->email()); |
| 130 | 131 |
| 131 if (!primary_user_) | 132 if (!primary_user_) |
| 132 primary_user_ = *it; | 133 primary_user_ = *it; |
| 133 break; | 134 break; |
| 134 } | 135 } |
| 135 } | 136 } |
| 136 } | 137 } |
| 137 | 138 |
| 138 user_manager::User* FakeUserManager::GetActiveUserInternal() const { | 139 user_manager::User* FakeUserManager::GetActiveUserInternal() const { |
| 139 if (user_list_.size()) { | 140 if (user_list_.size()) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 155 } | 156 } |
| 156 | 157 |
| 157 user_manager::User* FakeUserManager::GetActiveUser() { | 158 user_manager::User* FakeUserManager::GetActiveUser() { |
| 158 return GetActiveUserInternal(); | 159 return GetActiveUserInternal(); |
| 159 } | 160 } |
| 160 | 161 |
| 161 void FakeUserManager::SwitchActiveUser(const std::string& email) { | 162 void FakeUserManager::SwitchActiveUser(const std::string& email) { |
| 162 active_user_id_ = email; | 163 active_user_id_ = email; |
| 163 ProfileHelper::Get()->ActiveUserHashChanged( | 164 ProfileHelper::Get()->ActiveUserHashChanged( |
| 164 ProfileHelper::GetUserIdHashByUserIdForTesting(email)); | 165 ProfileHelper::GetUserIdHashByUserIdForTesting(email)); |
| 166 if (user_list_.size() && !active_user_id_.empty()) { |
| 167 for (user_manager::UserList::const_iterator it = user_list_.begin(); |
| 168 it != user_list_.end(); ++it) { |
| 169 (*it)->set_is_active((*it)->email() == active_user_id_); |
| 170 } |
| 171 } |
| 165 } | 172 } |
| 166 | 173 |
| 167 void FakeUserManager::SaveUserDisplayName( | 174 void FakeUserManager::SaveUserDisplayName( |
| 168 const std::string& username, | 175 const std::string& username, |
| 169 const base::string16& display_name) { | 176 const base::string16& display_name) { |
| 170 for (user_manager::UserList::iterator it = user_list_.begin(); | 177 for (user_manager::UserList::iterator it = user_list_.begin(); |
| 171 it != user_list_.end(); | 178 it != user_list_.end(); |
| 172 ++it) { | 179 ++it) { |
| 173 if ((*it)->email() == username) { | 180 if ((*it)->email() == username) { |
| 174 (*it)->set_display_name(display_name); | 181 (*it)->set_display_name(display_name); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 bool FakeUserManager::IsKioskApp(const std::string& user_id) const { | 348 bool FakeUserManager::IsKioskApp(const std::string& user_id) const { |
| 342 return false; | 349 return false; |
| 343 } | 350 } |
| 344 | 351 |
| 345 bool FakeUserManager::IsPublicAccountMarkedForRemoval( | 352 bool FakeUserManager::IsPublicAccountMarkedForRemoval( |
| 346 const std::string& user_id) const { | 353 const std::string& user_id) const { |
| 347 return false; | 354 return false; |
| 348 } | 355 } |
| 349 | 356 |
| 350 } // namespace chromeos | 357 } // namespace chromeos |
| OLD | NEW |