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

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: Test fixed. Created 5 years, 10 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
« no previous file with comments | « components/user_manager/BUILD.gn ('k') | components/user_manager/fake_user_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_manager_base.h"
16 14
17 namespace chromeos { 15 namespace user_manager {
18
19 class FakeSupervisedUserManager;
20 16
21 // Fake user manager with a barebones implementation. Users can be added 17 // Fake user manager with a barebones implementation. Users can be added
22 // and set as logged in, and those users can be returned. 18 // and set as logged in, and those users can be returned.
23 class FakeUserManager : public ChromeUserManager { 19 class USER_MANAGER_EXPORT FakeUserManager : public UserManagerBase {
24 public: 20 public:
25 FakeUserManager(); 21 FakeUserManager();
26 ~FakeUserManager() override; 22 ~FakeUserManager() override;
27 23
28 // Create and add a new user. 24 // Create and add a new user.
29 const user_manager::User* AddUser(const std::string& email); 25 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 26
37 // Calculates the user name hash and calls UserLoggedIn to login a user. 27 // Calculates the user name hash and calls UserLoggedIn to login a user.
38 void LoginUser(const std::string& email); 28 void LoginUser(const std::string& email);
39 29
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. 30 // UserManager overrides.
50 const user_manager::UserList& GetUsers() const override; 31 const user_manager::UserList& GetUsers() const override;
51 user_manager::UserList GetUsersAllowedForMultiProfile() const override; 32 user_manager::UserList GetUsersAllowedForMultiProfile() const override;
52 user_manager::UserList GetUsersAllowedForSupervisedUsersCreation()
53 const override;
54 const user_manager::UserList& GetLoggedInUsers() const override; 33 const user_manager::UserList& GetLoggedInUsers() const override;
55 34
56 // Set the user as logged in. 35 // Set the user as logged in.
57 void UserLoggedIn(const std::string& email, 36 void UserLoggedIn(const std::string& email,
58 const std::string& username_hash, 37 const std::string& username_hash,
59 bool browser_restart) override; 38 bool browser_restart) override;
60 39
61 const user_manager::User* GetActiveUser() const override; 40 const user_manager::User* GetActiveUser() const override;
62 user_manager::User* GetActiveUser() override; 41 user_manager::User* GetActiveUser() override;
63 void SwitchActiveUser(const std::string& email) override; 42 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 {} 105 void PerformPostUserLoggedInActions(bool browser_restart) override {}
127 bool IsDemoApp(const std::string& user_id) const override; 106 bool IsDemoApp(const std::string& user_id) const override;
128 bool IsKioskApp(const std::string& user_id) const override; 107 bool IsKioskApp(const std::string& user_id) const override;
129 bool IsPublicAccountMarkedForRemoval( 108 bool IsPublicAccountMarkedForRemoval(
130 const std::string& user_id) const override; 109 const std::string& user_id) const override;
131 void DemoAccountLoggedIn() override {} 110 void DemoAccountLoggedIn() override {}
132 void KioskAppLoggedIn(const std::string& app_id) override {} 111 void KioskAppLoggedIn(const std::string& app_id) override {}
133 void PublicAccountUserLoggedIn(user_manager::User* user) override {} 112 void PublicAccountUserLoggedIn(user_manager::User* user) override {}
134 void SupervisedUserLoggedIn(const std::string& user_id) override {} 113 void SupervisedUserLoggedIn(const std::string& user_id) override {}
135 114
136 void set_owner_email(const std::string& owner_email) { 115 protected:
137 owner_email_ = owner_email; 116 user_manager::User* primary_user_;
138 }
139 117
140 void set_multi_profile_user_controller( 118 // If set this is the active user. If empty, the first created user is the
141 MultiProfileUserController* controller) { 119 // active user.
142 multi_profile_user_controller_ = controller; 120 std::string active_user_id_;
143 }
144 121
145 private: 122 private:
146 // We use this internal function for const-correctness. 123 // We use this internal function for const-correctness.
147 user_manager::User* GetActiveUserInternal() const; 124 user_manager::User* GetActiveUserInternal() const;
148 125
149 scoped_ptr<FakeSupervisedUserManager> supervised_user_manager_; 126 // stub, always empty string.
150 user_manager::UserList user_list_;
151 user_manager::UserList logged_in_users_;
152 std::string owner_email_; 127 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 128
160 DISALLOW_COPY_AND_ASSIGN(FakeUserManager); 129 DISALLOW_COPY_AND_ASSIGN(FakeUserManager);
161 }; 130 };
162 131
163 } // namespace chromeos 132 } // namespace user_manager
164 133
165 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_FAKE_USER_MANAGER_H_ 134 #endif // COMPONENTS_USER_MANAGER_FAKE_USER_MANAGER_H_
OLDNEW
« no previous file with comments | « components/user_manager/BUILD.gn ('k') | components/user_manager/fake_user_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698