Chromium Code Reviews| 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 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 8 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 9 #include "components/user_manager/user_image/user_image.h" | 9 #include "components/user_manager/user_image/user_image.h" |
| 10 #include "components/user_manager/user_type.h" | 10 #include "components/user_manager/user_type.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 | 109 |
| 110 void FakeUserManager::UserLoggedIn(const std::string& email, | 110 void FakeUserManager::UserLoggedIn(const std::string& email, |
| 111 const std::string& username_hash, | 111 const std::string& username_hash, |
| 112 bool browser_restart) { | 112 bool browser_restart) { |
| 113 for (user_manager::UserList::const_iterator it = user_list_.begin(); | 113 for (user_manager::UserList::const_iterator it = user_list_.begin(); |
| 114 it != user_list_.end(); | 114 it != user_list_.end(); |
| 115 ++it) { | 115 ++it) { |
| 116 if ((*it)->username_hash() == username_hash) { | 116 if ((*it)->username_hash() == username_hash) { |
| 117 (*it)->set_is_logged_in(true); | 117 (*it)->set_is_logged_in(true); |
| 118 logged_in_users_.push_back(*it); | 118 logged_in_users_.push_back(*it); |
| 119 SwitchActiveUser((*it)->email()); | |
| 119 | 120 |
| 120 if (!primary_user_) | 121 if (!primary_user_) |
| 121 primary_user_ = *it; | 122 primary_user_ = *it; |
| 122 break; | 123 break; |
| 123 } | 124 } |
| 124 } | 125 } |
| 125 } | 126 } |
| 126 | 127 |
| 127 user_manager::User* FakeUserManager::GetActiveUserInternal() const { | 128 user_manager::User* FakeUserManager::GetActiveUserInternal() const { |
| 128 if (user_list_.size()) { | 129 if (user_list_.size()) { |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 142 const user_manager::User* FakeUserManager::GetActiveUser() const { | 143 const user_manager::User* FakeUserManager::GetActiveUser() const { |
| 143 return GetActiveUserInternal(); | 144 return GetActiveUserInternal(); |
| 144 } | 145 } |
| 145 | 146 |
| 146 user_manager::User* FakeUserManager::GetActiveUser() { | 147 user_manager::User* FakeUserManager::GetActiveUser() { |
| 147 return GetActiveUserInternal(); | 148 return GetActiveUserInternal(); |
| 148 } | 149 } |
| 149 | 150 |
| 150 void FakeUserManager::SwitchActiveUser(const std::string& email) { | 151 void FakeUserManager::SwitchActiveUser(const std::string& email) { |
| 151 active_user_id_ = email; | 152 active_user_id_ = email; |
| 153 if (user_list_.size() && !active_user_id_.empty()) { | |
| 154 for (user_manager::UserList::const_iterator it = user_list_.begin(); | |
| 155 it != user_list_.end(); ++it) { | |
| 156 if ((*it)->email() == active_user_id_) | |
| 157 (*it)->set_is_active(true); | |
| 158 else if ((*it)->is_active()) | |
| 159 (*it)->set_is_active(false); | |
| 160 } | |
|
dzhioev (left Google)
2014/08/01 15:30:41
nit: I think '(*it)->set_is_active((*it)->email()
michaelpg
2014/10/20 23:47:27
Done.
| |
| 161 } | |
| 152 } | 162 } |
| 153 | 163 |
| 154 void FakeUserManager::SaveUserDisplayName( | 164 void FakeUserManager::SaveUserDisplayName( |
| 155 const std::string& username, | 165 const std::string& username, |
| 156 const base::string16& display_name) { | 166 const base::string16& display_name) { |
| 157 for (user_manager::UserList::iterator it = user_list_.begin(); | 167 for (user_manager::UserList::iterator it = user_list_.begin(); |
| 158 it != user_list_.end(); | 168 it != user_list_.end(); |
| 159 ++it) { | 169 ++it) { |
| 160 if ((*it)->email() == username) { | 170 if ((*it)->email() == username) { |
| 161 (*it)->set_display_name(display_name); | 171 (*it)->set_display_name(display_name); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 | 308 |
| 299 UserFlow* FakeUserManager::GetUserFlow(const std::string& email) const { | 309 UserFlow* FakeUserManager::GetUserFlow(const std::string& email) const { |
| 300 return NULL; | 310 return NULL; |
| 301 } | 311 } |
| 302 | 312 |
| 303 bool FakeUserManager::AreSupervisedUsersAllowed() const { | 313 bool FakeUserManager::AreSupervisedUsersAllowed() const { |
| 304 return true; | 314 return true; |
| 305 } | 315 } |
| 306 | 316 |
| 307 } // namespace chromeos | 317 } // namespace chromeos |
| OLD | NEW |