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 | 31 |
31 // This class saves various information about profiles to local preferences. | 32 // This class saves various information about profiles to local preferences. |
32 // 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 |
33 // actually load the profiles from disk. | 34 // actually load the profiles from disk. |
34 class ProfileInfoCache : public ProfileInfoInterface, | 35 class ProfileInfoCache : public ProfileInfoInterface, |
35 public base::SupportsWeakPtr<ProfileInfoCache> { | 36 public base::SupportsWeakPtr<ProfileInfoCache> { |
36 public: | 37 public: |
37 ProfileInfoCache(PrefService* prefs, const FilePath& user_data_dir); | 38 ProfileInfoCache(PrefService* prefs, const FilePath& user_data_dir); |
38 virtual ~ProfileInfoCache(); | 39 virtual ~ProfileInfoCache(); |
39 | 40 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 static bool IsDefaultAvatarIconUrl(const std::string& icon_url, | 120 static bool IsDefaultAvatarIconUrl(const std::string& icon_url, |
120 size_t *icon_index); | 121 size_t *icon_index); |
121 | 122 |
122 // Gets all names of profiles associated with this instance of Chrome. | 123 // Gets all names of profiles associated with this instance of Chrome. |
123 // Because this method will be called during uninstall, before the creation | 124 // Because this method will be called during uninstall, before the creation |
124 // of the ProfileManager, it reads directly from the local state preferences, | 125 // of the ProfileManager, it reads directly from the local state preferences, |
125 // rather than going through the ProfileInfoCache object. | 126 // rather than going through the ProfileInfoCache object. |
126 static std::vector<string16> GetProfileNames(); | 127 static std::vector<string16> GetProfileNames(); |
127 | 128 |
128 // Register cache related preferences in Local State. | 129 // Register cache related preferences in Local State. |
129 static void RegisterPrefs(PrefService* prefs); | 130 static void RegisterPrefs(PrefServiceSimple* prefs); |
130 | 131 |
131 void AddObserver(ProfileInfoCacheObserver* obs); | 132 void AddObserver(ProfileInfoCacheObserver* obs); |
132 void RemoveObserver(ProfileInfoCacheObserver* obs); | 133 void RemoveObserver(ProfileInfoCacheObserver* obs); |
133 | 134 |
134 private: | 135 private: |
135 const base::DictionaryValue* GetInfoForProfileAtIndex(size_t index) const; | 136 const base::DictionaryValue* GetInfoForProfileAtIndex(size_t index) const; |
136 // 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|. |
137 // 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, |
138 // user name, and avatar icon. | 139 // user name, and avatar icon. |
139 void SetInfoForProfileAtIndex(size_t index, base::DictionaryValue* info); | 140 void SetInfoForProfileAtIndex(size_t index, base::DictionaryValue* info); |
(...skipping 28 matching lines...) Expand all Loading... |
168 // to be mutable. | 169 // to be mutable. |
169 mutable std::map<std::string, gfx::Image*> gaia_pictures_; | 170 mutable std::map<std::string, gfx::Image*> gaia_pictures_; |
170 // 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 |
171 // loading multiple times. | 172 // loading multiple times. |
172 mutable std::map<std::string, bool> gaia_pictures_loading_; | 173 mutable std::map<std::string, bool> gaia_pictures_loading_; |
173 | 174 |
174 DISALLOW_COPY_AND_ASSIGN(ProfileInfoCache); | 175 DISALLOW_COPY_AND_ASSIGN(ProfileInfoCache); |
175 }; | 176 }; |
176 | 177 |
177 #endif // CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ | 178 #endif // CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ |
OLD | NEW |