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