Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: components/user_manager/fake_user_manager.h

Issue 824683002: UserManager stack refactoring. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USERS_FAKE_USER_MANAGER_H_ 5 #ifndef COMPONENTS_USER_MANAGER_FAKE_USER_MANAGER_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_FAKE_USER_MANAGER_H_ 6 #define COMPONENTS_USER_MANAGER_FAKE_USER_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "chrome/browser/chromeos/login/user_flow.h"
13 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h"
14 #include "components/user_manager/user.h" 12 #include "components/user_manager/user.h"
15 #include "components/user_manager/user_image/user_image.h" 13 #include "components/user_manager/user_image/user_image.h"
14 #include "components/user_manager/user_manager_base.h"
16 15
17 namespace chromeos { 16 namespace user_manager {
18
19 class FakeSupervisedUserManager;
20 17
21 // Fake user manager with a barebones implementation. Users can be added 18 // Fake user manager with a barebones implementation. Users can be added
22 // and set as logged in, and those users can be returned. 19 // and set as logged in, and those users can be returned.
23 class FakeUserManager : public ChromeUserManager { 20 class USER_MANAGER_EXPORT FakeUserManager : public UserManagerBase {
24 public: 21 public:
25 FakeUserManager(); 22 FakeUserManager();
26 ~FakeUserManager() override; 23 ~FakeUserManager() override;
27 24
28 // Create and add a new user. 25 // Create and add a new user.
29 const user_manager::User* AddUser(const std::string& email); 26 virtual const user_manager::User* AddUser(const std::string& email);
30
31 // Create and add a kiosk app user.
32 void AddKioskAppUser(const std::string& kiosk_app_username);
33
34 // Create and add a public account user.
35 const user_manager::User* AddPublicAccountUser(const std::string& email);
36 27
37 // Calculates the user name hash and calls UserLoggedIn to login a user. 28 // Calculates the user name hash and calls UserLoggedIn to login a user.
38 void LoginUser(const std::string& email); 29 void LoginUser(const std::string& email);
39 30
40 // ChromeUserManager overrides.
41 MultiProfileUserController* GetMultiProfileUserController() override;
42 UserImageManager* GetUserImageManager(const std::string& user_id) override;
43 SupervisedUserManager* GetSupervisedUserManager() override;
44 void SetUserFlow(const std::string& email, UserFlow* flow) override {}
45 UserFlow* GetCurrentUserFlow() const override;
46 UserFlow* GetUserFlow(const std::string& email) const override;
47 void ResetUserFlow(const std::string& email) override {}
48
49 // UserManager overrides. 31 // UserManager overrides.
50 const user_manager::UserList& GetUsers() const override; 32 const user_manager::UserList& GetUsers() const override;
51 user_manager::UserList GetUsersAllowedForMultiProfile() const override; 33 user_manager::UserList GetUsersAllowedForMultiProfile() const override;
52 user_manager::UserList GetUsersAllowedForSupervisedUsersCreation()
53 const override;
54 const user_manager::UserList& GetLoggedInUsers() const override; 34 const user_manager::UserList& GetLoggedInUsers() const override;
55 35
56 // Set the user as logged in. 36 // Set the user as logged in.
57 void UserLoggedIn(const std::string& email, 37 void UserLoggedIn(const std::string& email,
58 const std::string& username_hash, 38 const std::string& username_hash,
59 bool browser_restart) override; 39 bool browser_restart) override;
60 40
61 const user_manager::User* GetActiveUser() const override; 41 const user_manager::User* GetActiveUser() const override;
62 user_manager::User* GetActiveUser() override; 42 user_manager::User* GetActiveUser() override;
63 void SwitchActiveUser(const std::string& email) override; 43 void SwitchActiveUser(const std::string& email) override;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 void PerformPostUserLoggedInActions(bool browser_restart) override {} 106 void PerformPostUserLoggedInActions(bool browser_restart) override {}
127 bool IsDemoApp(const std::string& user_id) const override; 107 bool IsDemoApp(const std::string& user_id) const override;
128 bool IsKioskApp(const std::string& user_id) const override; 108 bool IsKioskApp(const std::string& user_id) const override;
129 bool IsPublicAccountMarkedForRemoval( 109 bool IsPublicAccountMarkedForRemoval(
130 const std::string& user_id) const override; 110 const std::string& user_id) const override;
131 void DemoAccountLoggedIn() override {} 111 void DemoAccountLoggedIn() override {}
132 void KioskAppLoggedIn(const std::string& app_id) override {} 112 void KioskAppLoggedIn(const std::string& app_id) override {}
133 void PublicAccountUserLoggedIn(user_manager::User* user) override {} 113 void PublicAccountUserLoggedIn(user_manager::User* user) override {}
134 void SupervisedUserLoggedIn(const std::string& user_id) override {} 114 void SupervisedUserLoggedIn(const std::string& user_id) override {}
135 115
136 void set_owner_email(const std::string& owner_email) { 116 protected:
137 owner_email_ = owner_email; 117 user_manager::User* primary_user_;
138 }
139 118
140 void set_multi_profile_user_controller( 119 // If set this is the active user. If empty, the first created user is the
141 MultiProfileUserController* controller) { 120 // active user.
142 multi_profile_user_controller_ = controller; 121 std::string active_user_id_;
143 }
144 122
145 private: 123 private:
146 // We use this internal function for const-correctness. 124 // We use this internal function for const-correctness.
147 user_manager::User* GetActiveUserInternal() const; 125 user_manager::User* GetActiveUserInternal() const;
148 126
149 scoped_ptr<FakeSupervisedUserManager> supervised_user_manager_; 127 // stub, always empty string.
150 user_manager::UserList user_list_;
151 user_manager::UserList logged_in_users_;
152 std::string owner_email_; 128 std::string owner_email_;
153 user_manager::User* primary_user_;
154
155 // If set this is the active user. If empty, the first created user is the
156 // active user.
157 std::string active_user_id_;
158 MultiProfileUserController* multi_profile_user_controller_;
159 129
160 DISALLOW_COPY_AND_ASSIGN(FakeUserManager); 130 DISALLOW_COPY_AND_ASSIGN(FakeUserManager);
161 }; 131 };
162 132
163 } // namespace chromeos 133 } // namespace user_manager
164 134
165 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_FAKE_USER_MANAGER_H_ 135 #endif // COMPONENTS_USER_MANAGER_FAKE_USER_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698