| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/fake_user_manager.h" | 5 #include "chrome/browser/chromeos/login/fake_user_manager.h" |
| 6 | 6 |
| 7 namespace { | 7 namespace { |
| 8 | 8 |
| 9 // As defined in /chromeos/dbus/cryptohome_client.cc. | 9 // As defined in /chromeos/dbus/cryptohome_client.cc. |
| 10 static const char kUserIdHashSuffix[] = "-hash"; | 10 static const char kUserIdHashSuffix[] = "-hash"; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 delete *it; | 21 delete *it; |
| 22 } | 22 } |
| 23 } | 23 } |
| 24 | 24 |
| 25 void FakeUserManager::AddUser(const std::string& email) { | 25 void FakeUserManager::AddUser(const std::string& email) { |
| 26 User* user = User::CreateRegularUser(email); | 26 User* user = User::CreateRegularUser(email); |
| 27 user->set_username_hash(email + kUserIdHashSuffix); | 27 user->set_username_hash(email + kUserIdHashSuffix); |
| 28 user_list_.push_back(user); | 28 user_list_.push_back(user); |
| 29 } | 29 } |
| 30 | 30 |
| 31 void FakeUserManager::AddKioskAppUser(const std::string& kiosk_app_username) { |
| 32 User* user = User::CreateKioskAppUser(kiosk_app_username); |
| 33 user->set_username_hash(kiosk_app_username + kUserIdHashSuffix); |
| 34 user_list_.push_back(user); |
| 35 } |
| 36 |
| 37 void FakeUserManager::UserLoggedIn(const std::string& email) { |
| 38 UserLoggedIn(email, email + kUserIdHashSuffix, false); |
| 39 } |
| 40 |
| 31 const UserList& FakeUserManager::GetUsers() const { | 41 const UserList& FakeUserManager::GetUsers() const { |
| 32 return user_list_; | 42 return user_list_; |
| 33 } | 43 } |
| 34 | 44 |
| 35 UserList FakeUserManager::GetUsersAdmittedForMultiProfile() const { | 45 UserList FakeUserManager::GetUsersAdmittedForMultiProfile() const { |
| 36 UserList result; | 46 UserList result; |
| 37 for (UserList::const_iterator it = user_list_.begin(); | 47 for (UserList::const_iterator it = user_list_.begin(); |
| 38 it != user_list_.end(); | 48 it != user_list_.end(); |
| 39 ++it) { | 49 ++it) { |
| 40 if ((*it)->GetType() == User::USER_TYPE_REGULAR && !(*it)->is_logged_in()) | 50 if ((*it)->GetType() == User::USER_TYPE_REGULAR && !(*it)->is_logged_in()) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 54 it != user_list_.end(); | 64 it != user_list_.end(); |
| 55 ++it) { | 65 ++it) { |
| 56 if ((*it)->username_hash() == username_hash) { | 66 if ((*it)->username_hash() == username_hash) { |
| 57 (*it)->set_is_logged_in(true); | 67 (*it)->set_is_logged_in(true); |
| 58 logged_in_users_.push_back(*it); | 68 logged_in_users_.push_back(*it); |
| 59 break; | 69 break; |
| 60 } | 70 } |
| 61 } | 71 } |
| 62 } | 72 } |
| 63 | 73 |
| 64 const User* FakeUserManager::GetActiveUser() const { | 74 User* FakeUserManager::GetActiveUserInternal() const { |
| 65 return GetActiveUser(); | |
| 66 } | |
| 67 | |
| 68 User* FakeUserManager::GetActiveUser() { | |
| 69 // Just return the first user. | |
| 70 if (user_list_.size()) | 75 if (user_list_.size()) |
| 71 return user_list_[0]; | 76 return user_list_[0]; |
| 72 return NULL; | 77 return NULL; |
| 73 } | 78 } |
| 74 | 79 |
| 80 const User* FakeUserManager::GetActiveUser() const { |
| 81 return GetActiveUserInternal(); |
| 82 } |
| 83 |
| 84 User* FakeUserManager::GetActiveUser() { |
| 85 return GetActiveUserInternal(); |
| 86 } |
| 87 |
| 75 void FakeUserManager::SaveUserDisplayName( | 88 void FakeUserManager::SaveUserDisplayName( |
| 76 const std::string& username, | 89 const std::string& username, |
| 77 const string16& display_name) { | 90 const string16& display_name) { |
| 78 for (UserList::iterator it = user_list_.begin(); | 91 for (UserList::iterator it = user_list_.begin(); |
| 79 it != user_list_.end(); ++it) { | 92 it != user_list_.end(); ++it) { |
| 80 if ((*it)->email() == username) { | 93 if ((*it)->email() == username) { |
| 81 (*it)->set_display_name(display_name); | 94 (*it)->set_display_name(display_name); |
| 82 return; | 95 return; |
| 83 } | 96 } |
| 84 } | 97 } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 | 190 |
| 178 bool FakeUserManager::IsCurrentUserNonCryptohomeDataEphemeral() const { | 191 bool FakeUserManager::IsCurrentUserNonCryptohomeDataEphemeral() const { |
| 179 return false; | 192 return false; |
| 180 } | 193 } |
| 181 | 194 |
| 182 bool FakeUserManager::CanCurrentUserLock() const { | 195 bool FakeUserManager::CanCurrentUserLock() const { |
| 183 return false; | 196 return false; |
| 184 } | 197 } |
| 185 | 198 |
| 186 bool FakeUserManager::IsUserLoggedIn() const { | 199 bool FakeUserManager::IsUserLoggedIn() const { |
| 187 return true; | 200 return logged_in_users_.size() > 0; |
| 188 } | 201 } |
| 189 | 202 |
| 190 bool FakeUserManager::IsLoggedInAsRegularUser() const { | 203 bool FakeUserManager::IsLoggedInAsRegularUser() const { |
| 191 return true; | 204 return true; |
| 192 } | 205 } |
| 193 | 206 |
| 194 bool FakeUserManager::IsLoggedInAsDemoUser() const { | 207 bool FakeUserManager::IsLoggedInAsDemoUser() const { |
| 195 return false; | 208 return false; |
| 196 } | 209 } |
| 197 | 210 |
| 198 bool FakeUserManager::IsLoggedInAsPublicAccount() const { | 211 bool FakeUserManager::IsLoggedInAsPublicAccount() const { |
| 199 return false; | 212 return false; |
| 200 } | 213 } |
| 201 | 214 |
| 202 bool FakeUserManager::IsLoggedInAsGuest() const { | 215 bool FakeUserManager::IsLoggedInAsGuest() const { |
| 203 return false; | 216 return false; |
| 204 } | 217 } |
| 205 | 218 |
| 206 bool FakeUserManager::IsLoggedInAsLocallyManagedUser() const { | 219 bool FakeUserManager::IsLoggedInAsLocallyManagedUser() const { |
| 207 return false; | 220 return false; |
| 208 } | 221 } |
| 209 | 222 |
| 210 bool FakeUserManager::IsLoggedInAsKioskApp() const { | 223 bool FakeUserManager::IsLoggedInAsKioskApp() const { |
| 211 return false; | 224 const User* active_user = GetActiveUser(); |
| 225 return active_user ? |
| 226 active_user->GetType() == User::USER_TYPE_KIOSK_APP : |
| 227 false; |
| 212 } | 228 } |
| 213 | 229 |
| 214 bool FakeUserManager::IsLoggedInAsStub() const { | 230 bool FakeUserManager::IsLoggedInAsStub() const { |
| 215 return false; | 231 return false; |
| 216 } | 232 } |
| 217 | 233 |
| 218 bool FakeUserManager::IsSessionStarted() const { | 234 bool FakeUserManager::IsSessionStarted() const { |
| 219 return false; | 235 return false; |
| 220 } | 236 } |
| 221 | 237 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 249 bool FakeUserManager::AreLocallyManagedUsersAllowed() const { | 265 bool FakeUserManager::AreLocallyManagedUsersAllowed() const { |
| 250 return true; | 266 return true; |
| 251 } | 267 } |
| 252 | 268 |
| 253 base::FilePath FakeUserManager::GetUserProfileDir( | 269 base::FilePath FakeUserManager::GetUserProfileDir( |
| 254 const std::string&email) const { | 270 const std::string&email) const { |
| 255 return base::FilePath(); | 271 return base::FilePath(); |
| 256 } | 272 } |
| 257 | 273 |
| 258 } // namespace chromeos | 274 } // namespace chromeos |
| OLD | NEW |