| 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 "components/user_manager/fake_user_manager.h" | 5 #include "components/user_manager/fake_user_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 user_manager::UserList result; | 81 user_manager::UserList result; |
| 82 for (user_manager::UserList::const_iterator it = users_.begin(); | 82 for (user_manager::UserList::const_iterator it = users_.begin(); |
| 83 it != users_.end(); ++it) { | 83 it != users_.end(); ++it) { |
| 84 if ((*it)->GetType() == user_manager::USER_TYPE_REGULAR && | 84 if ((*it)->GetType() == user_manager::USER_TYPE_REGULAR && |
| 85 !(*it)->is_logged_in()) | 85 !(*it)->is_logged_in()) |
| 86 result.push_back(*it); | 86 result.push_back(*it); |
| 87 } | 87 } |
| 88 return result; | 88 return result; |
| 89 } | 89 } |
| 90 | 90 |
| 91 const user_manager::UserList& FakeUserManager::GetLoggedInUsers() const { | |
| 92 return logged_in_users_; | |
| 93 } | |
| 94 | |
| 95 void FakeUserManager::UserLoggedIn(const AccountId& account_id, | 91 void FakeUserManager::UserLoggedIn(const AccountId& account_id, |
| 96 const std::string& username_hash, | 92 const std::string& username_hash, |
| 97 bool browser_restart) { | 93 bool browser_restart) { |
| 98 for (user_manager::UserList::const_iterator it = users_.begin(); | 94 for (user_manager::UserList::const_iterator it = users_.begin(); |
| 99 it != users_.end(); ++it) { | 95 it != users_.end(); ++it) { |
| 100 if ((*it)->username_hash() == username_hash) { | 96 if ((*it)->username_hash() == username_hash) { |
| 101 (*it)->set_is_logged_in(true); | 97 (*it)->set_is_logged_in(true); |
| 102 (*it)->set_profile_is_created(); | 98 (*it)->set_profile_is_created(); |
| 103 logged_in_users_.push_back(*it); | 99 logged_in_users_.push_back(*it); |
| 104 | 100 |
| 105 if (!primary_user_) | 101 if (!primary_user_) |
| 106 primary_user_ = *it; | 102 primary_user_ = *it; |
| 103 if (!active_user_) |
| 104 active_user_ = *it; |
| 107 break; | 105 break; |
| 108 } | 106 } |
| 109 } | 107 } |
| 108 |
| 109 if (!active_user_ && AreEphemeralUsersEnabled()) |
| 110 RegularUserLoggedInAsEphemeral(account_id); |
| 110 } | 111 } |
| 111 | 112 |
| 112 user_manager::User* FakeUserManager::GetActiveUserInternal() const { | 113 user_manager::User* FakeUserManager::GetActiveUserInternal() const { |
| 113 if (active_user_ != nullptr) | 114 if (active_user_ != nullptr) |
| 114 return active_user_; | 115 return active_user_; |
| 115 | 116 |
| 116 if (!users_.empty()) { | 117 if (!users_.empty()) { |
| 117 if (active_account_id_.is_valid()) { | 118 if (active_account_id_.is_valid()) { |
| 118 for (user_manager::UserList::const_iterator it = users_.begin(); | 119 for (user_manager::UserList::const_iterator it = users_.begin(); |
| 119 it != users_.end(); ++it) { | 120 it != users_.end(); ++it) { |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 bool FakeUserManager::IsUserNonCryptohomeDataEphemeral( | 255 bool FakeUserManager::IsUserNonCryptohomeDataEphemeral( |
| 255 const AccountId& account_id) const { | 256 const AccountId& account_id) const { |
| 256 return false; | 257 return false; |
| 257 } | 258 } |
| 258 | 259 |
| 259 bool FakeUserManager::AreSupervisedUsersAllowed() const { | 260 bool FakeUserManager::AreSupervisedUsersAllowed() const { |
| 260 return true; | 261 return true; |
| 261 } | 262 } |
| 262 | 263 |
| 263 bool FakeUserManager::AreEphemeralUsersEnabled() const { | 264 bool FakeUserManager::AreEphemeralUsersEnabled() const { |
| 264 return false; | 265 return GetEphemeralUsersEnabled(); |
| 266 } |
| 267 |
| 268 void FakeUserManager::SetEphemeralUsersEnabled(bool enabled) { |
| 269 UserManagerBase::SetEphemeralUsersEnabled(enabled); |
| 265 } | 270 } |
| 266 | 271 |
| 267 const std::string& FakeUserManager::GetApplicationLocale() const { | 272 const std::string& FakeUserManager::GetApplicationLocale() const { |
| 268 static const std::string default_locale("en-US"); | 273 static const std::string default_locale("en-US"); |
| 269 return default_locale; | 274 return default_locale; |
| 270 } | 275 } |
| 271 | 276 |
| 272 PrefService* FakeUserManager::GetLocalState() const { | 277 PrefService* FakeUserManager::GetLocalState() const { |
| 273 return nullptr; | 278 return nullptr; |
| 274 } | 279 } |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 NOTIMPLEMENTED(); | 357 NOTIMPLEMENTED(); |
| 353 return; | 358 return; |
| 354 } | 359 } |
| 355 | 360 |
| 356 bool FakeUserManager::IsValidDefaultUserImageId(int image_index) const { | 361 bool FakeUserManager::IsValidDefaultUserImageId(int image_index) const { |
| 357 NOTIMPLEMENTED(); | 362 NOTIMPLEMENTED(); |
| 358 return false; | 363 return false; |
| 359 } | 364 } |
| 360 | 365 |
| 361 } // namespace user_manager | 366 } // namespace user_manager |
| OLD | NEW |