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

Side by Side Diff: chrome/browser/chromeos/login/user_manager_impl.h

Issue 11419184: Add public accounts to UserManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Re-upload against the correct upstream commit. Created 8 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_USER_MANAGER_IMPL_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_
7 7
8 #include <set>
8 #include <string> 9 #include <string>
10 #include <vector>
9 11
10 #include "base/basictypes.h" 12 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/singleton.h" 14 #include "base/memory/singleton.h"
15 #include "base/memory/weak_ptr.h"
13 #include "base/observer_list.h" 16 #include "base/observer_list.h"
14 #include "base/synchronization/lock.h" 17 #include "base/synchronization/lock.h"
18 #include "base/values.h"
15 #include "chrome/browser/api/sync/profile_sync_service_observer.h" 19 #include "chrome/browser/api/sync/profile_sync_service_observer.h"
16 #include "chrome/browser/chromeos/login/user.h" 20 #include "chrome/browser/chromeos/login/user.h"
17 #include "chrome/browser/chromeos/login/user_image_manager_impl.h" 21 #include "chrome/browser/chromeos/login/user_image_manager_impl.h"
18 #include "chrome/browser/chromeos/login/user_manager.h" 22 #include "chrome/browser/chromeos/login/user_manager.h"
19 #include "chrome/browser/chromeos/login/wallpaper_manager.h" 23 #include "chrome/browser/chromeos/login/wallpaper_manager.h"
24 #include "chrome/browser/chromeos/settings/cros_settings.h"
20 #include "chrome/browser/chromeos/settings/device_settings_service.h" 25 #include "chrome/browser/chromeos/settings/device_settings_service.h"
21 #include "content/public/browser/notification_observer.h" 26 #include "content/public/browser/notification_observer.h"
22 #include "content/public/browser/notification_registrar.h" 27 #include "content/public/browser/notification_registrar.h"
23 28
24 class FilePath; 29 class FilePath;
25 class PrefService; 30 class PrefService;
26 class ProfileSyncService; 31 class ProfileSyncService;
27 32
28 namespace chromeos { 33 namespace chromeos {
29 34
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 const std::string& username) const OVERRIDE; 66 const std::string& username) const OVERRIDE;
62 virtual void SaveUserDisplayEmail(const std::string& username, 67 virtual void SaveUserDisplayEmail(const std::string& username,
63 const std::string& display_email) OVERRIDE; 68 const std::string& display_email) OVERRIDE;
64 virtual std::string GetUserDisplayEmail( 69 virtual std::string GetUserDisplayEmail(
65 const std::string& username) const OVERRIDE; 70 const std::string& username) const OVERRIDE;
66 virtual bool IsCurrentUserOwner() const OVERRIDE; 71 virtual bool IsCurrentUserOwner() const OVERRIDE;
67 virtual bool IsCurrentUserNew() const OVERRIDE; 72 virtual bool IsCurrentUserNew() const OVERRIDE;
68 virtual bool IsCurrentUserEphemeral() const OVERRIDE; 73 virtual bool IsCurrentUserEphemeral() const OVERRIDE;
69 virtual bool CanCurrentUserLock() const OVERRIDE; 74 virtual bool CanCurrentUserLock() const OVERRIDE;
70 virtual bool IsUserLoggedIn() const OVERRIDE; 75 virtual bool IsUserLoggedIn() const OVERRIDE;
76 virtual bool IsLoggedInAsRegularUser() const OVERRIDE;
71 virtual bool IsLoggedInAsDemoUser() const OVERRIDE; 77 virtual bool IsLoggedInAsDemoUser() const OVERRIDE;
72 virtual bool IsLoggedInAsPublicAccount() const OVERRIDE; 78 virtual bool IsLoggedInAsPublicAccount() const OVERRIDE;
73 virtual bool IsLoggedInAsGuest() const OVERRIDE; 79 virtual bool IsLoggedInAsGuest() const OVERRIDE;
74 virtual bool IsLoggedInAsStub() const OVERRIDE; 80 virtual bool IsLoggedInAsStub() const OVERRIDE;
75 virtual bool IsSessionStarted() const OVERRIDE; 81 virtual bool IsSessionStarted() const OVERRIDE;
76 virtual bool IsEphemeralUser(const std::string& email) const OVERRIDE; 82 virtual bool IsEphemeralUser(const std::string& email) const OVERRIDE;
77 virtual void AddObserver(UserManager::Observer* obs) OVERRIDE; 83 virtual void AddObserver(UserManager::Observer* obs) OVERRIDE;
78 virtual void RemoveObserver(UserManager::Observer* obs) OVERRIDE; 84 virtual void RemoveObserver(UserManager::Observer* obs) OVERRIDE;
79 virtual void NotifyLocalStateChanged() OVERRIDE; 85 virtual void NotifyLocalStateChanged() OVERRIDE;
80 86
81 // content::NotificationObserver implementation. 87 // content::NotificationObserver implementation.
82 virtual void Observe(int type, 88 virtual void Observe(int type,
83 const content::NotificationSource& source, 89 const content::NotificationSource& source,
84 const content::NotificationDetails& details) OVERRIDE; 90 const content::NotificationDetails& details) OVERRIDE;
85 91
86 // ProfileSyncServiceObserver implementation. 92 // ProfileSyncServiceObserver implementation.
87 virtual void OnStateChanged() OVERRIDE; 93 virtual void OnStateChanged() OVERRIDE;
88 94
89 private: 95 private:
90 friend class UserManagerImplWrapper; 96 friend class UserManagerImplWrapper;
91 friend class WallpaperManager; 97 friend class WallpaperManager;
92 friend class UserManagerTest; 98 friend class UserManagerTest;
93 99
94 UserManagerImpl(); 100 UserManagerImpl();
95 101
102 // Helper function that copies users from |users_list| to |users_vector| and
103 // |users_set|. Duplicates and users already present in |existing_users| are
104 // skipped. The |logged_in_user| is also skipped and the return value
105 // indicates whether that user was found in |users_list|.
106 bool ParseUserList(std::vector<std::string>* users_vector,
107 std::set<std::string>* users_set,
108 const ListValue& users_list,
pastarmovj 2012/11/28 09:57:16 nit: move |users_vector| and |users_set| to be las
bartfab (slow) 2012/11/28 12:30:17 Done.
109 const std::set<std::string>& existing_users,
110 const std::string& logged_in_user) const;
111
96 // Loads |users_| from Local State if the list has not been loaded yet. 112 // Loads |users_| from Local State if the list has not been loaded yet.
97 // Subsequent calls have no effect. Must be called on the UI thread. 113 // Subsequent calls have no effect. Must be called on the UI thread.
98 void EnsureUsersLoaded(); 114 void EnsureUsersLoaded();
99 115
100 // Retrieves trusted device policies and removes users from the persistent 116 // Retrieves trusted device policies and removes users from the persistent
101 // list if ephemeral users are enabled. Schedules a callback to itself if 117 // list if ephemeral users are enabled. Schedules a callback to itself if
102 // trusted device policies are not yet available. 118 // trusted device policies are not yet available.
103 void RetrieveTrustedDevicePolicies(); 119 void RetrieveTrustedDevicePolicies();
104 120
105 // Returns true if trusted device policies have successfully been retrieved 121 // Returns true if trusted device policies have successfully been retrieved
(...skipping 12 matching lines...) Expand all
118 134
119 void SetCurrentUserIsOwner(bool is_current_user_owner); 135 void SetCurrentUserIsOwner(bool is_current_user_owner);
120 136
121 // Updates current user ownership on UI thread. 137 // Updates current user ownership on UI thread.
122 void UpdateOwnership(DeviceSettingsService::OwnershipStatus status, 138 void UpdateOwnership(DeviceSettingsService::OwnershipStatus status,
123 bool is_owner); 139 bool is_owner);
124 140
125 // Triggers an asynchronous ownership check. 141 // Triggers an asynchronous ownership check.
126 void CheckOwnership(); 142 void CheckOwnership();
127 143
128 // Removes the user from the persistent list only. Also removes the user's 144 // Removes data stored or cached outside the user's cryptohome (wallpaper,
129 // picture. 145 // avatar, OAuth token status, display name, display email).
130 void RemoveUserFromListInternal(const std::string& email); 146 void RemoveNonCryptohomeData(const std::string& email);
131 147
132 // List of all known users. User instances are owned by |this| and deleted 148 // Moves the regular user identified by |email| out of the user list or to its
133 // when users are removed by |RemoveUserFromListInternal|. 149 // front, as specified by |move_to_front|.
pastarmovj 2012/11/28 09:57:16 Can you please put some description why is this ne
bartfab (slow) 2012/11/28 12:30:17 Done.
150 User *UpdateRegularUsers(const std::string& email, bool move_to_front);
151
152 // Replaces the list of device-local users with |local_users_list|. Ensures
153 // that data stored outside theit cryptohomes is removed for any users who are
pastarmovj 2012/11/28 09:57:16 s/theit/their/
bartfab (slow) 2012/11/28 12:30:17 Done.
154 // no longer on the list. Returns |true| if the user list has changed.
155 bool UpdateLocalUsers(const base::ListValue& local_users_list);
156
157 // Interface to the signed settings store.
158 CrosSettings* cros_settings_;
159
160 // True if observers have been registered with the signed settings store.
161 bool observing_cros_settings_;
162
163 // True if users have been loaded from prefs already.
164 bool users_loaded_;
165
166 // List of all known users. User instances are owned by |this|. Regular users
167 // are removed by |RemoveUserFromListInternal|, device-local users by
168 // |UpdateLocalUsers|.
pastarmovj 2012/11/28 09:57:16 Write a justification for having this member mutab
bartfab (slow) 2012/11/28 12:30:17 Actually, there is no justification. This seems to
134 mutable UserList users_; 169 mutable UserList users_;
135 170
136 // The logged-in user. NULL until a user has logged in, then points to one 171 // The logged-in user. NULL until a user has logged in, then points to one
137 // of the User instances in |users_|, the |guest_user_| instance or an 172 // of the User instances in |users_|, the |guest_user_| instance or an
138 // ephemeral user instance. 173 // ephemeral user instance.
139 User* logged_in_user_; 174 User* logged_in_user_;
140 175
141 // True if SessionStarted() has been called. 176 // True if SessionStarted() has been called.
142 bool session_started_; 177 bool session_started_;
143 178
(...skipping 27 matching lines...) Expand all
171 206
172 // Profile sync service which is observed to take actions after sync 207 // Profile sync service which is observed to take actions after sync
173 // errors appear. NOTE: there is no guarantee that it is the current sync 208 // errors appear. NOTE: there is no guarantee that it is the current sync
174 // service, so do NOT use it outside |OnStateChanged| method. 209 // service, so do NOT use it outside |OnStateChanged| method.
175 ProfileSyncService* observed_sync_service_; 210 ProfileSyncService* observed_sync_service_;
176 211
177 ObserverList<UserManager::Observer> observer_list_; 212 ObserverList<UserManager::Observer> observer_list_;
178 213
179 scoped_ptr<UserImageManagerImpl> user_image_manager_; 214 scoped_ptr<UserImageManagerImpl> user_image_manager_;
180 215
216 // Weak pointer factory.
217 base::WeakPtrFactory<UserManagerImpl> weak_ptr_factory_;
218
181 DISALLOW_COPY_AND_ASSIGN(UserManagerImpl); 219 DISALLOW_COPY_AND_ASSIGN(UserManagerImpl);
182 }; 220 };
183 221
184 } // namespace chromeos 222 } // namespace chromeos
185 223
186 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_ 224 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698