| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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_CHROME_USER_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USERS_FAKE_CHROME_USER_MANAGER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_FAKE_CHROME_USER_MANAGER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_FAKE_CHROME_USER_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "chrome/browser/chromeos/login/user_flow.h" | 14 #include "chrome/browser/chromeos/login/user_flow.h" |
| 15 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" | 15 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" |
| 16 #include "components/prefs/testing_pref_service.h" |
| 16 #include "components/user_manager/fake_user_manager.h" | 17 #include "components/user_manager/fake_user_manager.h" |
| 17 #include "components/user_manager/user.h" | 18 #include "components/user_manager/user.h" |
| 18 #include "components/user_manager/user_image/user_image.h" | 19 #include "components/user_manager/user_image/user_image.h" |
| 19 | 20 |
| 20 namespace chromeos { | 21 namespace chromeos { |
| 21 | 22 |
| 22 class FakeSupervisedUserManager; | 23 class FakeSupervisedUserManager; |
| 23 | 24 |
| 24 // Fake chrome user manager with a barebones implementation. Users can be added | 25 // Fake chrome user manager with a barebones implementation. Users can be added |
| 25 // and set as logged in, and those users can be returned. | 26 // and set as logged in, and those users can be returned. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 37 // Calculates the user name hash and calls UserLoggedIn to login a user. | 38 // Calculates the user name hash and calls UserLoggedIn to login a user. |
| 38 // Sets the user as having its profile created, but does not create a profile. | 39 // Sets the user as having its profile created, but does not create a profile. |
| 39 // NOTE: This does not match production, which first logs in the user, then | 40 // NOTE: This does not match production, which first logs in the user, then |
| 40 // creates the profile and updates the user later. | 41 // creates the profile and updates the user later. |
| 41 void LoginUser(const AccountId& account_id); | 42 void LoginUser(const AccountId& account_id); |
| 42 | 43 |
| 43 const user_manager::User* AddUser(const AccountId& account_id); | 44 const user_manager::User* AddUser(const AccountId& account_id); |
| 44 const user_manager::User* AddUserWithAffiliation(const AccountId& account_id, | 45 const user_manager::User* AddUserWithAffiliation(const AccountId& account_id, |
| 45 bool is_affiliated); | 46 bool is_affiliated); |
| 46 | 47 |
| 48 // Creates the instance returned by |GetLocalState()| (which returns nullptr |
| 49 // by default). |
| 50 void CreateLocalState(); |
| 51 |
| 47 // user_manager::UserManager override. | 52 // user_manager::UserManager override. |
| 48 void Shutdown() override; | 53 void Shutdown() override; |
| 49 const user_manager::UserList& GetUsers() const override; | 54 const user_manager::UserList& GetUsers() const override; |
| 50 user_manager::UserList GetUsersAllowedForMultiProfile() const override; | 55 user_manager::UserList GetUsersAllowedForMultiProfile() const override; |
| 51 const user_manager::UserList& GetLoggedInUsers() const override; | 56 const user_manager::UserList& GetLoggedInUsers() const override; |
| 52 const user_manager::UserList& GetLRULoggedInUsers() const override; | 57 const user_manager::UserList& GetLRULoggedInUsers() const override; |
| 53 user_manager::UserList GetUnlockUsers() const override; | 58 user_manager::UserList GetUnlockUsers() const override; |
| 54 const AccountId& GetOwnerAccountId() const override; | 59 const AccountId& GetOwnerAccountId() const override; |
| 55 void UserLoggedIn(const AccountId& account_id, | 60 void UserLoggedIn(const AccountId& account_id, |
| 56 const std::string& user_id_hash, | 61 const std::string& user_id_hash, |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 | 204 |
| 200 // If set this is the active user. If empty, the first created user is the | 205 // If set this is the active user. If empty, the first created user is the |
| 201 // active user. | 206 // active user. |
| 202 AccountId active_account_id_ = EmptyAccountId(); | 207 AccountId active_account_id_ = EmptyAccountId(); |
| 203 | 208 |
| 204 // Lazy-initialized default flow. | 209 // Lazy-initialized default flow. |
| 205 mutable std::unique_ptr<UserFlow> default_flow_; | 210 mutable std::unique_ptr<UserFlow> default_flow_; |
| 206 | 211 |
| 207 using FlowMap = std::map<AccountId, UserFlow*>; | 212 using FlowMap = std::map<AccountId, UserFlow*>; |
| 208 | 213 |
| 214 std::unique_ptr<TestingPrefServiceSimple> local_state_; |
| 215 |
| 209 // Specific flows by user e-mail. | 216 // Specific flows by user e-mail. |
| 210 // Keys should be canonicalized before access. | 217 // Keys should be canonicalized before access. |
| 211 FlowMap specific_flows_; | 218 FlowMap specific_flows_; |
| 212 | 219 |
| 213 DISALLOW_COPY_AND_ASSIGN(FakeChromeUserManager); | 220 DISALLOW_COPY_AND_ASSIGN(FakeChromeUserManager); |
| 214 }; | 221 }; |
| 215 | 222 |
| 216 } // namespace chromeos | 223 } // namespace chromeos |
| 217 | 224 |
| 218 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_FAKE_CHROME_USER_MANAGER_H_ | 225 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_FAKE_CHROME_USER_MANAGER_H_ |
| OLD | NEW |