1 // Copyright 2015 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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USERS_FAKE_CHROME_USER_MANAGER_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_FAKE_CHROME_USER_MANAGER_H_
11 #include "base/memory/scoped_ptr.h"
12 #include "chrome/browser/chromeos/login/user_flow.h"
13 #include "chrome/browser/chromeos/login/users/user_manager_interface.h"
14 #include "components/user_manager/fake_user_manager.h"
15 #include "components/user_manager/user.h"
16 #include "components/user_manager/user_image/user_image.h"
17 #include "components/user_manager/user_manager_base.h"
21 class FakeSupervisedUserManager
;
23 // Fake chrome user manager with a barebones implementation. Users can be added
24 // and set as logged in, and those users can be returned.
25 class FakeChromeUserManager
: public user_manager::FakeUserManager
,
26 public UserManagerInterface
{
28 FakeChromeUserManager();
29 ~FakeChromeUserManager() override
;
31 // Create and add a kiosk app user.
32 void AddKioskAppUser(const std::string
& kiosk_app_username
);
34 // Create and add a public account user.
35 const user_manager::User
* AddPublicAccountUser(const std::string
& email
);
37 // Calculates the user name hash and calls UserLoggedIn to login a user.
38 void LoginUser(const std::string
& email
);
40 // UserManager overrides.
41 user_manager::UserList
GetUsersAllowedForMultiProfile() const override
;
43 // user_manager::FakeUserManager override.
44 const user_manager::User
* AddUser(const std::string
& email
) override
;
45 const user_manager::User
* AddUserWithAffiliation(const std::string
& email
,
46 bool is_affiliated
) override
;
48 // UserManagerInterface implementation.
49 BootstrapManager
* GetBootstrapManager() override
;
50 MultiProfileUserController
* GetMultiProfileUserController() override
;
51 UserImageManager
* GetUserImageManager(const std::string
& user_id
) override
;
52 SupervisedUserManager
* GetSupervisedUserManager() override
;
53 void SetUserFlow(const std::string
& email
, UserFlow
* flow
) override
;
54 UserFlow
* GetCurrentUserFlow() const override
;
55 UserFlow
* GetUserFlow(const std::string
& email
) const override
;
56 void ResetUserFlow(const std::string
& email
) override
;
57 user_manager::UserList
GetUsersAllowedForSupervisedUsersCreation()
59 void SwitchActiveUser(const std::string
& email
) override
;
60 const std::string
& GetOwnerEmail() const override
;
61 void SessionStarted() override
;
62 void RemoveUser(const std::string
& email
,
63 user_manager::RemoveUserDelegate
* delegate
) override
;
64 bool FindKnownUserPrefs(const user_manager::UserID
& user_id
,
65 const base::DictionaryValue
** out_value
) override
;
66 void UpdateKnownUserPrefs(const user_manager::UserID
& user_id
,
67 const base::DictionaryValue
& values
,
70 void set_owner_email(const std::string
& owner_email
) {
71 owner_email_
= owner_email
;
74 void set_bootstrap_manager(BootstrapManager
* bootstrap_manager
) {
75 bootstrap_manager_
= bootstrap_manager
;
78 void set_multi_profile_user_controller(
79 MultiProfileUserController
* controller
) {
80 multi_profile_user_controller_
= controller
;
84 // Lazily creates default user flow.
85 UserFlow
* GetDefaultUserFlow() const;
87 scoped_ptr
<FakeSupervisedUserManager
> supervised_user_manager_
;
88 std::string owner_email_
;
90 BootstrapManager
* bootstrap_manager_
;
91 MultiProfileUserController
* multi_profile_user_controller_
;
93 typedef std::map
<std::string
, UserFlow
*> FlowMap
;
95 // Lazy-initialized default flow.
96 mutable scoped_ptr
<UserFlow
> default_flow_
;
98 // Specific flows by user e-mail.
99 // Keys should be canonicalized before access.
100 FlowMap specific_flows_
;
102 DISALLOW_COPY_AND_ASSIGN(FakeChromeUserManager
);
105 } // namespace chromeos
107 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_FAKE_CHROME_USER_MANAGER_H_