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 12 matching lines...) Expand all Loading... |
23 } | 23 } |
24 } | 24 } |
25 | 25 |
26 void FakeUserManager::AddUser(const std::string& email) { | 26 void FakeUserManager::AddUser(const std::string& email) { |
27 User* user = User::CreateRegularUser(email); | 27 User* user = User::CreateRegularUser(email); |
28 user->set_username_hash(email + kUserIdHashSuffix); | 28 user->set_username_hash(email + kUserIdHashSuffix); |
29 user->SetStubImage(User::kProfileImageIndex, false); | 29 user->SetStubImage(User::kProfileImageIndex, false); |
30 user_list_.push_back(user); | 30 user_list_.push_back(user); |
31 } | 31 } |
32 | 32 |
| 33 void FakeUserManager::AddKioskAppUser(const std::string& kiosk_app_username) { |
| 34 User* user = User::CreateKioskAppUser(kiosk_app_username); |
| 35 user->set_username_hash(kiosk_app_username + kUserIdHashSuffix); |
| 36 user_list_.push_back(user); |
| 37 } |
| 38 |
33 void FakeUserManager::LoginUser(const std::string& email) { | 39 void FakeUserManager::LoginUser(const std::string& email) { |
34 UserLoggedIn(email, email + kUserIdHashSuffix, false); | 40 UserLoggedIn(email, email + kUserIdHashSuffix, false); |
35 } | 41 } |
36 | 42 |
37 const UserList& FakeUserManager::GetUsers() const { | 43 const UserList& FakeUserManager::GetUsers() const { |
38 return user_list_; | 44 return user_list_; |
39 } | 45 } |
40 | 46 |
41 UserList FakeUserManager::GetUsersAdmittedForMultiProfile() const { | 47 UserList FakeUserManager::GetUsersAdmittedForMultiProfile() const { |
42 UserList result; | 48 UserList result; |
(...skipping 20 matching lines...) Expand all Loading... |
63 (*it)->set_is_logged_in(true); | 69 (*it)->set_is_logged_in(true); |
64 logged_in_users_.push_back(*it); | 70 logged_in_users_.push_back(*it); |
65 | 71 |
66 if (!primary_user_) | 72 if (!primary_user_) |
67 primary_user_ = *it; | 73 primary_user_ = *it; |
68 break; | 74 break; |
69 } | 75 } |
70 } | 76 } |
71 } | 77 } |
72 | 78 |
73 const User* FakeUserManager::GetActiveUser() const { | 79 User* FakeUserManager::GetActiveUserInternal() const { |
74 return GetActiveUser(); | |
75 } | |
76 | |
77 User* FakeUserManager::GetActiveUser() { | |
78 // Just return the first user. | |
79 if (user_list_.size()) | 80 if (user_list_.size()) |
80 return user_list_[0]; | 81 return user_list_[0]; |
81 return NULL; | 82 return NULL; |
82 } | 83 } |
83 | 84 |
| 85 const User* FakeUserManager::GetActiveUser() const { |
| 86 return GetActiveUserInternal(); |
| 87 } |
| 88 |
| 89 User* FakeUserManager::GetActiveUser() { |
| 90 return GetActiveUserInternal(); |
| 91 } |
| 92 |
84 void FakeUserManager::SaveUserDisplayName( | 93 void FakeUserManager::SaveUserDisplayName( |
85 const std::string& username, | 94 const std::string& username, |
86 const string16& display_name) { | 95 const string16& display_name) { |
87 for (UserList::iterator it = user_list_.begin(); | 96 for (UserList::iterator it = user_list_.begin(); |
88 it != user_list_.end(); ++it) { | 97 it != user_list_.end(); ++it) { |
89 if ((*it)->email() == username) { | 98 if ((*it)->email() == username) { |
90 (*it)->set_display_name(display_name); | 99 (*it)->set_display_name(display_name); |
91 return; | 100 return; |
92 } | 101 } |
93 } | 102 } |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 | 200 |
192 bool FakeUserManager::IsCurrentUserNonCryptohomeDataEphemeral() const { | 201 bool FakeUserManager::IsCurrentUserNonCryptohomeDataEphemeral() const { |
193 return false; | 202 return false; |
194 } | 203 } |
195 | 204 |
196 bool FakeUserManager::CanCurrentUserLock() const { | 205 bool FakeUserManager::CanCurrentUserLock() const { |
197 return false; | 206 return false; |
198 } | 207 } |
199 | 208 |
200 bool FakeUserManager::IsUserLoggedIn() const { | 209 bool FakeUserManager::IsUserLoggedIn() const { |
201 return true; | 210 return logged_in_users_.size() > 0; |
202 } | 211 } |
203 | 212 |
204 bool FakeUserManager::IsLoggedInAsRegularUser() const { | 213 bool FakeUserManager::IsLoggedInAsRegularUser() const { |
205 return true; | 214 return true; |
206 } | 215 } |
207 | 216 |
208 bool FakeUserManager::IsLoggedInAsDemoUser() const { | 217 bool FakeUserManager::IsLoggedInAsDemoUser() const { |
209 return false; | 218 return false; |
210 } | 219 } |
211 | 220 |
212 bool FakeUserManager::IsLoggedInAsPublicAccount() const { | 221 bool FakeUserManager::IsLoggedInAsPublicAccount() const { |
213 return false; | 222 return false; |
214 } | 223 } |
215 | 224 |
216 bool FakeUserManager::IsLoggedInAsGuest() const { | 225 bool FakeUserManager::IsLoggedInAsGuest() const { |
217 return false; | 226 return false; |
218 } | 227 } |
219 | 228 |
220 bool FakeUserManager::IsLoggedInAsLocallyManagedUser() const { | 229 bool FakeUserManager::IsLoggedInAsLocallyManagedUser() const { |
221 return false; | 230 return false; |
222 } | 231 } |
223 | 232 |
224 bool FakeUserManager::IsLoggedInAsKioskApp() const { | 233 bool FakeUserManager::IsLoggedInAsKioskApp() const { |
225 return false; | 234 const User* active_user = GetActiveUser(); |
| 235 return active_user ? |
| 236 active_user->GetType() == User::USER_TYPE_KIOSK_APP : |
| 237 false; |
226 } | 238 } |
227 | 239 |
228 bool FakeUserManager::IsLoggedInAsStub() const { | 240 bool FakeUserManager::IsLoggedInAsStub() const { |
229 return false; | 241 return false; |
230 } | 242 } |
231 | 243 |
232 bool FakeUserManager::IsSessionStarted() const { | 244 bool FakeUserManager::IsSessionStarted() const { |
233 return false; | 245 return false; |
234 } | 246 } |
235 | 247 |
(...skipping 27 matching lines...) Expand all Loading... |
263 bool FakeUserManager::AreLocallyManagedUsersAllowed() const { | 275 bool FakeUserManager::AreLocallyManagedUsersAllowed() const { |
264 return true; | 276 return true; |
265 } | 277 } |
266 | 278 |
267 base::FilePath FakeUserManager::GetUserProfileDir( | 279 base::FilePath FakeUserManager::GetUserProfileDir( |
268 const std::string&email) const { | 280 const std::string&email) const { |
269 return base::FilePath(); | 281 return base::FilePath(); |
270 } | 282 } |
271 | 283 |
272 } // namespace chromeos | 284 } // namespace chromeos |
OLD | NEW |