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

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

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