Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / chromeos / login / mock_user_manager.cc
blob69881606308fcdadb9bf4d4b9ae6b0d4d8568fee
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.
5 #include "chrome/browser/chromeos/login/mock_user_manager.h"
7 #include "chrome/browser/chromeos/login/fake_supervised_user_manager.h"
9 namespace chromeos {
11 MockUserManager::MockUserManager()
12 : user_flow_(new DefaultUserFlow()),
13 supervised_user_manager_(new FakeSupervisedUserManager()) {}
15 MockUserManager::~MockUserManager() {
16 ClearUserList();
19 const UserList& MockUserManager::GetUsers() const {
20 return user_list_;
23 const User* MockUserManager::GetLoggedInUser() const {
24 return user_list_.empty() ? NULL : user_list_.front();
27 User* MockUserManager::GetLoggedInUser() {
28 return user_list_.empty() ? NULL : user_list_.front();
31 UserList MockUserManager::GetUnlockUsers() const {
32 return user_list_;
35 const std::string& MockUserManager::GetOwnerEmail() {
36 return GetLoggedInUser()->email();
39 const User* MockUserManager::GetActiveUser() const {
40 return GetLoggedInUser();
43 User* MockUserManager::GetActiveUser() {
44 return GetLoggedInUser();
47 const User* MockUserManager::GetPrimaryUser() const {
48 return GetLoggedInUser();
51 User* MockUserManager::GetUserByProfile(Profile* profile) const {
52 return user_list_.empty() ? NULL : user_list_.front();
55 UserImageManager* MockUserManager::GetUserImageManager(
56 const std::string& user_id) {
57 return NULL;
60 SupervisedUserManager* MockUserManager::GetSupervisedUserManager() {
61 return supervised_user_manager_.get();
64 // Creates a new User instance.
65 void MockUserManager::SetActiveUser(const std::string& email) {
66 ClearUserList();
67 AddUser(email);
70 UserFlow* MockUserManager::GetCurrentUserFlow() const {
71 return user_flow_.get();
74 UserFlow* MockUserManager::GetUserFlow(const std::string&) const {
75 return user_flow_.get();
78 User* MockUserManager::CreatePublicAccountUser(const std::string& email) {
79 ClearUserList();
80 user_list_.push_back(User::CreatePublicAccountUser(email));
81 return user_list_.back();
84 void MockUserManager::AddUser(const std::string& email) {
85 user_list_.push_back(User::CreateRegularUser(email));
88 void MockUserManager::ClearUserList() {
89 // Can't use STLDeleteElements because of the protected destructor of User.
90 UserList::iterator user;
91 for (user = user_list_.begin(); user != user_list_.end(); ++user)
92 delete *user;
93 user_list_.clear();
96 bool MockUserManager::RespectLocalePreference(
97 Profile* profile,
98 const User* user,
99 scoped_ptr<locale_util::SwitchLanguageCallback> callback) const {
100 return false;
103 } // namespace chromeos