| OLD | NEW |
| 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 CHROME_BROWSER_CHROMEOS_LOGIN_USERS_FAKE_USER_MANAGER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_FAKE_USER_MANAGER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_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" | 12 #include "chrome/browser/chromeos/login/user_flow.h" |
| 13 #include "chrome/browser/chromeos/login/users/user_manager.h" | 13 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" |
| 14 #include "components/user_manager/user.h" | 14 #include "components/user_manager/user.h" |
| 15 #include "components/user_manager/user_image/user_image.h" | 15 #include "components/user_manager/user_image/user_image.h" |
| 16 | 16 |
| 17 namespace chromeos { | 17 namespace chromeos { |
| 18 | 18 |
| 19 class FakeSupervisedUserManager; | 19 class FakeSupervisedUserManager; |
| 20 | 20 |
| 21 // Fake user manager with a barebones implementation. Users can be added | 21 // Fake user manager with a barebones implementation. Users can be added |
| 22 // and set as logged in, and those users can be returned. | 22 // and set as logged in, and those users can be returned. |
| 23 class FakeUserManager : public UserManager { | 23 class FakeUserManager : public ChromeUserManager { |
| 24 public: | 24 public: |
| 25 FakeUserManager(); | 25 FakeUserManager(); |
| 26 virtual ~FakeUserManager(); | 26 virtual ~FakeUserManager(); |
| 27 | 27 |
| 28 // Create and add a new user. | 28 // Create and add a new user. |
| 29 const user_manager::User* AddUser(const std::string& email); | 29 const user_manager::User* AddUser(const std::string& email); |
| 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 std::string& kiosk_app_username); |
| 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 std::string& email); |
| 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 std::string& email); |
| 39 | 39 |
| 40 // ChromeUserManager overrides. |
| 41 virtual MultiProfileUserController* GetMultiProfileUserController() OVERRIDE; |
| 42 virtual UserImageManager* GetUserImageManager( |
| 43 const std::string& user_id) OVERRIDE; |
| 44 virtual SupervisedUserManager* GetSupervisedUserManager() OVERRIDE; |
| 45 virtual void SetUserFlow(const std::string& email, UserFlow* flow) OVERRIDE {} |
| 46 virtual UserFlow* GetCurrentUserFlow() const OVERRIDE; |
| 47 virtual UserFlow* GetUserFlow(const std::string& email) const OVERRIDE; |
| 48 virtual void ResetUserFlow(const std::string& email) OVERRIDE {} |
| 49 |
| 40 // UserManager overrides. | 50 // UserManager overrides. |
| 41 virtual const user_manager::UserList& GetUsers() const OVERRIDE; | 51 virtual const user_manager::UserList& GetUsers() const OVERRIDE; |
| 42 virtual user_manager::UserList GetUsersAdmittedForMultiProfile() | 52 virtual user_manager::UserList GetUsersAdmittedForMultiProfile() |
| 43 const OVERRIDE; | 53 const OVERRIDE; |
| 44 virtual const user_manager::UserList& GetLoggedInUsers() const OVERRIDE; | 54 virtual const user_manager::UserList& GetLoggedInUsers() const OVERRIDE; |
| 45 | 55 |
| 46 // Set the user as logged in. | 56 // Set the user as logged in. |
| 47 virtual void UserLoggedIn(const std::string& email, | 57 virtual void UserLoggedIn(const std::string& email, |
| 48 const std::string& username_hash, | 58 const std::string& username_hash, |
| 49 bool browser_restart) OVERRIDE; | 59 bool browser_restart) OVERRIDE; |
| 50 | 60 |
| 51 virtual const user_manager::User* GetActiveUser() const OVERRIDE; | 61 virtual const user_manager::User* GetActiveUser() const OVERRIDE; |
| 52 virtual user_manager::User* GetActiveUser() OVERRIDE; | 62 virtual user_manager::User* GetActiveUser() OVERRIDE; |
| 53 virtual void SwitchActiveUser(const std::string& email) OVERRIDE; | 63 virtual void SwitchActiveUser(const std::string& email) OVERRIDE; |
| 54 virtual void SaveUserDisplayName(const std::string& username, | 64 virtual void SaveUserDisplayName(const std::string& username, |
| 55 const base::string16& display_name) OVERRIDE; | 65 const base::string16& display_name) OVERRIDE; |
| 56 | 66 |
| 57 // Not implemented. | 67 // Not implemented. |
| 58 virtual void UpdateUserAccountData( | 68 virtual void UpdateUserAccountData( |
| 59 const std::string& user_id, | 69 const std::string& user_id, |
| 60 const UserAccountData& account_data) OVERRIDE {} | 70 const UserAccountData& account_data) OVERRIDE {} |
| 61 virtual void Shutdown() OVERRIDE {} | 71 virtual void Shutdown() OVERRIDE {} |
| 62 virtual MultiProfileUserController* GetMultiProfileUserController() OVERRIDE; | |
| 63 virtual UserImageManager* GetUserImageManager( | |
| 64 const std::string& user_id) OVERRIDE; | |
| 65 virtual SupervisedUserManager* GetSupervisedUserManager() OVERRIDE; | |
| 66 virtual const user_manager::UserList& GetLRULoggedInUsers() const OVERRIDE; | 72 virtual const user_manager::UserList& GetLRULoggedInUsers() const OVERRIDE; |
| 67 virtual user_manager::UserList GetUnlockUsers() const OVERRIDE; | 73 virtual user_manager::UserList GetUnlockUsers() const OVERRIDE; |
| 68 virtual const std::string& GetOwnerEmail() const OVERRIDE; | 74 virtual const std::string& GetOwnerEmail() const OVERRIDE; |
| 69 virtual void SessionStarted() OVERRIDE {} | 75 virtual void SessionStarted() OVERRIDE {} |
| 70 virtual void RemoveUser(const std::string& email, | 76 virtual void RemoveUser(const std::string& email, |
| 71 RemoveUserDelegate* delegate) OVERRIDE {} | 77 user_manager::RemoveUserDelegate* delegate) OVERRIDE { |
| 78 } |
| 72 virtual void RemoveUserFromList(const std::string& email) OVERRIDE; | 79 virtual void RemoveUserFromList(const std::string& email) OVERRIDE; |
| 73 virtual bool IsKnownUser(const std::string& email) const OVERRIDE; | 80 virtual bool IsKnownUser(const std::string& email) const OVERRIDE; |
| 74 virtual const user_manager::User* FindUser( | 81 virtual const user_manager::User* FindUser( |
| 75 const std::string& email) const OVERRIDE; | 82 const std::string& email) const OVERRIDE; |
| 76 virtual user_manager::User* FindUserAndModify( | 83 virtual user_manager::User* FindUserAndModify( |
| 77 const std::string& email) OVERRIDE; | 84 const std::string& email) OVERRIDE; |
| 78 virtual const user_manager::User* GetLoggedInUser() const OVERRIDE; | 85 virtual const user_manager::User* GetLoggedInUser() const OVERRIDE; |
| 79 virtual user_manager::User* GetLoggedInUser() OVERRIDE; | 86 virtual user_manager::User* GetLoggedInUser() OVERRIDE; |
| 80 virtual const user_manager::User* GetPrimaryUser() const OVERRIDE; | 87 virtual const user_manager::User* GetPrimaryUser() const OVERRIDE; |
| 81 virtual void SaveUserOAuthStatus( | 88 virtual void SaveUserOAuthStatus( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 97 virtual bool IsLoggedInAsRegularUser() const OVERRIDE; | 104 virtual bool IsLoggedInAsRegularUser() const OVERRIDE; |
| 98 virtual bool IsLoggedInAsDemoUser() const OVERRIDE; | 105 virtual bool IsLoggedInAsDemoUser() const OVERRIDE; |
| 99 virtual bool IsLoggedInAsPublicAccount() const OVERRIDE; | 106 virtual bool IsLoggedInAsPublicAccount() const OVERRIDE; |
| 100 virtual bool IsLoggedInAsGuest() const OVERRIDE; | 107 virtual bool IsLoggedInAsGuest() const OVERRIDE; |
| 101 virtual bool IsLoggedInAsSupervisedUser() const OVERRIDE; | 108 virtual bool IsLoggedInAsSupervisedUser() const OVERRIDE; |
| 102 virtual bool IsLoggedInAsKioskApp() const OVERRIDE; | 109 virtual bool IsLoggedInAsKioskApp() const OVERRIDE; |
| 103 virtual bool IsLoggedInAsStub() const OVERRIDE; | 110 virtual bool IsLoggedInAsStub() const OVERRIDE; |
| 104 virtual bool IsSessionStarted() const OVERRIDE; | 111 virtual bool IsSessionStarted() const OVERRIDE; |
| 105 virtual bool IsUserNonCryptohomeDataEphemeral( | 112 virtual bool IsUserNonCryptohomeDataEphemeral( |
| 106 const std::string& email) const OVERRIDE; | 113 const std::string& email) const OVERRIDE; |
| 107 virtual void SetUserFlow(const std::string& email, UserFlow* flow) OVERRIDE {} | |
| 108 virtual UserFlow* GetCurrentUserFlow() const OVERRIDE; | |
| 109 virtual UserFlow* GetUserFlow(const std::string& email) const OVERRIDE; | |
| 110 virtual void ResetUserFlow(const std::string& email) OVERRIDE {} | |
| 111 virtual void AddObserver(Observer* obs) OVERRIDE {} | 114 virtual void AddObserver(Observer* obs) OVERRIDE {} |
| 112 virtual void RemoveObserver(Observer* obs) OVERRIDE {} | 115 virtual void RemoveObserver(Observer* obs) OVERRIDE {} |
| 113 virtual void AddSessionStateObserver( | 116 virtual void AddSessionStateObserver( |
| 114 UserSessionStateObserver* obs) OVERRIDE {} | 117 UserSessionStateObserver* obs) OVERRIDE {} |
| 115 virtual void RemoveSessionStateObserver( | 118 virtual void RemoveSessionStateObserver( |
| 116 UserSessionStateObserver* obs) OVERRIDE {} | 119 UserSessionStateObserver* obs) OVERRIDE {} |
| 117 virtual void NotifyLocalStateChanged() OVERRIDE {} | 120 virtual void NotifyLocalStateChanged() OVERRIDE {} |
| 118 virtual bool AreSupervisedUsersAllowed() const OVERRIDE; | 121 virtual bool AreSupervisedUsersAllowed() const OVERRIDE; |
| 119 | 122 |
| 123 // UserManagerBase overrides: |
| 124 virtual bool AreEphemeralUsersEnabled() const OVERRIDE; |
| 125 virtual const std::string& GetApplicationLocale() const OVERRIDE; |
| 126 virtual PrefService* GetLocalState() const OVERRIDE; |
| 127 virtual void HandleUserOAuthTokenStatusChange( |
| 128 const std::string& user_id, |
| 129 user_manager::User::OAuthTokenStatus status) const OVERRIDE {} |
| 130 virtual bool IsEnterpriseManaged() const OVERRIDE; |
| 131 virtual void LoadPublicAccounts( |
| 132 std::set<std::string>* public_sessions_set) OVERRIDE {} |
| 133 virtual void PerformPreUserListLoadingActions() OVERRIDE {} |
| 134 virtual void PerformPostUserListLoadingActions() OVERRIDE {} |
| 135 virtual void PerformPostUserLoggedInActions(bool browser_restart) OVERRIDE {} |
| 136 virtual bool IsDemoApp(const std::string& user_id) const OVERRIDE; |
| 137 virtual bool IsKioskApp(const std::string& user_id) const OVERRIDE; |
| 138 virtual bool IsPublicAccountMarkedForRemoval( |
| 139 const std::string& user_id) const OVERRIDE; |
| 140 virtual void DemoAccountLoggedIn() OVERRIDE {} |
| 141 virtual void KioskAppLoggedIn(const std::string& app_id) OVERRIDE {} |
| 142 virtual void PublicAccountUserLoggedIn(user_manager::User* user) OVERRIDE {} |
| 143 virtual void RetailModeUserLoggedIn() OVERRIDE {} |
| 144 virtual void SupervisedUserLoggedIn(const std::string& user_id) OVERRIDE {} |
| 145 |
| 120 void set_owner_email(const std::string& owner_email) { | 146 void set_owner_email(const std::string& owner_email) { |
| 121 owner_email_ = owner_email; | 147 owner_email_ = owner_email; |
| 122 } | 148 } |
| 123 | 149 |
| 124 void set_multi_profile_user_controller( | 150 void set_multi_profile_user_controller( |
| 125 MultiProfileUserController* controller) { | 151 MultiProfileUserController* controller) { |
| 126 multi_profile_user_controller_ = controller; | 152 multi_profile_user_controller_ = controller; |
| 127 } | 153 } |
| 128 | 154 |
| 129 private: | 155 private: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 140 // active user. | 166 // active user. |
| 141 std::string active_user_id_; | 167 std::string active_user_id_; |
| 142 MultiProfileUserController* multi_profile_user_controller_; | 168 MultiProfileUserController* multi_profile_user_controller_; |
| 143 | 169 |
| 144 DISALLOW_COPY_AND_ASSIGN(FakeUserManager); | 170 DISALLOW_COPY_AND_ASSIGN(FakeUserManager); |
| 145 }; | 171 }; |
| 146 | 172 |
| 147 } // namespace chromeos | 173 } // namespace chromeos |
| 148 | 174 |
| 149 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_FAKE_USER_MANAGER_H_ | 175 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_FAKE_USER_MANAGER_H_ |
| OLD | NEW |