| 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 <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 // Fake chrome user manager with a barebones implementation. Users can be added | 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. | 24 // and set as logged in, and those users can be returned. |
| 25 class FakeChromeUserManager : public user_manager::FakeUserManager, | 25 class FakeChromeUserManager : public user_manager::FakeUserManager, |
| 26 public UserManagerInterface { | 26 public UserManagerInterface { |
| 27 public: | 27 public: |
| 28 FakeChromeUserManager(); | 28 FakeChromeUserManager(); |
| 29 ~FakeChromeUserManager() override; | 29 ~FakeChromeUserManager() override; |
| 30 | 30 |
| 31 // Create and add a kiosk app user. | 31 // Create and add a kiosk app user. |
| 32 void AddKioskAppUser(const std::string& kiosk_app_username); | 32 void AddKioskAppUser(const AccountId& kiosk_app_account_id); |
| 33 | 33 |
| 34 // Create and add a public account user. | 34 // Create and add a public account user. |
| 35 const user_manager::User* AddPublicAccountUser(const std::string& email); | 35 const user_manager::User* AddPublicAccountUser(const AccountId& account_id); |
| 36 | 36 |
| 37 // Calculates the user name hash and calls UserLoggedIn to login a user. | 37 // Calculates the user name hash and calls UserLoggedIn to login a user. |
| 38 void LoginUser(const std::string& email); | 38 void LoginUser(const AccountId& account_id); |
| 39 | 39 |
| 40 // UserManager overrides. | 40 // UserManager overrides. |
| 41 user_manager::UserList GetUsersAllowedForMultiProfile() const override; | 41 user_manager::UserList GetUsersAllowedForMultiProfile() const override; |
| 42 | 42 |
| 43 // user_manager::FakeUserManager override. | 43 // user_manager::FakeUserManager override. |
| 44 const user_manager::User* AddUser(const std::string& email) override; | 44 const user_manager::User* AddUser(const AccountId& account_id) override; |
| 45 const user_manager::User* AddUserWithAffiliation(const std::string& email, | 45 const user_manager::User* AddUserWithAffiliation(const AccountId& account_id, |
| 46 bool is_affiliated) override; | 46 bool is_affiliated) override; |
| 47 | 47 |
| 48 // UserManagerInterface implementation. | 48 // UserManagerInterface implementation. |
| 49 BootstrapManager* GetBootstrapManager() override; | 49 BootstrapManager* GetBootstrapManager() override; |
| 50 MultiProfileUserController* GetMultiProfileUserController() override; | 50 MultiProfileUserController* GetMultiProfileUserController() override; |
| 51 UserImageManager* GetUserImageManager(const std::string& user_id) override; | 51 UserImageManager* GetUserImageManager(const AccountId& account_id) override; |
| 52 SupervisedUserManager* GetSupervisedUserManager() override; | 52 SupervisedUserManager* GetSupervisedUserManager() override; |
| 53 void SetUserFlow(const std::string& email, UserFlow* flow) override; | 53 void SetUserFlow(const AccountId& account_id, UserFlow* flow) override; |
| 54 UserFlow* GetCurrentUserFlow() const override; | 54 UserFlow* GetCurrentUserFlow() const override; |
| 55 UserFlow* GetUserFlow(const std::string& email) const override; | 55 UserFlow* GetUserFlow(const AccountId& account_id) const override; |
| 56 void ResetUserFlow(const std::string& email) override; | 56 void ResetUserFlow(const AccountId& account_id) override; |
| 57 user_manager::UserList GetUsersAllowedForSupervisedUsersCreation() | 57 user_manager::UserList GetUsersAllowedForSupervisedUsersCreation() |
| 58 const override; | 58 const override; |
| 59 void SwitchActiveUser(const std::string& email) override; | 59 void SwitchActiveUser(const AccountId& account_id) override; |
| 60 const std::string& GetOwnerEmail() const override; | 60 const AccountId& GetOwnerAccountId() const override; |
| 61 void SessionStarted() override; | 61 void SessionStarted() override; |
| 62 void RemoveUser(const std::string& email, | 62 void RemoveUser(const AccountId& account_id, |
| 63 user_manager::RemoveUserDelegate* delegate) override; | 63 user_manager::RemoveUserDelegate* delegate) override; |
| 64 bool FindKnownUserPrefs(const user_manager::UserID& user_id, | 64 bool FindKnownUserPrefs(const AccountId& account_id, |
| 65 const base::DictionaryValue** out_value) override; | 65 const base::DictionaryValue** out_value) override; |
| 66 void UpdateKnownUserPrefs(const user_manager::UserID& user_id, | 66 void UpdateKnownUserPrefs(const AccountId& account_id, |
| 67 const base::DictionaryValue& values, | 67 const base::DictionaryValue& values, |
| 68 bool clear) override; | 68 bool clear) override; |
| 69 | 69 |
| 70 void set_owner_email(const std::string& owner_email) { | 70 void set_owner_id(const AccountId& owner_account_id) { |
| 71 owner_email_ = owner_email; | 71 owner_account_id_ = owner_account_id; |
| 72 } | 72 } |
| 73 | 73 |
| 74 void set_bootstrap_manager(BootstrapManager* bootstrap_manager) { | 74 void set_bootstrap_manager(BootstrapManager* bootstrap_manager) { |
| 75 bootstrap_manager_ = bootstrap_manager; | 75 bootstrap_manager_ = bootstrap_manager; |
| 76 } | 76 } |
| 77 | 77 |
| 78 void set_multi_profile_user_controller( | 78 void set_multi_profile_user_controller( |
| 79 MultiProfileUserController* controller) { | 79 MultiProfileUserController* controller) { |
| 80 multi_profile_user_controller_ = controller; | 80 multi_profile_user_controller_ = controller; |
| 81 } | 81 } |
| 82 | 82 |
| 83 private: | 83 private: |
| 84 // Lazily creates default user flow. | 84 // Lazily creates default user flow. |
| 85 UserFlow* GetDefaultUserFlow() const; | 85 UserFlow* GetDefaultUserFlow() const; |
| 86 | 86 |
| 87 scoped_ptr<FakeSupervisedUserManager> supervised_user_manager_; | 87 scoped_ptr<FakeSupervisedUserManager> supervised_user_manager_; |
| 88 std::string owner_email_; | 88 AccountId owner_account_id_ = EmptyAccountId(); |
| 89 | 89 |
| 90 BootstrapManager* bootstrap_manager_; | 90 BootstrapManager* bootstrap_manager_; |
| 91 MultiProfileUserController* multi_profile_user_controller_; | 91 MultiProfileUserController* multi_profile_user_controller_; |
| 92 | 92 |
| 93 typedef std::map<std::string, UserFlow*> FlowMap; | |
| 94 | |
| 95 // Lazy-initialized default flow. | 93 // Lazy-initialized default flow. |
| 96 mutable scoped_ptr<UserFlow> default_flow_; | 94 mutable scoped_ptr<UserFlow> default_flow_; |
| 97 | 95 |
| 96 using FlowMap = std::map<AccountId, UserFlow*>; |
| 97 |
| 98 // Specific flows by user e-mail. | 98 // Specific flows by user e-mail. |
| 99 // Keys should be canonicalized before access. | 99 // Keys should be canonicalized before access. |
| 100 FlowMap specific_flows_; | 100 FlowMap specific_flows_; |
| 101 | 101 |
| 102 DISALLOW_COPY_AND_ASSIGN(FakeChromeUserManager); | 102 DISALLOW_COPY_AND_ASSIGN(FakeChromeUserManager); |
| 103 }; | 103 }; |
| 104 | 104 |
| 105 } // namespace chromeos | 105 } // namespace chromeos |
| 106 | 106 |
| 107 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_FAKE_CHROME_USER_MANAGER_H_ | 107 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_FAKE_CHROME_USER_MANAGER_H_ |
| OLD | NEW |