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

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

Issue 1425093004: Revert of This CL replaces user_manager::UserID with AccountId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@468875--Chrome-OS-handles-deletion-of-Gmail-account-poorly--Create-AccountID-structure-part2--user_names
Patch Set: Created 5 years, 1 month 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 COMPONENTS_USER_MANAGER_FAKE_USER_MANAGER_H_ 5 #ifndef COMPONENTS_USER_MANAGER_FAKE_USER_MANAGER_H_
6 #define COMPONENTS_USER_MANAGER_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 "components/signin/core/account_id/account_id.h"
13 #include "components/user_manager/user.h" 12 #include "components/user_manager/user.h"
14 #include "components/user_manager/user_manager_base.h" 13 #include "components/user_manager/user_manager_base.h"
15 14
16 namespace user_manager { 15 namespace user_manager {
17 16
18 // Fake user manager with a barebones implementation. Users can be added 17 // Fake user manager with a barebones implementation. Users can be added
19 // and set as logged in, and those users can be returned. 18 // and set as logged in, and those users can be returned.
20 class USER_MANAGER_EXPORT FakeUserManager : public UserManagerBase { 19 class USER_MANAGER_EXPORT FakeUserManager : public UserManagerBase {
21 public: 20 public:
22 FakeUserManager(); 21 FakeUserManager();
23 ~FakeUserManager() override; 22 ~FakeUserManager() override;
24 23
25 // Create and add a new user. Created user is not affiliated with the domain, 24 // Create and add a new user. Created user is not affiliated with the domain,
26 // that owns the device. 25 // that owns the device.
27 virtual const user_manager::User* AddUser(const AccountId& account_id); 26 virtual const user_manager::User* AddUser(const std::string& email);
28 27
29 // The same as AddUser() but allows to specify user affiliation with the 28 // The same as AddUser() but allows to specify user affiliation with the
30 // domain, that owns the device. 29 // domain, that owns the device.
31 virtual const user_manager::User* AddUserWithAffiliation( 30 virtual const user_manager::User* AddUserWithAffiliation(
32 const AccountId& account_id, 31 const std::string& email, bool is_affiliated);
33 bool is_affiliated);
34 32
35 // Calculates the user name hash and calls UserLoggedIn to login a user. 33 // Calculates the user name hash and calls UserLoggedIn to login a user.
36 void LoginUser(const AccountId& account_id); 34 void LoginUser(const std::string& email);
37 35
38 // UserManager overrides. 36 // UserManager overrides.
39 const user_manager::UserList& GetUsers() const override; 37 const user_manager::UserList& GetUsers() const override;
40 user_manager::UserList GetUsersAllowedForMultiProfile() const override; 38 user_manager::UserList GetUsersAllowedForMultiProfile() const override;
41 const user_manager::UserList& GetLoggedInUsers() const override; 39 const user_manager::UserList& GetLoggedInUsers() const override;
42 40
43 // Set the user as logged in. 41 // Set the user as logged in.
44 void UserLoggedIn(const AccountId& account_id, 42 void UserLoggedIn(const std::string& email,
45 const std::string& username_hash, 43 const std::string& username_hash,
46 bool browser_restart) override; 44 bool browser_restart) override;
47 45
48 const user_manager::User* GetActiveUser() const override; 46 const user_manager::User* GetActiveUser() const override;
49 user_manager::User* GetActiveUser() override; 47 user_manager::User* GetActiveUser() override;
50 void SwitchActiveUser(const AccountId& account_id) override; 48 void SwitchActiveUser(const std::string& email) override;
51 void SaveUserDisplayName(const AccountId& account_id, 49 void SaveUserDisplayName(const std::string& username,
52 const base::string16& display_name) override; 50 const base::string16& display_name) override;
53 51
54 // Not implemented. 52 // Not implemented.
55 void UpdateUserAccountData(const AccountId& account_id, 53 void UpdateUserAccountData(const std::string& user_id,
56 const UserAccountData& account_data) override {} 54 const UserAccountData& account_data) override {}
57 void Shutdown() override {} 55 void Shutdown() override {}
58 const user_manager::UserList& GetLRULoggedInUsers() const override; 56 const user_manager::UserList& GetLRULoggedInUsers() const override;
59 user_manager::UserList GetUnlockUsers() const override; 57 user_manager::UserList GetUnlockUsers() const override;
60 const AccountId& GetOwnerAccountId() const override; 58 const std::string& GetOwnerEmail() const override;
61 void SessionStarted() override {} 59 void SessionStarted() override {}
62 void RemoveUser(const AccountId& account_id, 60 void RemoveUser(const std::string& email,
63 user_manager::RemoveUserDelegate* delegate) override {} 61 user_manager::RemoveUserDelegate* delegate) override {}
64 void RemoveUserFromList(const AccountId& account_id) override; 62 void RemoveUserFromList(const std::string& email) override;
65 bool IsKnownUser(const AccountId& account_id) const override; 63 bool IsKnownUser(const std::string& email) const override;
66 const user_manager::User* FindUser( 64 const user_manager::User* FindUser(const std::string& email) const override;
67 const AccountId& account_id) const override; 65 user_manager::User* FindUserAndModify(const std::string& email) override;
68 user_manager::User* FindUserAndModify(const AccountId& account_id) override;
69 const user_manager::User* GetLoggedInUser() const override; 66 const user_manager::User* GetLoggedInUser() const override;
70 user_manager::User* GetLoggedInUser() override; 67 user_manager::User* GetLoggedInUser() override;
71 const user_manager::User* GetPrimaryUser() const override; 68 const user_manager::User* GetPrimaryUser() const override;
72 void SaveUserOAuthStatus( 69 void SaveUserOAuthStatus(
73 const AccountId& account_id, 70 const std::string& username,
74 user_manager::User::OAuthTokenStatus oauth_token_status) override {} 71 user_manager::User::OAuthTokenStatus oauth_token_status) override {}
75 void SaveForceOnlineSignin(const AccountId& account_id, 72 void SaveForceOnlineSignin(const std::string& user_id,
76 bool force_online_signin) override {} 73 bool force_online_signin) override {}
77 base::string16 GetUserDisplayName(const AccountId& account_id) const override; 74 base::string16 GetUserDisplayName(const std::string& username) const override;
78 void SaveUserDisplayEmail(const AccountId& account_id, 75 void SaveUserDisplayEmail(const std::string& username,
79 const std::string& display_email) override {} 76 const std::string& display_email) override {}
80 std::string GetUserDisplayEmail(const AccountId& account_id) const override; 77 std::string GetUserDisplayEmail(const std::string& username) const override;
81 bool IsCurrentUserOwner() const override; 78 bool IsCurrentUserOwner() const override;
82 bool IsCurrentUserNew() const override; 79 bool IsCurrentUserNew() const override;
83 bool IsCurrentUserNonCryptohomeDataEphemeral() const override; 80 bool IsCurrentUserNonCryptohomeDataEphemeral() const override;
84 bool CanCurrentUserLock() const override; 81 bool CanCurrentUserLock() const override;
85 bool IsUserLoggedIn() const override; 82 bool IsUserLoggedIn() const override;
86 bool IsLoggedInAsUserWithGaiaAccount() const override; 83 bool IsLoggedInAsUserWithGaiaAccount() const override;
87 bool IsLoggedInAsPublicAccount() const override; 84 bool IsLoggedInAsPublicAccount() const override;
88 bool IsLoggedInAsGuest() const override; 85 bool IsLoggedInAsGuest() const override;
89 bool IsLoggedInAsSupervisedUser() const override; 86 bool IsLoggedInAsSupervisedUser() const override;
90 bool IsLoggedInAsKioskApp() const override; 87 bool IsLoggedInAsKioskApp() const override;
91 bool IsLoggedInAsStub() const override; 88 bool IsLoggedInAsStub() const override;
92 bool IsSessionStarted() const override; 89 bool IsSessionStarted() const override;
93 bool IsUserNonCryptohomeDataEphemeral( 90 bool IsUserNonCryptohomeDataEphemeral(
94 const AccountId& account_id) const override; 91 const std::string& email) const override;
95 void AddObserver(Observer* obs) override {} 92 void AddObserver(Observer* obs) override {}
96 void RemoveObserver(Observer* obs) override {} 93 void RemoveObserver(Observer* obs) override {}
97 void AddSessionStateObserver(UserSessionStateObserver* obs) override {} 94 void AddSessionStateObserver(UserSessionStateObserver* obs) override {}
98 void RemoveSessionStateObserver(UserSessionStateObserver* obs) override {} 95 void RemoveSessionStateObserver(UserSessionStateObserver* obs) override {}
99 void NotifyLocalStateChanged() override {} 96 void NotifyLocalStateChanged() override {}
100 bool AreSupervisedUsersAllowed() const override; 97 bool AreSupervisedUsersAllowed() const override;
101 98
102 // UserManagerBase overrides: 99 // UserManagerBase overrides:
103 bool AreEphemeralUsersEnabled() const override; 100 bool AreEphemeralUsersEnabled() const override;
104 const std::string& GetApplicationLocale() const override; 101 const std::string& GetApplicationLocale() const override;
105 PrefService* GetLocalState() const override; 102 PrefService* GetLocalState() const override;
106 void HandleUserOAuthTokenStatusChange( 103 void HandleUserOAuthTokenStatusChange(
107 const AccountId& account_id, 104 const std::string& user_id,
108 user_manager::User::OAuthTokenStatus status) const override {} 105 user_manager::User::OAuthTokenStatus status) const override {}
109 bool IsEnterpriseManaged() const override; 106 bool IsEnterpriseManaged() const override;
110 void LoadPublicAccounts(std::set<AccountId>* public_sessions_set) override {} 107 void LoadPublicAccounts(std::set<std::string>* public_sessions_set) override {
108 }
111 void PerformPreUserListLoadingActions() override {} 109 void PerformPreUserListLoadingActions() override {}
112 void PerformPostUserListLoadingActions() override {} 110 void PerformPostUserListLoadingActions() override {}
113 void PerformPostUserLoggedInActions(bool browser_restart) override {} 111 void PerformPostUserLoggedInActions(bool browser_restart) override {}
114 bool IsDemoApp(const AccountId& account_id) const override; 112 bool IsDemoApp(const std::string& user_id) const override;
115 bool IsKioskApp(const AccountId& account_id) const override; 113 bool IsKioskApp(const std::string& user_id) const override;
116 bool IsPublicAccountMarkedForRemoval( 114 bool IsPublicAccountMarkedForRemoval(
117 const AccountId& account_id) const override; 115 const std::string& user_id) const override;
118 void DemoAccountLoggedIn() override {} 116 void DemoAccountLoggedIn() override {}
119 void KioskAppLoggedIn(const AccountId& kiosk_app_account_id) override {} 117 void KioskAppLoggedIn(const std::string& app_id) override {}
120 void PublicAccountUserLoggedIn(user_manager::User* user) override {} 118 void PublicAccountUserLoggedIn(user_manager::User* user) override {}
121 void SupervisedUserLoggedIn(const AccountId& account_id) override {} 119 void SupervisedUserLoggedIn(const std::string& user_id) override {}
122 void OnUserRemoved(const AccountId& account_id) override {} 120 void OnUserRemoved(const std::string& user_id) override {}
123 121
124 protected: 122 protected:
125 user_manager::User* primary_user_; 123 user_manager::User* primary_user_;
126 124
127 // If set this is the active user. If empty, the first created user is the 125 // If set this is the active user. If empty, the first created user is the
128 // active user. 126 // active user.
129 AccountId active_account_id_ = EmptyAccountId(); 127 std::string active_user_id_;
130 128
131 private: 129 private:
132 // We use this internal function for const-correctness. 130 // We use this internal function for const-correctness.
133 user_manager::User* GetActiveUserInternal() const; 131 user_manager::User* GetActiveUserInternal() const;
134 132
135 // stub, always empty. 133 // stub, always empty string.
136 AccountId owner_account_id_ = EmptyAccountId(); 134 std::string owner_email_;
137 135
138 DISALLOW_COPY_AND_ASSIGN(FakeUserManager); 136 DISALLOW_COPY_AND_ASSIGN(FakeUserManager);
139 }; 137 };
140 138
141 } // namespace user_manager 139 } // namespace user_manager
142 140
143 #endif // COMPONENTS_USER_MANAGER_FAKE_USER_MANAGER_H_ 141 #endif // COMPONENTS_USER_MANAGER_FAKE_USER_MANAGER_H_
OLDNEW
« no previous file with comments | « components/user_manager/empty_user_info.cc ('k') | components/user_manager/fake_user_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698