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 COMPONENTS_USER_MANAGER_USER_MANAGER_BASE_H_ | 5 #ifndef COMPONENTS_USER_MANAGER_USER_MANAGER_BASE_H_ |
6 #define COMPONENTS_USER_MANAGER_USER_MANAGER_BASE_H_ | 6 #define COMPONENTS_USER_MANAGER_USER_MANAGER_BASE_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 class RemoveUserDelegate; | 32 class RemoveUserDelegate; |
33 | 33 |
34 // Base implementation of the UserManager interface. | 34 // Base implementation of the UserManager interface. |
35 class USER_MANAGER_EXPORT UserManagerBase : public UserManager { | 35 class USER_MANAGER_EXPORT UserManagerBase : public UserManager { |
36 public: | 36 public: |
37 // Creates UserManagerBase with |task_runner| for UI thread and | 37 // Creates UserManagerBase with |task_runner| for UI thread and |
38 // |blocking_task_runner| for SequencedWorkerPool. | 38 // |blocking_task_runner| for SequencedWorkerPool. |
39 UserManagerBase(scoped_refptr<base::TaskRunner> task_runner, | 39 UserManagerBase(scoped_refptr<base::TaskRunner> task_runner, |
40 scoped_refptr<base::TaskRunner> blocking_task_runner); | 40 scoped_refptr<base::TaskRunner> blocking_task_runner); |
41 virtual ~UserManagerBase(); | 41 ~UserManagerBase() override; |
42 | 42 |
43 // Registers UserManagerBase preferences. | 43 // Registers UserManagerBase preferences. |
44 static void RegisterPrefs(PrefRegistrySimple* registry); | 44 static void RegisterPrefs(PrefRegistrySimple* registry); |
45 | 45 |
46 // UserManager implementation: | 46 // UserManager implementation: |
47 virtual void Shutdown() override; | 47 void Shutdown() override; |
48 virtual const UserList& GetUsers() const override; | 48 const UserList& GetUsers() const override; |
49 virtual const UserList& GetLoggedInUsers() const override; | 49 const UserList& GetLoggedInUsers() const override; |
50 virtual const UserList& GetLRULoggedInUsers() const override; | 50 const UserList& GetLRULoggedInUsers() const override; |
51 virtual const std::string& GetOwnerEmail() const override; | 51 const std::string& GetOwnerEmail() const override; |
52 virtual void UserLoggedIn(const std::string& user_id, | 52 void UserLoggedIn(const std::string& user_id, |
53 const std::string& user_id_hash, | 53 const std::string& user_id_hash, |
54 bool browser_restart) override; | 54 bool browser_restart) override; |
55 virtual void SwitchActiveUser(const std::string& user_id) override; | 55 void SwitchActiveUser(const std::string& user_id) override; |
56 virtual void SwitchToLastActiveUser() override; | 56 void SwitchToLastActiveUser() override; |
57 virtual void SessionStarted() override; | 57 void SessionStarted() override; |
58 virtual void RemoveUser(const std::string& user_id, | 58 void RemoveUser(const std::string& user_id, |
59 RemoveUserDelegate* delegate) override; | 59 RemoveUserDelegate* delegate) override; |
60 virtual void RemoveUserFromList(const std::string& user_id) override; | 60 void RemoveUserFromList(const std::string& user_id) override; |
61 virtual bool IsKnownUser(const std::string& user_id) const override; | 61 bool IsKnownUser(const std::string& user_id) const override; |
62 virtual const User* FindUser(const std::string& user_id) const override; | 62 const User* FindUser(const std::string& user_id) const override; |
63 virtual User* FindUserAndModify(const std::string& user_id) override; | 63 User* FindUserAndModify(const std::string& user_id) override; |
64 virtual const User* GetLoggedInUser() const override; | 64 const User* GetLoggedInUser() const override; |
65 virtual User* GetLoggedInUser() override; | 65 User* GetLoggedInUser() override; |
66 virtual const User* GetActiveUser() const override; | 66 const User* GetActiveUser() const override; |
67 virtual User* GetActiveUser() override; | 67 User* GetActiveUser() override; |
68 virtual const User* GetPrimaryUser() const override; | 68 const User* GetPrimaryUser() const override; |
69 virtual void SaveUserOAuthStatus( | 69 void SaveUserOAuthStatus( |
70 const std::string& user_id, | 70 const std::string& user_id, |
71 User::OAuthTokenStatus oauth_token_status) override; | 71 User::OAuthTokenStatus oauth_token_status) override; |
72 virtual void SaveForceOnlineSignin(const std::string& user_id, | 72 void SaveForceOnlineSignin(const std::string& user_id, |
73 bool force_online_signin) override; | 73 bool force_online_signin) override; |
74 virtual void SaveUserDisplayName(const std::string& user_id, | 74 void SaveUserDisplayName(const std::string& user_id, |
75 const base::string16& display_name) override; | 75 const base::string16& display_name) override; |
76 virtual base::string16 GetUserDisplayName( | 76 base::string16 GetUserDisplayName( |
77 const std::string& user_id) const override; | 77 const std::string& user_id) const override; |
78 virtual void SaveUserDisplayEmail(const std::string& user_id, | 78 void SaveUserDisplayEmail(const std::string& user_id, |
79 const std::string& display_email) override; | 79 const std::string& display_email) override; |
80 virtual std::string GetUserDisplayEmail( | 80 std::string GetUserDisplayEmail( |
81 const std::string& user_id) const override; | 81 const std::string& user_id) const override; |
82 virtual void SaveUserType(const std::string& user_id, | 82 void SaveUserType(const std::string& user_id, |
83 const UserType& user_type) override; | 83 const UserType& user_type) override; |
84 virtual void UpdateUserAccountData( | 84 void UpdateUserAccountData( |
85 const std::string& user_id, | 85 const std::string& user_id, |
86 const UserAccountData& account_data) override; | 86 const UserAccountData& account_data) override; |
87 virtual bool IsCurrentUserOwner() const override; | 87 bool IsCurrentUserOwner() const override; |
88 virtual bool IsCurrentUserNew() const override; | 88 bool IsCurrentUserNew() const override; |
89 virtual bool IsCurrentUserNonCryptohomeDataEphemeral() const override; | 89 bool IsCurrentUserNonCryptohomeDataEphemeral() const override; |
90 virtual bool CanCurrentUserLock() const override; | 90 bool CanCurrentUserLock() const override; |
91 virtual bool IsUserLoggedIn() const override; | 91 bool IsUserLoggedIn() const override; |
92 virtual bool IsLoggedInAsUserWithGaiaAccount() const override; | 92 bool IsLoggedInAsUserWithGaiaAccount() const override; |
93 virtual bool IsLoggedInAsChildUser() const override; | 93 bool IsLoggedInAsChildUser() const override; |
94 virtual bool IsLoggedInAsPublicAccount() const override; | 94 bool IsLoggedInAsPublicAccount() const override; |
95 virtual bool IsLoggedInAsGuest() const override; | 95 bool IsLoggedInAsGuest() const override; |
96 virtual bool IsLoggedInAsSupervisedUser() const override; | 96 bool IsLoggedInAsSupervisedUser() const override; |
97 virtual bool IsLoggedInAsKioskApp() const override; | 97 bool IsLoggedInAsKioskApp() const override; |
98 virtual bool IsLoggedInAsStub() const override; | 98 bool IsLoggedInAsStub() const override; |
99 virtual bool IsSessionStarted() const override; | 99 bool IsSessionStarted() const override; |
100 virtual bool IsUserNonCryptohomeDataEphemeral( | 100 bool IsUserNonCryptohomeDataEphemeral( |
101 const std::string& user_id) const override; | 101 const std::string& user_id) const override; |
102 virtual void AddObserver(UserManager::Observer* obs) override; | 102 void AddObserver(UserManager::Observer* obs) override; |
103 virtual void RemoveObserver(UserManager::Observer* obs) override; | 103 void RemoveObserver(UserManager::Observer* obs) override; |
104 virtual void AddSessionStateObserver( | 104 void AddSessionStateObserver( |
105 UserManager::UserSessionStateObserver* obs) override; | 105 UserManager::UserSessionStateObserver* obs) override; |
106 virtual void RemoveSessionStateObserver( | 106 void RemoveSessionStateObserver( |
107 UserManager::UserSessionStateObserver* obs) override; | 107 UserManager::UserSessionStateObserver* obs) override; |
108 virtual void NotifyLocalStateChanged() override; | 108 void NotifyLocalStateChanged() override; |
109 virtual void ChangeUserChildStatus(User* user, bool is_child) override; | 109 void ChangeUserChildStatus(User* user, bool is_child) override; |
110 | 110 |
111 // Helper function that copies users from |users_list| to |users_vector| and | 111 // Helper function that copies users from |users_list| to |users_vector| and |
112 // |users_set|. Duplicates and users already present in |existing_users| are | 112 // |users_set|. Duplicates and users already present in |existing_users| are |
113 // skipped. | 113 // skipped. |
114 static void ParseUserList(const base::ListValue& users_list, | 114 static void ParseUserList(const base::ListValue& users_list, |
115 const std::set<std::string>& existing_users, | 115 const std::set<std::string>& existing_users, |
116 std::vector<std::string>* users_vector, | 116 std::vector<std::string>* users_vector, |
117 std::set<std::string>* users_set); | 117 std::set<std::string>* users_set); |
118 | 118 |
119 protected: | 119 protected: |
(...skipping 13 matching lines...) Expand all Loading... |
133 virtual void DeleteUser(User* user); | 133 virtual void DeleteUser(User* user); |
134 | 134 |
135 // Returns the locale used by the application. | 135 // Returns the locale used by the application. |
136 virtual const std::string& GetApplicationLocale() const = 0; | 136 virtual const std::string& GetApplicationLocale() const = 0; |
137 | 137 |
138 // Returns "Local State" PrefService instance. | 138 // Returns "Local State" PrefService instance. |
139 virtual PrefService* GetLocalState() const = 0; | 139 virtual PrefService* GetLocalState() const = 0; |
140 | 140 |
141 // Loads |users_| from Local State if the list has not been loaded yet. | 141 // Loads |users_| from Local State if the list has not been loaded yet. |
142 // Subsequent calls have no effect. Must be called on the UI thread. | 142 // Subsequent calls have no effect. Must be called on the UI thread. |
143 void EnsureUsersLoaded(); | 143 virtual void EnsureUsersLoaded(); |
144 | 144 |
145 // Handle OAuth token |status| change for |user_id|. | 145 // Handle OAuth token |status| change for |user_id|. |
146 virtual void HandleUserOAuthTokenStatusChange( | 146 virtual void HandleUserOAuthTokenStatusChange( |
147 const std::string& user_id, | 147 const std::string& user_id, |
148 User::OAuthTokenStatus status) const = 0; | 148 User::OAuthTokenStatus status) const = 0; |
149 | 149 |
150 // Returns true if device is enterprise managed. | 150 // Returns true if device is enterprise managed. |
151 virtual bool IsEnterpriseManaged() const = 0; | 151 virtual bool IsEnterpriseManaged() const = 0; |
152 | 152 |
153 // Helper function that copies users from |users_list| to |users_vector| and | 153 // Helper function that copies users from |users_list| to |users_vector| and |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 scoped_refptr<base::TaskRunner> blocking_task_runner_; | 383 scoped_refptr<base::TaskRunner> blocking_task_runner_; |
384 | 384 |
385 base::WeakPtrFactory<UserManagerBase> weak_factory_; | 385 base::WeakPtrFactory<UserManagerBase> weak_factory_; |
386 | 386 |
387 DISALLOW_COPY_AND_ASSIGN(UserManagerBase); | 387 DISALLOW_COPY_AND_ASSIGN(UserManagerBase); |
388 }; | 388 }; |
389 | 389 |
390 } // namespace user_manager | 390 } // namespace user_manager |
391 | 391 |
392 #endif // COMPONENTS_USER_MANAGER_USER_MANAGER_BASE_H_ | 392 #endif // COMPONENTS_USER_MANAGER_USER_MANAGER_BASE_H_ |
OLD | NEW |