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

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

Issue 9405035: Implement ephemeral users (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: As discussed, removed initial image selection. Created 8 years, 9 months 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 (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 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 int image_index) OVERRIDE; 64 int image_index) OVERRIDE;
65 virtual void SaveUserImage(const std::string& username, 65 virtual void SaveUserImage(const std::string& username,
66 const SkBitmap& image) OVERRIDE; 66 const SkBitmap& image) OVERRIDE;
67 virtual void SaveUserImageFromFile(const std::string& username, 67 virtual void SaveUserImageFromFile(const std::string& username,
68 const FilePath& path) OVERRIDE; 68 const FilePath& path) OVERRIDE;
69 virtual void SaveUserImageFromProfileImage( 69 virtual void SaveUserImageFromProfileImage(
70 const std::string& username) OVERRIDE; 70 const std::string& username) OVERRIDE;
71 virtual void DownloadProfileImage(const std::string& reason) OVERRIDE; 71 virtual void DownloadProfileImage(const std::string& reason) OVERRIDE;
72 virtual bool IsCurrentUserOwner() const OVERRIDE; 72 virtual bool IsCurrentUserOwner() const OVERRIDE;
73 virtual bool IsCurrentUserNew() const OVERRIDE; 73 virtual bool IsCurrentUserNew() const OVERRIDE;
74 virtual bool IsCurrentUserEphemeral() const OVERRIDE;
74 virtual bool IsUserLoggedIn() const OVERRIDE; 75 virtual bool IsUserLoggedIn() const OVERRIDE;
75 virtual bool IsLoggedInAsDemoUser() const OVERRIDE; 76 virtual bool IsLoggedInAsDemoUser() const OVERRIDE;
76 virtual bool IsLoggedInAsGuest() const OVERRIDE; 77 virtual bool IsLoggedInAsGuest() const OVERRIDE;
77 virtual void AddObserver(Observer* obs) OVERRIDE; 78 virtual void AddObserver(Observer* obs) OVERRIDE;
78 virtual void RemoveObserver(Observer* obs) OVERRIDE; 79 virtual void RemoveObserver(Observer* obs) OVERRIDE;
79 virtual void NotifyLocalStateChanged() OVERRIDE; 80 virtual void NotifyLocalStateChanged() OVERRIDE;
80 virtual const SkBitmap& DownloadedProfileImage() const OVERRIDE; 81 virtual const SkBitmap& DownloadedProfileImage() const OVERRIDE;
81 82
82 // content::NotificationObserver implementation. 83 // content::NotificationObserver implementation.
83 virtual void Observe(int type, 84 virtual void Observe(int type,
84 const content::NotificationSource& source, 85 const content::NotificationSource& source,
85 const content::NotificationDetails& details) OVERRIDE; 86 const content::NotificationDetails& details) OVERRIDE;
86 87
87 // ProfileSyncServiceObserver implementation. 88 // ProfileSyncServiceObserver implementation.
88 virtual void OnStateChanged() OVERRIDE; 89 virtual void OnStateChanged() OVERRIDE;
89 90
90 protected: 91 protected:
91 UserManagerImpl(); 92 UserManagerImpl();
92 virtual ~UserManagerImpl(); 93 virtual ~UserManagerImpl();
93 94
94 // Returns image filepath for the given user. 95 // Returns image filepath for the given user.
95 FilePath GetImagePathForUser(const std::string& username); 96 FilePath GetImagePathForUser(const std::string& username);
96 97
97 private: 98 private:
98 friend class UserManagerImplWrapper; 99 friend class UserManagerImplWrapper;
100 friend class UserManagerTest;
99 101
100 // Loads |users_| from Local State if the list has not been loaded yet. 102 // Loads |users_| from Local State if the list has not been loaded yet.
101 // Subsequent calls have no effect. Must be called on the UI thread. 103 // Subsequent calls have no effect. Must be called on the UI thread.
102 void EnsureUsersLoaded(); 104 void EnsureUsersLoaded();
103 105
106 // Retrieves trusted device policies and removes users from the persistent
107 // list if ephemeral users are enabled. Schedules a callback to itself if
108 // trusted device policies are not yet available.
109 void RetrieveTrustedDevicePolicies();
110
111 // Returns true if trusted device policies have successfully been retrieved
112 // and ephemeral users are enabled.
113 bool AreEphemeralUsersEnabled() const;
114
115 // Returns true if the user with the given email address is to be treated as
116 // ephemeral.
117 bool IsEphemeralUser(const std::string& email) const;
118
119 // Returns the user with the given email address if found in the persistent
120 // list. Returns |NULL| otherwise.
121 const User* FindUserInList(const std::string& email) const;
122
104 // Makes stub user the current logged-in user (for test paths). 123 // Makes stub user the current logged-in user (for test paths).
105 void StubUserLoggedIn(); 124 void StubUserLoggedIn();
106 125
107 // Notifies on new user session. 126 // Notifies on new user session.
108 void NotifyOnLogin(); 127 void NotifyOnLogin();
109 128
110 // Reads user's oauth token status from local state preferences. 129 // Reads user's oauth token status from local state preferences.
111 User::OAuthTokenStatus LoadUserOAuthStatus(const std::string& username) const; 130 User::OAuthTokenStatus LoadUserOAuthStatus(const std::string& username) const;
112 131
113 void SetCurrentUserIsOwner(bool is_current_user_owner); 132 void SetCurrentUserIsOwner(bool is_current_user_owner);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 // ProfileDownloaderDelegate implementation. 181 // ProfileDownloaderDelegate implementation.
163 virtual int GetDesiredImageSideLength() const OVERRIDE; 182 virtual int GetDesiredImageSideLength() const OVERRIDE;
164 virtual Profile* GetBrowserProfile() OVERRIDE; 183 virtual Profile* GetBrowserProfile() OVERRIDE;
165 virtual std::string GetCachedPictureURL() const OVERRIDE; 184 virtual std::string GetCachedPictureURL() const OVERRIDE;
166 virtual void OnDownloadComplete(ProfileDownloader* downloader, 185 virtual void OnDownloadComplete(ProfileDownloader* downloader,
167 bool success) OVERRIDE; 186 bool success) OVERRIDE;
168 187
169 // Creates a new User instance. 188 // Creates a new User instance.
170 User* CreateUser(const std::string& email) const; 189 User* CreateUser(const std::string& email) const;
171 190
191 // Removes the user from the persistent list only. Also removes the user's
192 // picture.
193 void RemoveUserFromListInternal(const std::string& email);
194
172 // Loads user image from its file. 195 // Loads user image from its file.
173 scoped_refptr<UserImageLoader> image_loader_; 196 scoped_refptr<UserImageLoader> image_loader_;
174 197
175 // List of all known users. User instances are owned by |this| and deleted 198 // List of all known users. User instances are owned by |this| and deleted
176 // when a user is removed with |RemoveUser|. 199 // when users are removed by |RemoveUserFromListInternal|.
177 mutable UserList users_; 200 mutable UserList users_;
178 201
179 // Map of users' display names used to determine which users have unique 202 // Map of users' display names used to determine which users have unique
180 // display names. 203 // display names.
181 mutable base::hash_map<std::string, size_t> display_name_count_; 204 mutable base::hash_map<std::string, size_t> display_name_count_;
182 205
183 // User instance used to represent the demo user. 206 // User instance used to represent the demo user.
184 User demo_user_; 207 User demo_user_;
185 208
186 // User instance used to represent the off-the-record (guest) user. 209 // User instance used to represent the off-the-record (guest) user.
187 User guest_user_; 210 User guest_user_;
188 211
189 // A stub User instance for test paths (running without a logged-in user). 212 // A stub User instance for test paths (running without a logged-in user).
190 User stub_user_; 213 User stub_user_;
191 214
192 // The logged-in user. NULL until a user has logged in, then points to one 215 // The logged-in user. NULL until a user has logged in, then points to one
193 // of the User instances in |users_| or to the |guest_user_| instance. 216 // of the User instances in |users_|, the |guest_user_| instance or an
194 // In test paths without login points to the |stub_user_| instance. 217 // ephemeral user instance. In test paths without login points to the
218 // |stub_user_| instance.
195 User* logged_in_user_; 219 User* logged_in_user_;
196 220
197 // Cached flag of whether currently logged-in user is owner or not. 221 // Cached flag of whether currently logged-in user is owner or not.
198 // May be accessed on different threads, requires locking. 222 // May be accessed on different threads, requires locking.
199 bool is_current_user_owner_; 223 bool is_current_user_owner_;
200 mutable base::Lock is_current_user_owner_lock_; 224 mutable base::Lock is_current_user_owner_lock_;
201 225
202 // Cached flag of whether the currently logged-in user existed before this 226 // Cached flag of whether the currently logged-in user existed before this
203 // login. 227 // login.
204 bool is_current_user_new_; 228 bool is_current_user_new_;
205 229
230 // Cached flag of whether the currently logged-in user is ephemeral. Storage
231 // of persistent information is avoided for such users by not adding them to
232 // the user list in local state, not downloading their custom user images and
233 // mounting their cryptohomes using tmpfs.
234 bool is_current_user_ephemeral_;
235
206 // Cached flag of whether any user is logged in at the moment. 236 // Cached flag of whether any user is logged in at the moment.
207 bool is_user_logged_in_; 237 bool is_user_logged_in_;
208 238
239 // Cached flag indicating whether ephemeral users are enabled. Defaults to
240 // |false| if the value has not been read from trusted device policy yet.
241 bool ephemeral_users_enabled_;
242
243 // Cached name of device owner. Defaults to empty string if the value has not
244 // been read from trusted device policy yet.
245 std::string owner_email_;
246
209 content::NotificationRegistrar registrar_; 247 content::NotificationRegistrar registrar_;
210 248
211 // Profile sync service which is observed to take actions after sync 249 // Profile sync service which is observed to take actions after sync
212 // errors appear. NOTE: there is no guarantee that it is the current sync 250 // errors appear. NOTE: there is no guarantee that it is the current sync
213 // service, so do NOT use it outside |OnStateChanged| method. 251 // service, so do NOT use it outside |OnStateChanged| method.
214 ProfileSyncService* observed_sync_service_; 252 ProfileSyncService* observed_sync_service_;
215 253
216 ObserverList<Observer> observer_list_; 254 ObserverList<Observer> observer_list_;
217 255
218 // Download user profile image on login to update it if it's changed. 256 // Download user profile image on login to update it if it's changed.
(...skipping 15 matching lines...) Expand all
234 272
235 // Data URL for |downloaded_profile_image_|. 273 // Data URL for |downloaded_profile_image_|.
236 std::string downloaded_profile_image_data_url_; 274 std::string downloaded_profile_image_data_url_;
237 275
238 DISALLOW_COPY_AND_ASSIGN(UserManagerImpl); 276 DISALLOW_COPY_AND_ASSIGN(UserManagerImpl);
239 }; 277 };
240 278
241 } // namespace chromeos 279 } // namespace chromeos
242 280
243 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_ 281 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698