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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USER_IMAGE_MANAGER_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USER_IMAGE_MANAGER_H_ 7 8 #include <string> 9 10 #include "chrome/browser/chromeos/login/user.h" 11 12 class PrefRegistrySimple; 13 14 namespace base { 15 class FilePath; 16 } 17 18 namespace gfx { 19 class ImageSkia; 20 } 21 22 namespace chromeos { 23 24 class UserImage; 25 26 // Base class that provides a mechanism for updating user images. 27 class UserImageManager { 28 public: 29 // Registers user image manager preferences. 30 static void RegisterPrefs(PrefRegistrySimple* registry); 31 32 virtual ~UserImageManager(); 33 34 // Loads user image data from Local State. 35 virtual void LoadUserImages(const UserList& users) = 0; 36 37 // Indicates that a user with the given |email| has just logged in. 38 virtual void UserLoggedIn(const std::string& email, 39 bool user_is_new, 40 bool user_is_local) = 0; 41 42 // Sets user image to the default image with index |image_index|, sends 43 // LOGIN_USER_IMAGE_CHANGED notification and updates Local State. 44 virtual void SaveUserDefaultImageIndex(const std::string& username, 45 int image_index) = 0; 46 47 // Saves image to file, sends LOGIN_USER_IMAGE_CHANGED notification and 48 // updates Local State. 49 virtual void SaveUserImage(const std::string& username, 50 const UserImage& user_image) = 0; 51 52 // Tries to load user image from disk; if successful, sets it for the user, 53 // sends LOGIN_USER_IMAGE_CHANGED notification and updates Local State. 54 virtual void SaveUserImageFromFile(const std::string& username, 55 const base::FilePath& path) = 0; 56 57 // Sets profile image as user image for |username|, sends 58 // LOGIN_USER_IMAGE_CHANGED notification and updates Local State. If the user 59 // is not logged-in or the last |DownloadProfileImage| call has failed, a 60 // default grey avatar will be used until the user logs in and profile image 61 // is downloaded successfully. 62 virtual void SaveUserImageFromProfileImage(const std::string& username) = 0; 63 64 // Deletes user image and the corresponding image file. 65 virtual void DeleteUserImage(const std::string& username) = 0; 66 67 // Starts downloading the profile image for the logged-in user. 68 // If user's image index is |kProfileImageIndex|, newly downloaded image 69 // is immediately set as user's current picture. 70 // |reason| is an arbitrary string (used to report UMA histograms with 71 // download times). 72 virtual void DownloadProfileImage(const std::string& reason) = 0; 73 74 // Returns the result of the last successful profile image download, if any. 75 // Otherwise, returns an empty bitmap. 76 virtual const gfx::ImageSkia& DownloadedProfileImage() const = 0; 77 78 // Cancels any profile image download in progress. 79 virtual void Shutdown() = 0; 80 }; 81 82 } // namespace chromeos 83 84 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_IMAGE_MANAGER_H_ 85