| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/chromeos/login/mock_user_manager.h" | |
| 6 | |
| 7 #include "chrome/browser/chromeos/login/fake_supervised_user_manager.h" | |
| 8 | |
| 9 namespace chromeos { | |
| 10 | |
| 11 MockUserManager::MockUserManager() | |
| 12 : user_flow_(new DefaultUserFlow()), | |
| 13 supervised_user_manager_(new FakeSupervisedUserManager()) {} | |
| 14 | |
| 15 MockUserManager::~MockUserManager() { | |
| 16 ClearUserList(); | |
| 17 } | |
| 18 | |
| 19 const UserList& MockUserManager::GetUsers() const { | |
| 20 return user_list_; | |
| 21 } | |
| 22 | |
| 23 const User* MockUserManager::GetLoggedInUser() const { | |
| 24 return user_list_.empty() ? NULL : user_list_.front(); | |
| 25 } | |
| 26 | |
| 27 User* MockUserManager::GetLoggedInUser() { | |
| 28 return user_list_.empty() ? NULL : user_list_.front(); | |
| 29 } | |
| 30 | |
| 31 UserList MockUserManager::GetUnlockUsers() const { | |
| 32 return user_list_; | |
| 33 } | |
| 34 | |
| 35 const std::string& MockUserManager::GetOwnerEmail() { | |
| 36 return GetLoggedInUser()->email(); | |
| 37 } | |
| 38 | |
| 39 const User* MockUserManager::GetActiveUser() const { | |
| 40 return GetLoggedInUser(); | |
| 41 } | |
| 42 | |
| 43 User* MockUserManager::GetActiveUser() { | |
| 44 return GetLoggedInUser(); | |
| 45 } | |
| 46 | |
| 47 const User* MockUserManager::GetPrimaryUser() const { | |
| 48 return GetLoggedInUser(); | |
| 49 } | |
| 50 | |
| 51 User* MockUserManager::GetUserByProfile(Profile* profile) const { | |
| 52 return user_list_.empty() ? NULL : user_list_.front(); | |
| 53 } | |
| 54 | |
| 55 MultiProfileUserController* MockUserManager::GetMultiProfileUserController() { | |
| 56 return NULL; | |
| 57 } | |
| 58 | |
| 59 UserImageManager* MockUserManager::GetUserImageManager( | |
| 60 const std::string& user_id) { | |
| 61 return NULL; | |
| 62 } | |
| 63 | |
| 64 SupervisedUserManager* MockUserManager::GetSupervisedUserManager() { | |
| 65 return supervised_user_manager_.get(); | |
| 66 } | |
| 67 | |
| 68 // Creates a new User instance. | |
| 69 void MockUserManager::SetActiveUser(const std::string& email) { | |
| 70 ClearUserList(); | |
| 71 AddUser(email); | |
| 72 } | |
| 73 | |
| 74 UserFlow* MockUserManager::GetCurrentUserFlow() const { | |
| 75 return user_flow_.get(); | |
| 76 } | |
| 77 | |
| 78 UserFlow* MockUserManager::GetUserFlow(const std::string&) const { | |
| 79 return user_flow_.get(); | |
| 80 } | |
| 81 | |
| 82 User* MockUserManager::CreatePublicAccountUser(const std::string& email) { | |
| 83 ClearUserList(); | |
| 84 user_list_.push_back(User::CreatePublicAccountUser(email)); | |
| 85 return user_list_.back(); | |
| 86 } | |
| 87 | |
| 88 void MockUserManager::AddUser(const std::string& email) { | |
| 89 user_list_.push_back(User::CreateRegularUser(email)); | |
| 90 } | |
| 91 | |
| 92 void MockUserManager::ClearUserList() { | |
| 93 // Can't use STLDeleteElements because of the protected destructor of User. | |
| 94 UserList::iterator user; | |
| 95 for (user = user_list_.begin(); user != user_list_.end(); ++user) | |
| 96 delete *user; | |
| 97 user_list_.clear(); | |
| 98 } | |
| 99 | |
| 100 bool MockUserManager::RespectLocalePreference( | |
| 101 Profile* profile, | |
| 102 const User* user, | |
| 103 scoped_ptr<locale_util::SwitchLanguageCallback> callback) const { | |
| 104 return false; | |
| 105 } | |
| 106 | |
| 107 } // namespace chromeos | |
| OLD | NEW |