| 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_PROFILES_PROFILE_INFO_CACHE_H_ | 5 #ifndef CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ |
| 6 #define CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ | 6 #define CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 class PrefRegistrySimple; | 30 class PrefRegistrySimple; |
| 31 class ProfileAvatarDownloader; | 31 class ProfileAvatarDownloader; |
| 32 | 32 |
| 33 // This class saves various information about profiles to local preferences. | 33 // This class saves various information about profiles to local preferences. |
| 34 // This cache can be used to display a list of profiles without having to | 34 // This cache can be used to display a list of profiles without having to |
| 35 // actually load the profiles from disk. | 35 // actually load the profiles from disk. |
| 36 class ProfileInfoCache : public ProfileInfoInterface, | 36 class ProfileInfoCache : public ProfileInfoInterface, |
| 37 public base::SupportsWeakPtr<ProfileInfoCache> { | 37 public base::SupportsWeakPtr<ProfileInfoCache> { |
| 38 public: | 38 public: |
| 39 ProfileInfoCache(PrefService* prefs, const base::FilePath& user_data_dir); | 39 ProfileInfoCache(PrefService* prefs, const base::FilePath& user_data_dir); |
| 40 virtual ~ProfileInfoCache(); | 40 ~ProfileInfoCache() override; |
| 41 | 41 |
| 42 // If the |supervised_user_id| is non-empty, the profile will be marked to be | 42 // If the |supervised_user_id| is non-empty, the profile will be marked to be |
| 43 // omitted from the avatar-menu list on desktop versions. This is used while a | 43 // omitted from the avatar-menu list on desktop versions. This is used while a |
| 44 // supervised user is in the process of being registered with the server. Use | 44 // supervised user is in the process of being registered with the server. Use |
| 45 // SetIsOmittedProfileAtIndex() to clear the flag when the profile is ready to | 45 // SetIsOmittedProfileAtIndex() to clear the flag when the profile is ready to |
| 46 // be shown in the menu. | 46 // be shown in the menu. |
| 47 void AddProfileToCache(const base::FilePath& profile_path, | 47 void AddProfileToCache(const base::FilePath& profile_path, |
| 48 const base::string16& name, | 48 const base::string16& name, |
| 49 const base::string16& username, | 49 const base::string16& username, |
| 50 size_t icon_index, | 50 size_t icon_index, |
| 51 const std::string& supervised_user_id); | 51 const std::string& supervised_user_id); |
| 52 void DeleteProfileFromCache(const base::FilePath& profile_path); | 52 void DeleteProfileFromCache(const base::FilePath& profile_path); |
| 53 | 53 |
| 54 // ProfileInfoInterface: | 54 // ProfileInfoInterface: |
| 55 virtual size_t GetNumberOfProfiles() const override; | 55 size_t GetNumberOfProfiles() const override; |
| 56 // Don't cache this value and reuse, because resorting the menu could cause | 56 // Don't cache this value and reuse, because resorting the menu could cause |
| 57 // the item being referred to to change out from under you. | 57 // the item being referred to to change out from under you. |
| 58 virtual size_t GetIndexOfProfileWithPath( | 58 size_t GetIndexOfProfileWithPath( |
| 59 const base::FilePath& profile_path) const override; | 59 const base::FilePath& profile_path) const override; |
| 60 virtual base::string16 GetNameOfProfileAtIndex(size_t index) const override; | 60 base::string16 GetNameOfProfileAtIndex(size_t index) const override; |
| 61 virtual base::string16 GetShortcutNameOfProfileAtIndex(size_t index) | 61 base::string16 GetShortcutNameOfProfileAtIndex(size_t index) const override; |
| 62 const override; | 62 base::FilePath GetPathOfProfileAtIndex(size_t index) const override; |
| 63 virtual base::FilePath GetPathOfProfileAtIndex(size_t index) const override; | 63 base::Time GetProfileActiveTimeAtIndex(size_t index) const override; |
| 64 virtual base::Time GetProfileActiveTimeAtIndex(size_t index) const override; | 64 base::string16 GetUserNameOfProfileAtIndex(size_t index) const override; |
| 65 virtual base::string16 GetUserNameOfProfileAtIndex( | 65 const gfx::Image& GetAvatarIconOfProfileAtIndex(size_t index) const override; |
| 66 size_t index) const override; | 66 std::string GetLocalAuthCredentialsOfProfileAtIndex( |
| 67 virtual const gfx::Image& GetAvatarIconOfProfileAtIndex( | |
| 68 size_t index) const override; | |
| 69 virtual std::string GetLocalAuthCredentialsOfProfileAtIndex( | |
| 70 size_t index) const override; | 67 size_t index) const override; |
| 71 // Note that a return value of false could mean an error in collection or | 68 // Note that a return value of false could mean an error in collection or |
| 72 // that there are currently no background apps running. However, the action | 69 // that there are currently no background apps running. However, the action |
| 73 // which results is the same in both cases (thus far). | 70 // which results is the same in both cases (thus far). |
| 74 virtual bool GetBackgroundStatusOfProfileAtIndex( | 71 bool GetBackgroundStatusOfProfileAtIndex(size_t index) const override; |
| 75 size_t index) const override; | 72 base::string16 GetGAIANameOfProfileAtIndex(size_t index) const override; |
| 76 virtual base::string16 GetGAIANameOfProfileAtIndex( | 73 base::string16 GetGAIAGivenNameOfProfileAtIndex(size_t index) const override; |
| 77 size_t index) const override; | |
| 78 virtual base::string16 GetGAIAGivenNameOfProfileAtIndex( | |
| 79 size_t index) const override; | |
| 80 // Returns the GAIA picture for the given profile. This may return NULL | 74 // Returns the GAIA picture for the given profile. This may return NULL |
| 81 // if the profile does not have a GAIA picture or if the picture must be | 75 // if the profile does not have a GAIA picture or if the picture must be |
| 82 // loaded from disk. | 76 // loaded from disk. |
| 83 virtual const gfx::Image* GetGAIAPictureOfProfileAtIndex( | 77 const gfx::Image* GetGAIAPictureOfProfileAtIndex(size_t index) const override; |
| 84 size_t index) const override; | 78 bool IsUsingGAIAPictureOfProfileAtIndex(size_t index) const override; |
| 85 virtual bool IsUsingGAIAPictureOfProfileAtIndex( | 79 bool ProfileIsSupervisedAtIndex(size_t index) const override; |
| 86 size_t index) const override; | 80 bool IsOmittedProfileAtIndex(size_t index) const override; |
| 87 virtual bool ProfileIsSupervisedAtIndex(size_t index) const override; | 81 bool ProfileIsSigninRequiredAtIndex(size_t index) const override; |
| 88 virtual bool IsOmittedProfileAtIndex(size_t index) const override; | 82 std::string GetSupervisedUserIdOfProfileAtIndex(size_t index) const override; |
| 89 virtual bool ProfileIsSigninRequiredAtIndex(size_t index) const override; | 83 bool ProfileIsEphemeralAtIndex(size_t index) const override; |
| 90 virtual std::string GetSupervisedUserIdOfProfileAtIndex(size_t index) const | 84 bool ProfileIsUsingDefaultNameAtIndex(size_t index) const override; |
| 91 override; | 85 bool ProfileIsUsingDefaultAvatarAtIndex(size_t index) const override; |
| 92 virtual bool ProfileIsEphemeralAtIndex(size_t index) const override; | |
| 93 virtual bool ProfileIsUsingDefaultNameAtIndex(size_t index) const override; | |
| 94 virtual bool ProfileIsUsingDefaultAvatarAtIndex(size_t index) const override; | |
| 95 | 86 |
| 96 size_t GetAvatarIconIndexOfProfileAtIndex(size_t index) const; | 87 size_t GetAvatarIconIndexOfProfileAtIndex(size_t index) const; |
| 97 | 88 |
| 98 void SetProfileActiveTimeAtIndex(size_t index); | 89 void SetProfileActiveTimeAtIndex(size_t index); |
| 99 // Warning: This will re-sort profiles and thus may change indices! | 90 // Warning: This will re-sort profiles and thus may change indices! |
| 100 void SetNameOfProfileAtIndex(size_t index, const base::string16& name); | 91 void SetNameOfProfileAtIndex(size_t index, const base::string16& name); |
| 101 void SetShortcutNameOfProfileAtIndex(size_t index, | 92 void SetShortcutNameOfProfileAtIndex(size_t index, |
| 102 const base::string16& name); | 93 const base::string16& name); |
| 103 void SetUserNameOfProfileAtIndex(size_t index, | 94 void SetUserNameOfProfileAtIndex(size_t index, |
| 104 const base::string16& user_name); | 95 const base::string16& user_name); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 // This prevents a picture from being downloaded multiple times. The | 220 // This prevents a picture from being downloaded multiple times. The |
| 230 // ProfileAvatarDownloader instances are deleted when the download completes | 221 // ProfileAvatarDownloader instances are deleted when the download completes |
| 231 // or when the ProfileInfoCache is destroyed. | 222 // or when the ProfileInfoCache is destroyed. |
| 232 mutable std::map<std::string, ProfileAvatarDownloader*> | 223 mutable std::map<std::string, ProfileAvatarDownloader*> |
| 233 avatar_images_downloads_in_progress_; | 224 avatar_images_downloads_in_progress_; |
| 234 | 225 |
| 235 DISALLOW_COPY_AND_ASSIGN(ProfileInfoCache); | 226 DISALLOW_COPY_AND_ASSIGN(ProfileInfoCache); |
| 236 }; | 227 }; |
| 237 | 228 |
| 238 #endif // CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ | 229 #endif // CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ |
| OLD | NEW |