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

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

Issue 8510069: Make ProfileImageDownloader available to non-chromeos code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix build Created 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/hash_tables.h" 12 #include "base/hash_tables.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/observer_list.h" 14 #include "base/observer_list.h"
15 #include "base/synchronization/lock.h" 15 #include "base/synchronization/lock.h"
16 #include "base/time.h" 16 #include "base/time.h"
17 #include "chrome/browser/chromeos/login/profile_image_downloader.h"
18 #include "chrome/browser/chromeos/login/user.h" 17 #include "chrome/browser/chromeos/login/user.h"
19 #include "chrome/browser/chromeos/login/user_image_loader.h" 18 #include "chrome/browser/chromeos/login/user_image_loader.h"
19 #include "chrome/browser/profiles/profile_downloader_delegate.h"
20 #include "content/public/browser/notification_observer.h" 20 #include "content/public/browser/notification_observer.h"
21 #include "content/public/browser/notification_registrar.h" 21 #include "content/public/browser/notification_registrar.h"
22 #include "third_party/skia/include/core/SkBitmap.h" 22 #include "third_party/skia/include/core/SkBitmap.h"
23 23
24 class FilePath; 24 class FilePath;
25 class PrefService; 25 class PrefService;
26 class ProfileDownloader;
26 27
27 namespace base { 28 namespace base {
28 template<typename> struct DefaultLazyInstanceTraits; 29 template<typename> struct DefaultLazyInstanceTraits;
29 } 30 }
30 31
31 namespace chromeos { 32 namespace chromeos {
32 33
33 class RemoveUserDelegate; 34 class RemoveUserDelegate;
34 35
35 // This class provides a mechanism for discovering users who have logged 36 // This class provides a mechanism for discovering users who have logged
36 // into this chromium os device before and updating that list. 37 // into this chromium os device before and updating that list.
37 class UserManager : public ProfileImageDownloader::Delegate, 38 class UserManager : public ProfileDownloaderDelegate,
38 public content::NotificationObserver { 39 public content::NotificationObserver {
39 public: 40 public:
40 // Returns a shared instance of a UserManager. Not thread-safe, should only be 41 // Returns a shared instance of a UserManager. Not thread-safe, should only be
41 // called from the main UI thread. 42 // called from the main UI thread.
42 static UserManager* Get(); 43 static UserManager* Get();
43 44
44 // Registers user manager preferences. 45 // Registers user manager preferences.
45 static void RegisterPrefs(PrefService* local_state); 46 static void RegisterPrefs(PrefService* local_state);
46 47
47 // Returns a list of the users who have logged into this device previously. 48 // Returns a list of the users who have logged into this device previously.
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 204
204 // Deletes user's image file. Runs on FILE thread. 205 // Deletes user's image file. Runs on FILE thread.
205 void DeleteUserImage(const FilePath& image_path); 206 void DeleteUserImage(const FilePath& image_path);
206 207
207 // Updates current user ownership on UI thread. 208 // Updates current user ownership on UI thread.
208 void UpdateOwnership(bool is_owner); 209 void UpdateOwnership(bool is_owner);
209 210
210 // Checks current user's ownership on file thread. 211 // Checks current user's ownership on file thread.
211 void CheckOwnership(); 212 void CheckOwnership();
212 213
213 // ProfileImageDownloader::Delegate implementation. 214 // ProfileDownloaderDelegate implementation.
214 virtual void OnDownloadSuccess(const SkBitmap& image) OVERRIDE; 215 virtual int GetDesiredImageSideLength() OVERRIDE;
215 virtual void OnDownloadFailure() OVERRIDE; 216 virtual Profile* GetBrowserProfile() OVERRIDE;
216 virtual void OnDownloadDefaultImage() OVERRIDE; 217 virtual void OnDownloadComplete(ProfileDownloader* downloader,
218 bool success) OVERRIDE;
217 219
218 // Creates a new User instance. 220 // Creates a new User instance.
219 User* CreateUser(const std::string& email) const; 221 User* CreateUser(const std::string& email) const;
220 222
221 // Loads user image from its file. 223 // Loads user image from its file.
222 scoped_refptr<UserImageLoader> image_loader_; 224 scoped_refptr<UserImageLoader> image_loader_;
223 225
224 // List of all known users. User instances are owned by |this| and deleted 226 // List of all known users. User instances are owned by |this| and deleted
225 // when a user is removed with |RemoveUser|. 227 // when a user is removed with |RemoveUser|.
226 mutable UserList users_; 228 mutable UserList users_;
(...skipping 25 matching lines...) Expand all
252 // Cached flag of whether any user is logged in at the moment. 254 // Cached flag of whether any user is logged in at the moment.
253 bool user_is_logged_in_; 255 bool user_is_logged_in_;
254 256
255 content::NotificationRegistrar registrar_; 257 content::NotificationRegistrar registrar_;
256 258
257 friend struct base::DefaultLazyInstanceTraits<UserManager>; 259 friend struct base::DefaultLazyInstanceTraits<UserManager>;
258 260
259 ObserverList<Observer> observer_list_; 261 ObserverList<Observer> observer_list_;
260 262
261 // Download user profile image on login to update it if it's changed. 263 // Download user profile image on login to update it if it's changed.
262 scoped_ptr<ProfileImageDownloader> profile_image_downloader_; 264 scoped_ptr<ProfileDownloader> profile_image_downloader_;
263 265
264 // Time when the profile image download has started. 266 // Time when the profile image download has started.
265 base::Time profile_image_load_start_time_; 267 base::Time profile_image_load_start_time_;
266 268
267 // True if the last user image required async save operation (which may not 269 // True if the last user image required async save operation (which may not
268 // have been completed yet). This flag is used to avoid races when user image 270 // have been completed yet). This flag is used to avoid races when user image
269 // is first set with |SaveUserImage| and then with |SaveUserImagePath|. 271 // is first set with |SaveUserImage| and then with |SaveUserImagePath|.
270 bool last_image_set_async_; 272 bool last_image_set_async_;
271 273
272 // Result of the last successful profile image download, if any. 274 // Result of the last successful profile image download, if any.
273 SkBitmap downloaded_profile_image_; 275 SkBitmap downloaded_profile_image_;
274 276
275 // Data URL for |downloaded_profile_image_|. 277 // Data URL for |downloaded_profile_image_|.
276 std::string downloaded_profile_image_data_url_; 278 std::string downloaded_profile_image_data_url_;
277 279
278 DISALLOW_COPY_AND_ASSIGN(UserManager); 280 DISALLOW_COPY_AND_ASSIGN(UserManager);
279 }; 281 };
280 282
281 } // namespace chromeos 283 } // namespace chromeos
282 284
283 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_H_ 285 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/user_image_loader.cc ('k') | chrome/browser/chromeos/login/user_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698