| 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> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/file_path.h" | 14 #include "base/file_path.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
| 17 #include "base/string16.h" | 17 #include "base/string16.h" |
| 18 #include "chrome/browser/profiles/profile_info_cache_observer.h" | 18 #include "chrome/browser/profiles/profile_info_cache_observer.h" |
| 19 #include "chrome/browser/profiles/profile_info_interface.h" | 19 #include "chrome/browser/profiles/profile_info_interface.h" |
| 20 | 20 |
| 21 namespace gfx { | 21 namespace gfx { |
| 22 class Image; | 22 class Image; |
| 23 } | 23 } |
| 24 | 24 |
| 25 namespace base { | 25 namespace base { |
| 26 class DictionaryValue; | 26 class DictionaryValue; |
| 27 } | 27 } |
| 28 | 28 |
| 29 class PrefService; | 29 class PrefService; |
| 30 class PrefServiceSimple; | 30 class PrefRegistrarSimple; |
| 31 | 31 |
| 32 // This class saves various information about profiles to local preferences. | 32 // This class saves various information about profiles to local preferences. |
| 33 // This cache can be used to display a list of profiles without having to | 33 // This cache can be used to display a list of profiles without having to |
| 34 // actually load the profiles from disk. | 34 // actually load the profiles from disk. |
| 35 class ProfileInfoCache : public ProfileInfoInterface, | 35 class ProfileInfoCache : public ProfileInfoInterface, |
| 36 public base::SupportsWeakPtr<ProfileInfoCache> { | 36 public base::SupportsWeakPtr<ProfileInfoCache> { |
| 37 public: | 37 public: |
| 38 ProfileInfoCache(PrefService* prefs, const FilePath& user_data_dir); | 38 ProfileInfoCache(PrefService* prefs, const FilePath& user_data_dir); |
| 39 virtual ~ProfileInfoCache(); | 39 virtual ~ProfileInfoCache(); |
| 40 | 40 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 static bool IsDefaultAvatarIconUrl(const std::string& icon_url, | 120 static bool IsDefaultAvatarIconUrl(const std::string& icon_url, |
| 121 size_t *icon_index); | 121 size_t *icon_index); |
| 122 | 122 |
| 123 // Gets all names of profiles associated with this instance of Chrome. | 123 // Gets all names of profiles associated with this instance of Chrome. |
| 124 // Because this method will be called during uninstall, before the creation | 124 // Because this method will be called during uninstall, before the creation |
| 125 // of the ProfileManager, it reads directly from the local state preferences, | 125 // of the ProfileManager, it reads directly from the local state preferences, |
| 126 // rather than going through the ProfileInfoCache object. | 126 // rather than going through the ProfileInfoCache object. |
| 127 static std::vector<string16> GetProfileNames(); | 127 static std::vector<string16> GetProfileNames(); |
| 128 | 128 |
| 129 // Register cache related preferences in Local State. | 129 // Register cache related preferences in Local State. |
| 130 static void RegisterPrefs(PrefServiceSimple* prefs); | 130 static void RegisterPrefs(PrefRegistrarSimple* prefs); |
| 131 | 131 |
| 132 void AddObserver(ProfileInfoCacheObserver* obs); | 132 void AddObserver(ProfileInfoCacheObserver* obs); |
| 133 void RemoveObserver(ProfileInfoCacheObserver* obs); | 133 void RemoveObserver(ProfileInfoCacheObserver* obs); |
| 134 | 134 |
| 135 private: | 135 private: |
| 136 const base::DictionaryValue* GetInfoForProfileAtIndex(size_t index) const; | 136 const base::DictionaryValue* GetInfoForProfileAtIndex(size_t index) const; |
| 137 // Saves the profile info to a cache and takes ownership of |info|. | 137 // Saves the profile info to a cache and takes ownership of |info|. |
| 138 // Currently the only information that is cached is the profile's name, | 138 // Currently the only information that is cached is the profile's name, |
| 139 // user name, and avatar icon. | 139 // user name, and avatar icon. |
| 140 void SetInfoForProfileAtIndex(size_t index, base::DictionaryValue* info); | 140 void SetInfoForProfileAtIndex(size_t index, base::DictionaryValue* info); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 169 // to be mutable. | 169 // to be mutable. |
| 170 mutable std::map<std::string, gfx::Image*> gaia_pictures_; | 170 mutable std::map<std::string, gfx::Image*> gaia_pictures_; |
| 171 // Marks a gaia profile picture as loading. This prevents a picture from | 171 // Marks a gaia profile picture as loading. This prevents a picture from |
| 172 // loading multiple times. | 172 // loading multiple times. |
| 173 mutable std::map<std::string, bool> gaia_pictures_loading_; | 173 mutable std::map<std::string, bool> gaia_pictures_loading_; |
| 174 | 174 |
| 175 DISALLOW_COPY_AND_ASSIGN(ProfileInfoCache); | 175 DISALLOW_COPY_AND_ASSIGN(ProfileInfoCache); |
| 176 }; | 176 }; |
| 177 | 177 |
| 178 #endif // CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ | 178 #endif // CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ |
| OLD | NEW |